@eso-status/forum-message 1.0.13 → 2.0.0-dev.1

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.
Files changed (57) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +101 -94
  3. package/lib/connector.d.ts +68 -0
  4. package/lib/connector.js +122 -0
  5. package/lib/const.d.ts +9 -0
  6. package/lib/const.js +12 -0
  7. package/lib/formatter/date.formatter.d.ts +97 -0
  8. package/lib/formatter/date.formatter.js +161 -0
  9. package/lib/identifier/slug.identifier.d.ts +94 -0
  10. package/lib/identifier/slug.identifier.js +140 -0
  11. package/lib/identifier/slug.match.d.ts +26 -0
  12. package/lib/identifier/slug.match.js +35 -0
  13. package/lib/identifier/status.identifier.d.ts +63 -0
  14. package/lib/identifier/status.identifier.js +86 -0
  15. package/lib/index.d.ts +11 -13
  16. package/lib/index.js +14 -72
  17. package/lib/raw.d.ts +42 -0
  18. package/lib/raw.js +58 -0
  19. package/lib/type/messageType.type.d.ts +4 -0
  20. package/lib/type/messageType.type.js +3 -0
  21. package/lib/type/remoteDownRawStatus.type.d.ts +4 -0
  22. package/lib/type/remoteDownRawStatus.type.js +3 -0
  23. package/lib/type/remotePlannedRawStatus.type.d.ts +4 -0
  24. package/lib/type/remotePlannedRawStatus.type.js +3 -0
  25. package/lib/type/remoteRawSlug.type.d.ts +11 -0
  26. package/lib/type/remoteRawSlug.type.js +3 -0
  27. package/lib/type/remoteRawStatus.type.d.ts +7 -0
  28. package/lib/type/remoteRawStatus.type.js +3 -0
  29. package/lib/type/remoteServerPcEuRawSlug.type.d.ts +4 -0
  30. package/lib/type/remoteServerPcEuRawSlug.type.js +3 -0
  31. package/lib/type/remoteServerPcNaRawSlug.type.d.ts +4 -0
  32. package/lib/type/remoteServerPcNaRawSlug.type.js +3 -0
  33. package/lib/type/remoteServerPcPtsRawSlug.type.d.ts +4 -0
  34. package/lib/type/remoteServerPcPtsRawSlug.type.js +3 -0
  35. package/lib/type/remoteServerPsEuRawSlug.type.d.ts +4 -0
  36. package/lib/type/remoteServerPsEuRawSlug.type.js +3 -0
  37. package/lib/type/remoteServerPsNaRawSlug.type.d.ts +4 -0
  38. package/lib/type/remoteServerPsNaRawSlug.type.js +3 -0
  39. package/lib/type/remoteServerXboxEuRawSlug.type.d.ts +4 -0
  40. package/lib/type/remoteServerXboxEuRawSlug.type.js +3 -0
  41. package/lib/type/remoteServerXboxNaRawSlug.type.d.ts +4 -0
  42. package/lib/type/remoteServerXboxNaRawSlug.type.js +3 -0
  43. package/lib/type/remoteServiceStoreEsoRawSlug.type.d.ts +4 -0
  44. package/lib/type/remoteServiceStoreEsoRawSlug.type.js +3 -0
  45. package/lib/type/remoteServiceSystemAccountRawSlug.type.d.ts +4 -0
  46. package/lib/type/remoteServiceSystemAccountRawSlug.type.js +3 -0
  47. package/lib/type/remoteServiceWebSiteRawSlug.type.d.ts +4 -0
  48. package/lib/type/remoteServiceWebSiteRawSlug.type.js +3 -0
  49. package/lib/type/remoteUpRawStatus.type.d.ts +4 -0
  50. package/lib/type/remoteUpRawStatus.type.js +3 -0
  51. package/lib/type/sourceUrl.type.d.ts +4 -0
  52. package/lib/type/sourceUrl.type.js +3 -0
  53. package/package.json +110 -37
  54. package/lib/classes/ForumMessageElement.d.ts +0 -110
  55. package/lib/classes/ForumMessageElement.js +0 -386
  56. package/lib/connectors/ForumMessageConnector.d.ts +0 -127
  57. package/lib/connectors/ForumMessageConnector.js +0 -311
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 dov118
3
+ Copyright (c) 2024 dov118
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,145 +1,152 @@
1
1
  # eso-status/forum-message
