@eso-status/forum-message 2.0.0-dev.6 → 2.0.0-dev.8

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.
@@ -60,9 +60,9 @@ export default class Connector {
60
60
  */
61
61
  private fetch;
62
62
  /**
63
- * Method for retrieving the information contained in an announcement
64
- * @param raw Raw data of the announcement
63
+ * Method to create the return list with all the data contained in the announcements, sorted by importance while avoiding duplicates
64
+ * @param matches List of all the data contained in the announcements
65
65
  * @private
66
66
  */
67
- private fetchEach;
67
+ private fetchAll;
68
68
  }
package/lib/connector.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const axios_1 = require("axios");
4
+ const types_1 = require("@eso-status/types");
4
5
  const raw_1 = require("./raw");
5
6
  /**
6
7
  * Class for retrieving information from announcements
@@ -50,7 +51,7 @@ class Connector {
50
51
  * @private
51
52
  */
52
53
  getMessages() {
53
- ['WarningMessage', 'AlertMessage'].forEach((type) => this.getMessagesByType(type));
54
+ ['AlertMessage', 'WarningMessage'].forEach((type) => this.getMessagesByType(type));
54
55
  }
55
56
  /**
56
57
  * Method for retrieving raw announcements based on the announcement level
@@ -76,10 +77,14 @@ class Connector {
76
77
  initialRaw = initialRaw.replace(' 。', '');
77
78
  initialRaw = initialRaw.replace(/<br\/>\n/g, '<br>');
78
79
  initialRaw = initialRaw.replace('. <br>', '.<br>');
79
- if (!initialRaw.includes('. <')) {
80
- return initialRaw.replace('. ', '.');
80
+ initialRaw = initialRaw.replace(' Thank you for your patience.', '');
81
+ if (initialRaw.includes('. Please check here for status updates: <a href')) {
82
+ return initialRaw.split(' Please check here for status updates: <a href')[0];
81
83
  }
82
- return initialRaw;
84
+ if (initialRaw.includes('. <a href')) {
85
+ return initialRaw.split(' <a href')[0];
86
+ }
87
+ return initialRaw.replace('. ', '.');
83
88
  });
84
89
  }
85
90
  /**
@@ -110,16 +115,34 @@ class Connector {
110
115
  * @private
111
116
  */
112
117
  fetch() {
113
- this.raw.forEach((raw) => this.fetchEach(raw));
118
+ const matches = [];
119
+ this.raw.forEach((raw) => {
120
+ new raw_1.default(this.url, raw).matches.forEach((match) => {
121
+ matches.push(match);
122
+ });
123
+ });
124
+ this.fetchAll(matches);
114
125
  }
115
126
  /**
116
- * Method for retrieving the information contained in an announcement
117
- * @param raw Raw data of the announcement
127
+ * Method to create the return list with all the data contained in the announcements, sorted by importance while avoiding duplicates
128
+ * @param matches List of all the data contained in the announcements
118
129
  * @private
119
130
  */