2
+
3
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=eso-status_forum-message&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=eso-status_forum-message)
4
+ [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=eso-status_forum-message&metric=bugs)](https://sonarcloud.io/summary/new_code?id=eso-status_forum-message)
5
+ [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=eso-status_forum-message&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=eso-status_forum-message)
6
+ [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=eso-status_forum-message&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=eso-status_forum-message)
7
+ [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=eso-status_forum-message&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=eso-status_forum-message)
8
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=eso-status_forum-message&metric=coverage)](https://sonarcloud.io/summary/new_code?id=eso-status_forum-message)
9
+ [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=eso-status_forum-message&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=eso-status_forum-message)
10
+
2
11
  [![npm](https://img.shields.io/npm/v/@eso-status/forum-message)](https://www.npmjs.com/package/@eso-status/forum-message)
3
12
  [![license](https://img.shields.io/npm/l/@eso-status/forum-message)](https://github.com/eso-status/forum-message/blob/master/LICENSE.md)
4
13
  <img src="https://img.shields.io/npm/dt/@eso-status/forum-message" alt="Downloads" />
5
- [![LGTM Grade](https://img.shields.io/lgtm/grade/javascript/github/eso-status/forum-message)](https://lgtm.com/projects/g/eso-status/forum-message/context:javascript)
6
14
  <img src="https://img.shields.io/node/v/@eso-status/forum-message" alt="Node version" />
15
+
7
16
  [![Build Status](https://github.com/eso-status/forum-message/workflows/CI/badge.svg)](https://github.com/eso-status/forum-message/actions/workflows/CI.yaml)
8
- [![Delivery Status](https://github.com/eso-status/forum-message/workflows/CD/badge.svg)](https://github.com/eso-status/forum-message/actions/workflows/CD.yaml)
17
+ [![Build Status](https://github.com/eso-status/forum-message/workflows/CD/badge.svg)](https://github.com/eso-status/forum-message/actions/workflows/CD.yaml)
9
18
 
10
- eso-status/forum-message is a library for getting and formatting data can founded in [https://forums.elderscrollsonline.com/](https://forums.elderscrollsonline.com/) and [https://forums.elderscrollsonline.com/en/categories/pts](https://forums.elderscrollsonline.com/en/categories/pts)
19
+ eso-status/forum-message is a library for retrieving and formatting data, which can be found at [https://forums.elderscrollsonline.com](https://forums.elderscrollsonline.com) or [https://forums.elderscrollsonline.com/en/categories/pts](https://forums.elderscrollsonline.com/en/categories/pts).
11
20
 
12
21
  ## 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-)
22
+ - [Install](#install)
23
+ - [Usage](#usage)
24
+ - [Return exemple](#return-exemple)
16
25
 
17
- ### How to get it ?
26
+ ### Install
18
27
  ```shell
19
28
  npm i @eso-status/forum-message
20
29
  ```
21
30
 
22
- ### How to use it ?
23
- - TypeScript
24
- ```typescript
25
- import { RawEsoStatus } from '@eso-status/types';
26
- import { ForumMessage } from "@eso-status/forum-message";
27
-
28
- ForumMessage.getData().then((data: RawEsoStatus[]): void => {
29
-
30
- }).catch((error: Error): void => {
31
-
32
- });
33
- ```
34
- - JavaScript
31
+ ### Usage
35
32
  ```javascript
36
- const { ForumMessage } = require('@eso-status/forum-message');
33
+ import ForumMessage from '@eso-status/forum-message';
34
+ import { EsoStatusRawData } from '@eso-status/types';
35
+ import { ForumMessagePTSURL } from '@eso-status/forum-message/const';
37
36
 
38
- ForumMessage.getData().then(function (data) {
39
-
40
- }).catch(function (error) {
41
-
42
- });
43
- ```
37
+ // Homepage data
38
+ const esoStatusRawDataList: EsoStatusRawData[] = await ForumMessage.getData();
44
39
 
45
- ### Returned data format ?
40
+ // PTS category homepage data
41
+ const esoStatusRawDataList: EsoStatusRawData[] = await ForumMessage.getData(ForumMessagePTSURL);
42
+ ```
43
+ ### Return exemple
46
44
  ```text
47
45
  [
48
46
  {
49
- sources: [
50
- 'https://forums.elderscrollsonline.com/en/categories/pts',
51
- 'https://forums.elderscrollsonline.com/'
52
- ],
53
- raw: '• PC/Mac: NA and EU megaservers for patch maintenance – July 26, 4:00AM EDT (8:00 UTC) – 8:00AM EDT (12:00 UTC)',
54
- slugs: [ 'server_pc_na' ],
55
- rawDate: 'July 26, 4:00AM EDT (8:00 UTC) – 8:00AM EDT (12:00 UTC)',
56
- date: [ Moment<2021-07-26T06:00:00Z>, Moment<2021-07-26T10:00:00Z> ],
47
+ source: 'https://forums.elderscrollsonline.com',
48
+ raw: '• PC/Mac: NA and EU megaservers for patch maintenance – September 3, 4:00AM EDT (8:00 UTC) – 9:00AM EDT (13:00 UTC)',
49
+ slug: 'server_pc_eu',
57
50
  type: 'server',
58
51
  support: 'pc',
59
- zone: 'na',
60
- status: 'planned'
52
+ zone: 'eu',
53
+ status: 'planned',
54
+ rawSlug: 'PC/Mac: NA and EU megaservers for'
61
55
  },
62
56
  {
63
- sources: [
64
- 'https://forums.elderscrollsonline.com/en/categories/pts',
65
- 'https://forums.elderscrollsonline.com/'
66
- ],
67
- raw: '• PC/Mac: NA and EU megaservers for patch maintenance – July 26, 4:00AM EDT (8:00 UTC) – 8:00AM EDT (12:00 UTC)',
68
- slugs: [ 'server_pc_eu' ],
69
- rawDate: 'July 26, 4:00AM EDT (8:00 UTC) – 8:00AM EDT (12:00 UTC)',
70
- date: [ Moment<2021-07-26T06:00:00Z>, Moment<2021-07-26T10:00:00Z> ],
57
+ source: 'https://forums.elderscrollsonline.com',
58
+ raw: '• PC/Mac: NA and EU megaservers for patch maintenance – September 3, 4:00AM EDT (8:00 UTC) – 9:00AM EDT (13:00 UTC)',
59
+ slug: 'server_pc_na',
71
60
  type: 'server',
72
61
  support: 'pc',
62
+ zone: 'na',
63
+ status: 'planned',
64
+ rawSlug: 'PC/Mac: NA and EU megaservers for'
65
+ },
66
+ {
67
+ source: 'https://forums.elderscrollsonline.com',
68
+ raw: '• Xbox: NA and EU megaservers for patch maintenance – September 4, 6:00AM EDT (10:00 UTC) - 12:00PM EDT (16:00 UTC)',
69
+ slug: 'server_xbox_eu',
70
+ type: 'server',
71
+ support: 'xbox',
73
72
  zone: 'eu',
74
- status: 'planned'
73
+ status: 'planned',
74
+ rawSlug: 'Xbox: NA and EU megaservers for',
75
+ rawDate: 'September 4, 6:00AM EDT (10:00 UTC) - 12:00PM EDT (16:00 UTC)',
76
+ dates: [ Moment<2024-09-04T10:00:00Z>, Moment<2024-09-04T16:00:00Z> ]
75
77
  },
76
78
  {
77
- sources: [
78
- 'https://forums.elderscrollsonline.com/en/categories/pts',
79
- 'https://forums.elderscrollsonline.com/'
80
- ],
81
- raw: '• Xbox: NA and EU megaservers for patch maintenance – July 28, 6:00AM EDT (10:00 UTC) – 10:00AM EDT (14:00 UTC)',
82
- slugs: [ 'server_xbox_na' ],
83
- rawDate: 'July 28, 6:00AM EDT (10:00 UTC) – 10:00AM EDT (14:00 UTC)',
84
- date: [ Moment<2021-07-28T08:00:00Z>, Moment<2021-07-28T12:00:00Z> ],
79
+ source: 'https://forums.elderscrollsonline.com',
80
+ raw: '• Xbox: NA and EU megaservers for patch maintenance – September 4, 6:00AM EDT (10:00 UTC) - 12:00PM EDT (16:00 UTC)',
81
+ slug: 'server_xbox_na',
85
82
  type: 'server',
86
83
  support: 'xbox',
87
84
  zone: 'na',
88
- status: 'planned'
85
+ status: 'planned',
86
+ rawSlug: 'Xbox: NA and EU megaservers for',
87
+ rawDate: 'September 4, 6:00AM EDT (10:00 UTC) - 12:00PM EDT (16:00 UTC)',
88
+ dates: [ Moment<2024-09-04T10:00:00Z>, Moment<2024-09-04T16:00:00Z> ]
89
89
  },
90
90
  {
91
- sources: [
92
- 'https://forums.elderscrollsonline.com/en/categories/pts',
93
- 'https://forums.elderscrollsonline.com/'
94
- ],
95
- raw: '• Xbox: NA and EU megaservers for patch maintenance – July 28, 6:00AM EDT (10:00 UTC) – 10:00AM EDT (14:00 UTC)',
96
- slugs: [ 'server_xbox_eu' ],
97
- rawDate: 'July 28, 6:00AM EDT (10:00 UTC) – 10:00AM EDT (14:00 UTC)',
98
- date: [ Moment<2021-07-28T08:00:00Z>, Moment<2021-07-28T12:00:00Z> ],
91
+ source: 'https://forums.elderscrollsonline.com',
92
+ raw: '• PlayStation®: NA and EU megaservers for patch maintenance – September 4, 6:00AM EDT (10:00 UTC) - 12:00PM EDT (16:00 UTC)',
93
+ slug: 'server_ps_eu',
99
94
  type: 'server',
100
- support: 'xbox',
95
+ support: 'ps',
101
96
  zone: 'eu',
102
- status: 'planned'
97
+ status: 'planned',
98
+ rawSlug: 'PlayStation®: NA and EU megaservers for',
99
+ rawDate: 'September 4, 6:00AM EDT (10:00 UTC) - 12:00PM EDT (16:00 UTC)',
100
+ dates: [ Moment<2024-09-04T10:00:00Z>, Moment<2024-09-04T16:00:00Z> ]
103
101
  },
104
102
  {
105
- sources: [
106
- 'https://forums.elderscrollsonline.com/en/categories/pts',
107
- 'https://forums.elderscrollsonline.com/'
108
- ],
109
- raw: '• PlayStation®: NA and EU megaservers for patch maintenance – July 28, 6:00AM EDT (10:00 UTC) – 10:00AM EDT (14:00 UTC)',
110
- slugs: [ 'server_ps_na' ],
111
- rawDate: 'July 28, 6:00AM EDT (10:00 UTC) – 10:00AM EDT (14:00 UTC)',
112
- date: [ Moment<2021-07-28T08:00:00Z>, Moment<2021-07-28T12:00:00Z> ],
103
+ source: 'https://forums.elderscrollsonline.com',
104
+ raw: '• PlayStation®: NA and EU megaservers for patch maintenance – September 4, 6:00AM EDT (10:00 UTC) - 12:00PM EDT (16:00 UTC)',
105
+ slug: 'server_ps_na',
113
106
  type: 'server',
114
107
  support: 'ps',
115
108
  zone: 'na',
116
- status: 'planned'
109
+ status: 'planned',
110
+ rawSlug: 'PlayStation®: NA and EU megaservers for',
111
+ rawDate: 'September 4, 6:00AM EDT (10:00 UTC) - 12:00PM EDT (16:00 UTC)',
112
+ dates: [ Moment<2024-09-04T10:00:00Z>, Moment<2024-09-04T16:00:00Z> ]
117
113
  },
118
114
  {
119
- sources: [
120
- 'https://forums.elderscrollsonline.com/en/categories/pts',
121
- 'https://forums.elderscrollsonline.com/'
122
- ],
123
- raw: '• PlayStation®: NA and EU megaservers for patch maintenance – July 28, 6:00AM EDT (10:00 UTC) – 10:00AM EDT (14:00 UTC)',
124
- slugs: [ 'server_ps_eu' ],
125
- rawDate: 'July 28, 6:00AM EDT (10:00 UTC) – 10:00AM EDT (14:00 UTC)',
126
- date: [ Moment<2021-07-28T08:00:00Z>, Moment<2021-07-28T12:00:00Z> ],
127
- type: 'server',
128
- support: 'ps',
129
- zone: 'eu',
130
- status: 'planned'
115
+ source: 'https://forums.elderscrollsonline.com',
116
+ raw: '• ESO Store and Account System for maintenance – September 4, 10:00AM EDT (14:00 UTC) - 12:00PM EDT (16:00 UTC)',
117
+ slug: 'service_store_eso',
118
+ type: 'service',
119
+ support: 'store',
120
+ zone: 'eso',
121
+ status: 'planned',
122
+ rawSlug: 'ESO Store and Account System for',
123
+ rawDate: 'September 4, 10:00AM EDT (14:00 UTC) - 12:00PM EDT (16:00 UTC)',
124
+ dates: [ Moment<2024-09-04T14:00:00Z>, Moment<2024-09-04T16:00:00Z> ]
131
125
  },
132
126
  {
133
- sources: [ 'https://forums.elderscrollsonline.com/en/categories/pts' ],
134
- raw: 'We will be performing maintenance for patch 7.1.2 on the PTS on Monday at 2:00AM EDT (06:00 UTC). ',
135
- slugs: [ 'server_pc_pts' ],
136
- rawDate: 'Monday at 2:00AM EDT (06:00 UTC). ',
137
- date: [ Moment<2021-07-24T04:00:00Z> ],
127
+ source: 'https://forums.elderscrollsonline.com',
128
+ raw: ' ESO Store and Account System for maintenance September 4, 10:00AM EDT (14:00 UTC) - 12:00PM EDT (16:00 UTC)',
129
+ slug: 'service_system_account',
130
+ type: 'service',
131
+ support: 'system',
132
+ zone: 'account',
133
+ status: 'planned',
134
+ rawSlug: 'ESO Store and Account System for',
135
+ rawDate: 'September 4, 10:00AM EDT (14:00 UTC) - 12:00PM EDT (16:00 UTC)',
136
+ dates: [ Moment<2024-09-04T14:00:00Z>, Moment<2024-09-04T16:00:00Z> ]
137
+ },
138
+ {
139
+ source: 'https://forums.elderscrollsonline.com/en/categories/pts',
140
+ raw: 'We will be performing maintenance on the PTS on Thursday at 9:00AM EDT (13:00 UTC).',
141
+ slug: 'server_pc_pts',
138
142
  type: 'server',
139
143
  support: 'pc',
140
144
  zone: 'pts',
141
- status: 'planned'
145
+ status: 'planned',
146
+ rawSlug: 'PTS',
147
+ rawDate: 'Thursday at 9:00AM EDT (13:00 UTC). ',
148
+ dates: [ Moment<2024-09-05T13:00:00Z> ],
149
+ rawStatus: 'We will be performing maintenance'
142
150
  }
143
151
  ]
144
152
  ```
145
-
@@ -0,0 +1,68 @@
1
+ import { SourceUrl } from './type/sourceUrl.type';
2
+ import { EsoStatusRawData } from './interface/esoStatusRawData.interface';
3
+ /**
4
+ * Class for retrieving information from announcements
5
+ */
6
+ export default class Connector {
7
+ private readonly url;
8
+ private readonly remoteContent;
9
+ /**
10
+ * List of raw data from announcements
11
+ */
12
+ raw: string[];
13
+ /**
14
+ * List of information from announcements
15
+ */
16
+ rawEsoStatus: EsoStatusRawData[];
17
+ /**
18
+ * @param url URL used as the source to retrieve announcements
19
+ * @param remoteContent Content of the source retrieved via URL
20
+ */
21
+ constructor(url: SourceUrl, remoteContent: string);
22
+ /**
23
+ * Method for creating an instance of the connector via a URL
24
+ * @param url URL used as the source to retrieve announcements
25
+ */
26
+ static init(url: SourceUrl): Promise<Connector>;
27
+ /**
28
+ * Method for retrieving remote content via a URL
29
+ * @param url URL serving as the source for retrieving announcements
30
+ * @private
31
+ */
32
+ private static getRemoteContent;
33
+ /**
34
+ * Method for retrieving raw announcements for all announcement levels
35
+ * @private
36
+ */
37
+ private getMessages;
38
+ /**
39
+ * Method for retrieving raw announcements based on the announcement level
40
+ * @private
41
+ */
42
+ private getMessagesByType;
43
+ /**
44
+ * Method for formatting the raw data of retrieved announcements
45
+ * @private
46
+ */
47
+ private replace;
48
+ /**
49
+ * Method for separating each announcement message
50
+ */
51
+ private split;
52
+ /**
53
+ * Method for removing unnecessary announcements
54
+ * @private
55
+ */
56
+ private filter;
57
+ /**
58
+ * Method for analyzing each announcement
59
+ * @private
60
+ */
61
+ private fetch;
62
+ /**
63
+ * Method for retrieving the information contained in an announcement
64
+ * @param raw Raw data of the announcement
65
+ * @private
66
+ */
67
+ private fetchEach;
68
+ }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const axios_1 = require("axios");
4
+ const raw_1 = require("./raw");
5
+ /**
6
+ * Class for retrieving information from announcements
7
+ */
8
+ class Connector {
9
+ /**
10
+ * @param url URL used as the source to retrieve announcements
11
+ * @param remoteContent Content of the source retrieved via URL
12
+ */
13
+ constructor(url, remoteContent) {
14
+ this.url = url;
15
+ this.remoteContent = remoteContent;
16
+ /**
17
+ * List of raw data from announcements
18
+ */
19
+ this.raw = [];
20
+ /**
21
+ * List of information from announcements
22
+ */
23
+ this.rawEsoStatus = [];
24
+ this.getMessages();
25
+ this.replace();
26
+ this.split();
27
+ this.filter();
28
+ this.fetch();
29
+ }
30
+ /**
31
+ * Method for creating an instance of the connector via a URL
32
+ * @param url URL used as the source to retrieve announcements
33
+ */
34
+ static async init(url) {
35
+ return new Connector(url, await Connector.getRemoteContent(url));
36
+ }
37
+ /**
38
+ * Method for retrieving remote content via a URL
39
+ * @param url URL serving as the source for retrieving announcements
40
+ * @private
41
+ */
42
+ static async getRemoteContent(url) {
43
+ const response = await axios_1.default.get(url);
44
+ return response?.status === 200 && !!response?.data
45
+ ? String(response?.data)
46
+ : '';
47
+ }
48
+ /**
49
+ * Method for retrieving raw announcements for all announcement levels
50
+ * @private
51
+ */
52
+ getMessages() {
53
+ ['WarningMessage', 'AlertMessage'].forEach((type) => this.getMessagesByType(type));
54
+ }
55
+ /**
56
+ * Method for retrieving raw announcements based on the announcement level
57
+ * @private
58
+ */
59
+ getMessagesByType(type) {
60
+ const split = this.remoteContent.split(`<div class="DismissMessage ${type}">`);
61
+ split.shift();
62
+ split.forEach((item) => {
63
+ const result = item.split('</div>');
64
+ if (result.length >= 2) {
65
+ this.raw.push(result[0]);
66
+ }
67
+ });
68
+ }
69
+ /**
70
+ * Method for formatting the raw data of retrieved announcements
71
+ * @private
72
+ */
73
+ replace() {
74
+ this.raw = this.raw.map((raw) => {
75
+ let initialRaw = raw;
76
+ initialRaw = initialRaw.replace(/<br\/>\n/g, '<br>');
77
+ return initialRaw.replace('. ', '.');
78
+ });
79
+ }
80
+ /**
81
+ * Method for separating each announcement message
82
+ */
83
+ split() {
84
+ const rawList = this.raw;
85
+ this.raw = [];
86
+ rawList.forEach((raw) => {
87
+ raw.split('<br>').forEach((split) => {
88
+ this.raw.push(split);
89
+ });
90
+ });
91
+ }
92
+ /**
93
+ * Method for removing unnecessary announcements
94
+ * @private
95
+ */
96
+ filter() {
97
+ this.raw = this.raw.filter((raw) => {
98
+ return (!raw.includes('Maintenance for the week of ') &&
99
+ !raw.includes('• PC/Mac: No maintenance – ') &&
100
+ raw !== '');
101
+ });
102
+ }
103
+ /**
104
+ * Method for analyzing each announcement
105
+ * @private
106
+ */
107
+ fetch() {
108
+ this.raw.forEach((raw) => this.fetchEach(raw));
109
+ }
110
+ /**
111
+ * Method for retrieving the information contained in an announcement
112
+ * @param raw Raw data of the announcement
113
+ * @private
114
+ */
115
+ fetchEach(raw) {
116
+ new raw_1.default(this.url, raw).matches.forEach((match) => {
117
+ this.rawEsoStatus.push(match);
118
+ });
119
+ }
120
+ }
121
+ exports.default = Connector;
122
+ //# sourceMappingURL=connector.js.map
package/lib/const.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { SourceUrl } from './type/sourceUrl.type';
2
+ /**
3
+ * Homepage URL
4
+ */
5
+ export declare const ForumMessageURL: SourceUrl;
6
+ /**
7
+ * PTS category homepage URL
8
+ */
9
+ export declare const ForumMessagePTSURL: SourceUrl;
package/lib/const.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ForumMessagePTSURL = exports.ForumMessageURL = void 0;
4
+ /**
5
+ * Homepage URL
6
+ */
7
+ exports.ForumMessageURL = 'https://forums.elderscrollsonline.com';
8
+ /**
9
+ * PTS category homepage URL
10
+ */
11
+ exports.ForumMessagePTSURL = 'https://forums.elderscrollsonline.com/en/categories/pts';
12
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1,97 @@
1
+ import { Moment } from 'moment';
2
+ /**
3
+ * Class for identifying and formatting the date contained in an announcement
4
+ */
5
+ export default class DateFormatter {
6
+ private readonly raw;
7
+ /**
8
+ * Raw date data contained in the announcement
9
+ */
10
+ rawDate: string;
11
+ /**
12
+ * List of dates formatted correctly contained in the announcement
13
+ */
14
+ dates: Moment[];
15
+ /**
16
+ * @param raw Raw data of the announcement
17
+ */
18
+ constructor(raw: string);
19
+ /**
20
+ * Method for retrieving the raw date and the list of dates present in the announcement based on its format
21
+ * Case #1: The announcement contains a date with a start and end time (hour/minute)
22
+ * Case #2: The announcement contains the name of the next maintenance day with a start time (hour/minute)
23
+ * @private
24
+ */
25
+ private checkFormat;
26
+ /**
27
+ * Method for retrieving the raw date in case #1
28
+ * @private
29
+ */
30
+ private getRawClassicDate;
31
+ /**
32
+ * Method for retrieving the raw date in case #2
33
+ * @private
34
+ */
35
+ private getRawSpecialDate;
36
+ /**
37
+ * Method for generating the list of correctly formatted dates for case #1
38
+ * @private
39
+ */
40
+ private formatClassic;
41
+ /**
42
+ * Method for retrieving the month number for case #1
43
+ * @private
44
+ */
45
+ private getRawClassicMouth;
46
+ /**
47
+ * Method for retrieving the day number for case #1
48
+ * @private
49
+ */
50
+ private getRawClassicDay;
51
+ /**
52
+ * Method for retrieving the hour number from a raw date
53
+ * @private
54
+ */
55
+ private getRawHour;
56
+ /**
57
+ * Method for retrieving the minute number of the start time for case #1
58
+ * @private
59
+ */
60
+ private getRawClassicMinute1;
61
+ /**
62
+ * Method for retrieving the end hour number in case #1
63
+ * @private
64
+ */
65
+ private getRawClassicHour2;
66
+ /**
67
+ * Method for retrieving the minute number of the end time in case #1
68
+ * @private
69
+ */
70
+ private getRawClassicMinute2;
71
+ /**
72
+ * Method for generating the correctly formatted date in case #2
73
+ * @private
74
+ */
75
+ private formatSpecial;
76
+ /**
77
+ * Method for retrieving the maintenance date in case #2
78
+ * Case #2 does not provide the month or day (i.e., no day number), only the name of the day (Monday, Tuesday, etc.). Therefore, you need to check if the day has already passed in the current week to determine whether to add a week to the maintenance date.
79
+ * @private
80
+ */
81
+ private getSpecialDate;
82
+ /**
83
+ * Method for retrieving the minute number of the time in case #2
84
+ * @private
85
+ */
86
+ private getRawSpecialMinute;
87
+ /**
88
+ * Method for formatting a date correctly
89
+ * @param year
90
+ * @param month
91
+ * @param day
92
+ * @param hour
93
+ * @param minute
94
+ * @private
95
+ */
96
+ private static generateMoment;
97
+ }