120
- fetchEach(raw) {
121
- new raw_1.default(this.url, raw).matches.forEach((match) => {
122
- this.rawEsoStatus.push(match);
131
+ fetchAll(matches) {
132
+ matches.forEach((match) => {
133
+ const alreadyInList = this.rawEsoStatus.filter((esoStatusRawData) => esoStatusRawData.slug === match.slug).length !== 0;
134
+ const alone = matches.filter((esoStatusRawData) => esoStatusRawData.slug === match.slug).length === 1;
135
+ const slugIsIssues = matches.filter((esoStatusRawData) => esoStatusRawData.status === types_1.IssuesStatus &&
136
+ esoStatusRawData.slug === match.slug).length !== 0;
137
+ const slugIsUp = matches.filter((esoStatusRawData) => esoStatusRawData.status === types_1.UpStatus &&
138
+ esoStatusRawData.slug === match.slug).length !== 0;
139
+ if (!alreadyInList) {
140
+ if (alone ||
141
+ (match.status === types_1.IssuesStatus && slugIsIssues) ||
142
+ (match.status === types_1.UpStatus && slugIsUp)) {
143
+ this.rawEsoStatus.push(match);
144
+ }
145
+ }
123
146
  });
124
147
  }
125
148
  }
@@ -53,6 +53,21 @@ export default class DateFormatter {
53
53
  * @private
54
54
  */
55
55
  private getRawHour;
56
+ /**
57
+ * Method to check if the time in parentheses is in UTC or not
58
+ * @private
59
+ */
60
+ private isUTCHour;
61
+ /**
62
+ * Method to retrieve the time when it is in UTC
63
+ * @private
64
+ */
65
+ private getRawUTCHour;
66
+ /**
67
+ * Method for retrieving the time when it is not in UTC
68
+ * @private
69
+ */
70
+ private getRawNoUTCHour;
56
71
  /**
57
72
  * Method for retrieving the minute number of the start time for case #1
58
73
  * @private
@@ -63,6 +78,21 @@ export default class DateFormatter {
63
78
  * @private
64
79
  */
65
80
  private getRawClassicHour2;
81
+ /**
82
+ * Method to check if the second time in parentheses is in UTC or not
83
+ * @private
84
+ */
85
+ private isUTCClassicHour2;
86
+ /**
87
+ * Method to retrieve the second time when it is in UTC
88
+ * @private
89
+ */
90
+ private getRawUTCClassicHour2;
91
+ /**
92
+ * Method to retrieve the second time when it is not in UTC
93
+ * @private
94
+ */
95
+ private getRawNoUTCClassicHour2;
66
96
  /**
67
97
  * Method for retrieving the minute number of the end time in case #1
68
98
  * @private
@@ -79,8 +79,33 @@ class DateFormatter {
79
79
  * @private
80
80
  */
81
81
  getRawHour() {
82
+ if (this.isUTCHour()) {
83
+ return this.getRawUTCHour();
84
+ }
85
+ return this.getRawNoUTCHour();
86
+ }
87
+ /**
88
+ * Method to check if the time in parentheses is in UTC or not
89
+ * @private
90
+ */
91
+ isUTCHour() {
92
+ return (this.rawDate.split(' UTC)').length === 3 ||
93
+ this.rawDate.split(' UTC)').length === 2);
94
+ }
95
+ /**
96
+ * Method to retrieve the time when it is in UTC
97
+ * @private
98
+ */
99
+ getRawUTCHour() {
82
100
  return Number(this.rawDate.split('(')[1].split(':')[0]);
83
101
  }
102
+ /**
103
+ * Method for retrieving the time when it is not in UTC
104
+ * @private
105
+ */
106
+ getRawNoUTCHour() {
107
+ return Number(this.rawDate.split(':')[0].split(', ')[1]);
108
+ }
84
109
  /**
85
110
  * Method for retrieving the minute number of the start time for case #1
86
111
  * @private
@@ -93,8 +118,32 @@ class DateFormatter {
93
118
  * @private
94
119
  */
95
120
  getRawClassicHour2() {
121
+ if (this.isUTCClassicHour2()) {
122
+ return this.getRawUTCClassicHour2();
123
+ }
124
+ return this.getRawNoUTCClassicHour2();
125
+ }
126
+ /**
127
+ * Method to check if the second time in parentheses is in UTC or not
128
+ * @private
129
+ */
130
+ isUTCClassicHour2() {
131
+ return this.rawDate.split(' UTC)').length === 3;
132
+ }
133
+ /**
134
+ * Method to retrieve the second time when it is in UTC
135
+ * @private
136
+ */
137
+ getRawUTCClassicHour2() {
96
138
  return Number(this.rawDate.split('(')[2].split(':')[0]);
97
139
  }
140
+ /**
141
+ * Method to retrieve the second time when it is not in UTC
142
+ * @private
143
+ */
144
+ getRawNoUTCClassicHour2() {
145
+ return Number(this.rawDate.split(' - ')[1].split(':')[0]);
146
+ }
98
147
  /**
99
148
  * Method for retrieving the minute number of the end time in case #1
100
149
  * @private
@@ -54,6 +54,7 @@ class SlugIdentifier {
54
54
  */
55
55
  this.ServerPsEuMatchesList = [
56
56
  'PlayStation®: NA and EU megaservers for',
57
+ 'The PlayStation™ Network',
57
58
  ];
58
59
  /**
59
60
  * List of indicators proving that the announcement pertains to the slug server_ps_na
@@ -61,6 +62,7 @@ class SlugIdentifier {
61
62
  */
62
63
  this.ServerPsNaMatchesList = [
63
64
  'PlayStation®: NA and EU megaservers for',
65
+ 'The PlayStation™ Network',
64
66
  ];
65
67
  /**
66
68
  * List of indicators proving that the announcement pertains to the slug server_xbox_eu
@@ -68,6 +70,7 @@ class SlugIdentifier {
68
70
  */
69
71
  this.ServerXboxEuMatchesList = [
70
72
  'Xbox: NA and EU megaservers for',
73
+ 'Xbox: EU megaserver for',
71
74
  ];
72
75
  /**
73
76
  * List of indicators proving that the announcement pertains to the slug server_xbox_na
@@ -33,6 +33,11 @@ export default class StatusIdentifier {
33
33
  * @private
34
34
  */
35
35
  private readonly plannedMatchesList;
36
+ /**
37
+ * List of indicators proving that the announcement pertains to the status issues
38
+ * @private
39
+ */
40
+ private readonly issuesMatchesList;
36
41
  /**
37
42
  * @param raw Raw data of the announcement
38
43
  */
@@ -14,7 +14,12 @@ class StatusIdentifier {
14
14
  * List of statuses to check for presence in the announcement
15
15
  * @private
16
16
  */
17
- this.statusList = [types_1.UpStatus, types_1.DownStatus, types_1.PlannedStatus];
17
+ this.statusList = [
18
+ types_1.UpStatus,
19
+ types_1.DownStatus,
20
+ types_1.PlannedStatus,
21
+ types_1.IssuesStatus,
22
+ ];
18
23
  /**
19
24
  * List of indicators proving that the announcement pertains to the status up
20
25
  * @private
@@ -23,6 +28,7 @@ class StatusIdentifier {
23
28
  '[COMPLETE]',
24
29
  'now available',
25
30
  'complete',
31
+ 'been resolved',
26
32
  ];
27
33
  /**
28
34
  * List of indicators proving that the announcement pertains to the status down
@@ -40,6 +46,13 @@ class StatusIdentifier {
40
46
  this.plannedMatchesList = [
41
47
  'We will be performing maintenance',
42
48
  ];
49
+ /**
50
+ * List of indicators proving that the announcement pertains to the status issues
51
+ * @private
52
+ */
53
+ this.issuesMatchesList = [
54
+ 'is currently experiencing a service interruption',
55
+ ];
43
56
  this.statusList.forEach((status) => this.identify(status));
44
57
  this.default();
45
58
  }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Different statuses of announcements indicating that the announcement refers to a service/server that is not functioning properly
3
+ */
4
+ export type RemoteIssuesRawStatus = 'is currently experiencing a service interruption';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=remoteIssuesRawStatus.type.js.map
@@ -5,7 +5,8 @@ import { RemoteServerPsEuRawSlug } from './remoteServerPsEuRawSlug.type';
5
5
  import { RemoteServerXboxEuRawSlug } from './remoteServerXboxEuRawSlug.type';
6
6
  import { RemoteServiceStoreEsoRawSlug } from './remoteServiceStoreEsoRawSlug.type';
7
7
  import { RemoteServiceWebSiteRawSlug } from './remoteServiceWebSiteRawSlug.type';
8
+ import { RemoteServerXboxNaRawSlug } from './remoteServerXboxNaRawSlug.type';
8
9
  /**
9
10
  * Different slugs of announcements
10
11
  */
11
- export type RemoteRawSlug = RemoteServerPcEuRawSlug | RemoteServerPcNaRawSlug | RemoteServerPcPtsRawSlug | RemoteServerPsEuRawSlug | RemoteServerXboxEuRawSlug | RemoteServiceStoreEsoRawSlug | RemoteServiceWebSiteRawSlug;
12
+ export type RemoteRawSlug = RemoteServerPcEuRawSlug | RemoteServerPcNaRawSlug | RemoteServerPcPtsRawSlug | RemoteServerPsEuRawSlug | RemoteServerXboxEuRawSlug | RemoteServerXboxNaRawSlug | RemoteServiceStoreEsoRawSlug | RemoteServiceWebSiteRawSlug;
@@ -1,7 +1,8 @@
1
1
  import { RemoteUpRawStatus } from './remoteUpRawStatus.type';
2
2
  import { RemoteDownRawStatus } from './remoteDownRawStatus.type';
3
3
  import { RemotePlannedRawStatus } from './remotePlannedRawStatus.type';
4
+ import { RemoteIssuesRawStatus } from './remoteIssuesRawStatus.type';
4
5
  /**
5
6
  * Different statuses of announcements
6
7
  */
7
- export type RemoteRawStatus = RemoteUpRawStatus | RemoteDownRawStatus | RemotePlannedRawStatus;
8
+ export type RemoteRawStatus = RemoteUpRawStatus | RemoteDownRawStatus | RemotePlannedRawStatus | RemoteIssuesRawStatus;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Different slugs of announcements concerning the European PlayStation® Megaserver
3
3
  */
4
- export type RemoteServerPsEuRawSlug = 'PlayStation®: NA and EU megaservers for';
4
+ export type RemoteServerPsEuRawSlug = 'PlayStation®: NA and EU megaservers for' | 'The PlayStation™ Network';
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Different slugs of announcements concerning the North American PlayStation® Megaserver
3
3
  */
4
- export type RemoteServerPsNaRawSlug = 'PlayStation®: NA and EU megaservers for';
4
+ export type RemoteServerPsNaRawSlug = 'PlayStation®: NA and EU megaservers for' | 'The PlayStation™ Network';
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Different slugs of announcements concerning the European Xbox Megaserver
3
3
  */
4
- export type RemoteServerXboxEuRawSlug = 'Xbox: NA and EU megaservers for';
4
+ export type RemoteServerXboxEuRawSlug = 'Xbox: NA and EU megaservers for' | 'Xbox: EU megaserver for';
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Different statuses of announcements indicating that the announcement refers to an accessible service/server
3
3
  */
4
- export type RemoteUpRawStatus = '[COMPLETE]' | 'now available' | 'complete';
4
+ export type RemoteUpRawStatus = '[COMPLETE]' | 'now available' | 'complete' | 'been resolved';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eso-status/forum-message",
3
- "version": "2.0.0-dev.6",
3
+ "version": "2.0.0-dev.8",
4
4
  "description": "Library for retrieving and formatting data, available at https://forums.elderscrollsonline.com or https://forums.elderscrollsonline.com/en/categories/pts",
5
5
  "author": "@dov118 <contact@dov118.dev> (https://dov118.dev)",
6
6
  "main": "lib/index.js",
@@ -19,6 +19,8 @@
19
19
  "lib/type/messageType.type.js",
20
20
  "lib/type/remoteDownRawStatus.type.d.ts",
21
21
  "lib/type/remoteDownRawStatus.type.js",
22
+ "lib/type/remoteIssuesRawStatus.type.d.ts",
23
+ "lib/type/remoteIssuesRawStatus.type.js",
22
24
  "lib/type/remotePlannedRawStatus.type.d.ts",
23
25
  "lib/type/remotePlannedRawStatus.type.js",
24
26
  "lib/type/remoteRawSlug.type.d.ts",
@@ -91,18 +93,18 @@
91
93
  "moment": "2.30.1"
92
94
  },
93
95
  "devDependencies": {
94
- "@types/jest": "29.5.12",
95
- "eslint": "8.57.0",
96
+ "@types/jest": "29.5.13",
97
+ "eslint": "8.57.1",
96
98
  "eslint-config-airbnb-base": "15.0.0",
97
99
  "eslint-config-airbnb-typescript": "18.0.0",
98
100
  "eslint-config-prettier": "9.1.0",
99
101
  "eslint-plugin-jest": "28.8.3",
100
102
  "eslint-plugin-prettier": "5.2.1",
101
- "eslint-plugin-sonarjs": "2.0.2",
102
- "eslint-plugin-unused-imports": "4.1.3",
103
- "husky": "9.1.5",
103
+ "eslint-plugin-sonarjs": "2.0.3",
104
+ "eslint-plugin-unused-imports": "4.1.4",
105
+ "husky": "9.1.6",
104
106
  "jest": "29.7.0",
105
- "nodemon": "3.1.4",
107
+ "nodemon": "3.1.7",
106
108
  "prettier": "3.3.3",
107
109
  "ts-jest": "29.2.5",
108
110
  "typescript": "5.5.4"