@eventconnectors/ndtrc_model 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/index.js ADDED
@@ -0,0 +1,30 @@
1
+ // src/index.js
2
+
3
+ // Exporteer alles in één keer vanuit de respectieve bestanden
4
+
5
+ module.exports = {
6
+ // Exporteer alle klassen uit de modelbestanden
7
+ ConvertedEntry: require("./src/model/ConvertedEntry"),
8
+ FetchedEntry: require("./src/model/FetchedEntry"),
9
+ ExternalLocationInfo: require("./src/model/FetchedEntry").ExternalLocationInfo,
10
+ Location: require("./src/model/ndtrc/Location"),
11
+ PriceElement: require("./src/model/ndtrc/PriceElement"),
12
+ TRCItem: require("./src/model/ndtrc/TRCItem"),
13
+ TRCItemCategories: require("./src/model/ndtrc/TRCItemCategories"),
14
+ File: require("./src/model/ndtrc/File"),
15
+ GISCoordinate: require("./src/model/ndtrc/GISCoordinate"),
16
+ Calendar: require("./src/model/ndtrc/Calendar"),
17
+ Contactinfo: require("./src/model/ndtrc/ContactInfo"),
18
+ TRCItemDetail: require("./src/model/ndtrc/TRCItemDetail"),
19
+
20
+ Address: require("./src/model/ndtrc/Address"),
21
+ ExtraPriceInformation: require("./src/model/ndtrc/ExtraPriceInformation"),
22
+ Performer: require("./src/model/ndtrc/Performer"),
23
+ Promotion: require("./src/model/ndtrc/Promotion"),
24
+ RouteInfo: require("./src/model/ndtrc/RouteInfo"),
25
+ SubItemGroup: require("./src/model/ndtrc/SubItemGroup"),
26
+ Translations: require("./src/model/ndtrc/Translations"),
27
+ TRCItemGroup: require("./src/model/ndtrc/TRCItemGroup"),
28
+ TRCItemRelation: require("./src/model/ndtrc/TRCItemRelation"),
29
+ Categories: require("./src/model/ndtrc/Categories"),
30
+ };
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@eventconnectors/ndtrc_model",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "jest"
7
+ },
8
+ "dependencies": {
9
+ "dayjs": "^1.11.13",
10
+ "moment": "^2.30.1",
11
+ "xmlbuilder": "^15.1.1"
12
+ },
13
+ "devDependencies": {
14
+ "jest": "^29.0.0"
15
+ },
16
+ "private": false,
17
+ "author": "wwwappz",
18
+ "license": "MIT"
19
+ }
@@ -0,0 +1,22 @@
1
+ const TRCItem = require('./ndtrc/TRCItem'); // Zorg ervoor dat je het juiste pad gebruikt naar de TRCItem-module
2
+
3
+ class ConvertedEntry {
4
+ constructor({
5
+ label = '',
6
+ created = null, // Verwacht een Date-object
7
+ modified = null, // Verwacht een Date-object
8
+ errorMessage = '',
9
+ externalId = '',
10
+ trcItem = null, // Verwacht een instantie van TRCItem
11
+ } = {}) {
12
+ this.label = label;
13
+ this.created = created;
14
+ this.modified = modified;
15
+ this.errorMessage = errorMessage;
16
+
17
+ this.externalId = externalId;
18
+ this.trcItem = trcItem instanceof TRCItem ? trcItem : null; // Validatie dat het een TRCItem is
19
+ }
20
+ }
21
+
22
+ module.exports = ConvertedEntry;
@@ -0,0 +1,55 @@
1
+
2
+ class FetchedEntry {
3
+ constructor({
4
+ feed = '',
5
+ sourceId = '',
6
+ sourceUrl = '',
7
+ errorMessage = '',
8
+ label = '',
9
+ created = null, // Verwacht een Date-object
10
+ modified = null, // Verwacht een Date-object
11
+ externalId = '',
12
+ data = {}, // Verwacht een object met willekeurige sleutel-waarde paren
13
+ externalLocationInfo = null, // Verwacht een instantie van ExternalLocationInfo
14
+ } = {}) {
15
+ this.feed = feed;
16
+ this.sourceId = sourceId;
17
+ this.sourceUrl = sourceUrl;
18
+ this.errorMessage = errorMessage;
19
+
20
+ this.label = label;
21
+ this.created = created;
22
+ this.modified = modified;
23
+
24
+ this.externalId = externalId;
25
+ this.data = data;
26
+ this.externalLocationInfo = externalLocationInfo;
27
+ }
28
+ }
29
+
30
+ class ExternalLocationInfo {
31
+ constructor({
32
+ externalId = '',
33
+ locationName = '',
34
+ address = '',
35
+ housenr = '',
36
+ zipcode = '',
37
+ city = '',
38
+ latitude = '',
39
+ longitude = '',
40
+ trcid = '',
41
+ ffId = '',
42
+ } = {}) {
43
+ this.externalId = externalId;
44
+ this.locationName = locationName;
45
+ this.address = address;
46
+ this.housenr = housenr;
47
+ this.zipcode = zipcode;
48
+ this.city = city;
49
+ this.latitude = latitude;
50
+ this.longitude = longitude;
51
+ this.trcid = trcid;
52
+ this.ffId = ffId;
53
+ }
54
+ }
55
+ module.exports = { FetchedEntry, ExternalLocationInfo };
@@ -0,0 +1,70 @@
1
+ const StringUtils = require('../../util/StringUtils'); // Import StringUtils voor validaties
2
+
3
+ class Address {
4
+ constructor({
5
+ main = false,
6
+ reservation = false,
7
+ title = '',
8
+ city = '',
9
+ citytrcid = '',
10
+ country = 'NL',
11
+ housenr = '',
12
+ street = '',
13
+ streettrcid = '',
14
+ zipcode = '',
15
+ province = '',
16
+ neighbourhood = '',
17
+ district = '',
18
+ gisCoordinates = []
19
+ } = {}) {
20
+ Object.assign(this, {
21
+ main,
22
+ reservation,
23
+ title,
24
+ city,
25
+ citytrcid,
26
+ country,
27
+ housenr,
28
+ street,
29
+ streettrcid,
30
+ zipcode,
31
+ province,
32
+ neighbourhood,
33
+ district,
34
+ gisCoordinates
35
+ });
36
+ }
37
+
38
+ /**
39
+ * Controleert of het adres leeg is.
40
+ * @returns {boolean}
41
+ */
42
+ isEmpty() {
43
+ return [
44
+ this.title,
45
+ this.city,
46
+ this.housenr,
47
+ this.street,
48
+ this.zipcode,
49
+ this.province
50
+ ].every(StringUtils.isEmpty) &&
51
+ (!this.gisCoordinates.length || this.gisCoordinates.every(coord => coord.isEmpty?.()));
52
+ }
53
+
54
+ /**
55
+ * Normaliseert adresvelden (zipcode en city).
56
+ */
57
+ normaliseAdresItems() {
58
+ if (this.zipcode?.match(/(\d{4})\s*(\w{2})/)) {
59
+ this.zipcode = this.zipcode.toUpperCase().replace(/(\d{4})\s*(\w{2})/, '$1 $2');
60
+ }
61
+
62
+ if (this.city?.match(/^[a-z\s]+$/i)) {
63
+ this.city = this.city
64
+ .toLowerCase()
65
+ .replace(/\b\w/g, char => char.toUpperCase()); // Hoofdletter per woord
66
+ }
67
+ }
68
+ }
69
+
70
+ module.exports = Address;
@@ -0,0 +1,240 @@
1
+ // Calendar.js
2
+
3
+ const moment = require('moment');
4
+
5
+ class Calendar {
6
+ constructor() {
7
+ this.singleDates = [];
8
+ this.patternDates = [];
9
+
10
+ this.opens = [];
11
+ this.closeds = [];
12
+ this.soldouts = [];
13
+ this.cancelleds = [];
14
+
15
+ this.excludeholidays = false;
16
+ this.cancelled = false;
17
+ this.soldout = false;
18
+
19
+ }
20
+
21
+ static CalendarType = {
22
+ NONE: 'NONE',
23
+ ALWAYSOPEN: 'ALWAYSOPEN',
24
+ ONREQUEST: 'ONREQUEST',
25
+ OPENINGTIMES: 'OPENINGTIMES',
26
+ PATTERNDATES: 'PATTERNDATES',
27
+ SINGLEDATES: 'SINGLEDATES'
28
+ };
29
+
30
+ cleanupData() {
31
+ this.singleDates.forEach(singleDate => {
32
+ if (singleDate.when) {
33
+ singleDate.when = singleDate.when.filter(when => when.isValid());
34
+ }
35
+ });
36
+
37
+ this.patternDates.forEach(patternDate => {
38
+ patternDate.opens.forEach(open => {
39
+ open.whens = open.whens.filter(when => when.isValid());
40
+ });
41
+
42
+ if (patternDate.opens.length && !patternDate.recurrencyType) {
43
+ patternDate.recurrencyType = PatternDate.RecurrencyType.WEEKLY;
44
+ }
45
+ });
46
+
47
+ ['opens', 'closeds', 'cancelleds', 'soldouts'].forEach(prop => {
48
+ this[prop].forEach(exceptionDate => {
49
+ exceptionDate.whens = exceptionDate.whens.filter(when => when.isValid());
50
+ });
51
+ });
52
+ }
53
+
54
+ determineCalendarType() {
55
+ if (this.calendarType !== null) return;
56
+
57
+ if (this.alwaysopen) {
58
+ this.calendarType = Calendar.CalendarType.ALWAYSOPEN;
59
+ } else if (this.onrequest) {
60
+ this.calendarType = Calendar.CalendarType.ONREQUEST;
61
+ } else if (this.singleDates.length > 0) {
62
+ this.calendarType = Calendar.CalendarType.SINGLEDATES;
63
+ } else if (this.patternDates.length > 0) {
64
+ const firstPattern = this.patternDates[0];
65
+ if (!firstPattern.enddate && !firstPattern.startdate) {
66
+ this.calendarType = Calendar.CalendarType.OPENINGTIMES;
67
+ } else {
68
+ this.calendarType = Calendar.CalendarType.PATTERNDATES;
69
+ }
70
+ } else {
71
+ this.calendarType = Calendar.CalendarType.NONE;
72
+ }
73
+ }
74
+ }
75
+
76
+ class SingleDate {
77
+ constructor(date = null, when = []) {
78
+ this.date = date ? moment(date) : null;
79
+ this.when = when;
80
+ }
81
+
82
+ equals(other) {
83
+ if (this === other) return true;
84
+ if (!(other instanceof SingleDate)) return false;
85
+
86
+ if (!this.date.isSame(other.date)) return false;
87
+ if (this.when.length !== other.when.length) return false;
88
+
89
+ return this.when.every((when, index) => when.equals(other.when[index]));
90
+ }
91
+ }
92
+
93
+ class PatternDate {
94
+ constructor() {
95
+ this.startdate = null;
96
+ this.enddate = null;
97
+ this.recurrencyType = null;
98
+
99
+ this.occurrence = null;
100
+ this.recurrence = null;
101
+ this.opens = [];
102
+ }
103
+
104
+ static RecurrencyType = {
105
+ DAILY: 'daily',
106
+ WEEKLY: 'weekly',
107
+ MONTHLY_SIMPLE: 'monthlySimple',
108
+ MONTHLY_COMPLEX: 'monthlyComplex',
109
+ YEARLY: 'yearly'
110
+ };
111
+
112
+ equals(other) {
113
+ if (this === other) return true;
114
+ if (!(other instanceof PatternDate)) return false;
115
+
116
+ const datesEqual = (!this.startdate && !other.startdate) || this.startdate.isSame(other.startdate);
117
+ const endDatesEqual = (!this.enddate && !other.enddate) || this.enddate.isSame(other.enddate);
118
+
119
+ return datesEqual &&
120
+ endDatesEqual &&
121
+ this.recurrencyType === other.recurrencyType &&
122
+ this.occurrence === other.occurrence &&
123
+ this.recurrence === other.recurrence &&
124
+ this.opensEquals(other.opens);
125
+ }
126
+
127
+ opensEquals(otherOpens) {
128
+ if (this.opens.length !== otherOpens.length) return false;
129
+ return this.opens.every((open, index) => open.equals(otherOpens[index]));
130
+ }
131
+ }
132
+
133
+ class Open {
134
+ constructor() {
135
+ this.month = null;
136
+ this.weeknumber = null;
137
+ this.daynumber = null;
138
+ this.day = null;
139
+ this.whens = [];
140
+ }
141
+
142
+ equals(other) {
143
+ if (this === other) return true;
144
+ if (!(other instanceof Open)) return false;
145
+
146
+ return this.month === other.month &&
147
+ this.weeknumber === other.weeknumber &&
148
+ this.daynumber === other.daynumber &&
149
+ this.day === other.day &&
150
+ this.whensEquals(other.whens);
151
+ }
152
+
153
+ whensEquals(otherWhens) {
154
+ if (this.whens.length !== otherWhens.length) return false;
155
+ return this.whens.every((when, index) => when.equals(otherWhens[index]));
156
+ }
157
+ }
158
+
159
+ class When {
160
+ constructor(timestart = null, status = null) {
161
+ this.timestart = timestart;
162
+
163
+ this.status = status;
164
+ this.statustranslations = [];
165
+ this.extrainformations = [];
166
+ }
167
+
168
+ equals(other) {
169
+ if (this === other) return true;
170
+ if (!(other instanceof When)) return false;
171
+
172
+ return this.timestart === other.timestart && this.timeend === other.timeend;
173
+ }
174
+
175
+ isValid() {
176
+ return this.isTimeValid(this.timestart) || this.isTimeValid(this.timeend);
177
+ }
178
+
179
+ isTimeValid(time) {
180
+ return time && time.trim().length > 0;
181
+ }
182
+
183
+ static Status = {
184
+ NORMAL: 'normal',
185
+ CANCELLED: 'cancelled',
186
+ SOLDOUT: 'soldout',
187
+ MOVEDTO: 'movedto',
188
+ PREMIERE: 'premiere',
189
+ REPRISE: 'reprise'
190
+ };
191
+ }
192
+
193
+ class StatusTranslation {
194
+ constructor(lang = null, text = null) {
195
+ this.lang = lang;
196
+ this.text = text;
197
+ }
198
+ }
199
+
200
+ class ExtraInformation {
201
+ constructor(lang = null, text = null) {
202
+ this.lang = lang;
203
+ this.text = text;
204
+ }
205
+ }
206
+
207
+ class ExceptionDate {
208
+ constructor(date = null, whens = []) {
209
+ this.date = date ? moment(date) : null;
210
+ this.whens = whens;
211
+ }
212
+ }
213
+
214
+ class Comment {
215
+ constructor(label = null, commentTranslations = []) {
216
+ this.label = label;
217
+ this.commentTranslations = commentTranslations;
218
+ }
219
+ }
220
+
221
+ class CommentTranslation {
222
+ constructor(label = null, lang = null) {
223
+ this.label = label;
224
+ this.lang = lang;
225
+ }
226
+ }
227
+
228
+ // Export the classes
229
+ module.exports = {
230
+ Calendar,
231
+ SingleDate,
232
+ PatternDate,
233
+ Open,
234
+ When,
235
+ StatusTranslation,
236
+ ExtraInformation,
237
+ ExceptionDate,
238
+ Comment,
239
+ CommentTranslation
240
+ };
@@ -0,0 +1,149 @@
1
+ // FeedData.js
2
+
3
+ const categories = {
4
+ "evenementen": "2.3",
5
+ "beurs": "2.3.1",
6
+ "braderie": "2.3.2",
7
+ "congres": "2.3.4",
8
+ "corso of optocht": "2.3.5",
9
+ "culinair": "2.3.6",
10
+ "excursie": ["2.7.2", "2.11.2"],
11
+ "kermis": "2.3.8",
12
+ "lezing/debat": "2.3.9",
13
+ "markt": "2.3.10",
14
+ "open dag": "2.3.11",
15
+ "rondleiding": ["2.3.12", "2.11.3"],
16
+ "sportevenement": "2.3.13",
17
+ "workshop": "2.3.15",
18
+ "wandeltocht": "2.3.17",
19
+ "varia": "2.3.18",
20
+ "grootstedelijk evenement": "2.3.23",
21
+ "rommelmarkt": "2.4.6",
22
+ "film": ["2.5.2", "4.6.34"],
23
+ "jeugd": "2.3.25",
24
+ "wijkfeest": "2.3.26",
25
+ "speeltuin": "2.3.27",
26
+ "festivals": "2.4",
27
+ "cultureel festival": "2.4.1",
28
+ "filmfestival": "2.4.2",
29
+ "muziekfestival": "2.4.3",
30
+ "theaterfestival": "2.4.4",
31
+ "jeugdfestival": "2.4.5",
32
+ "festival": "2.4.7",
33
+ "dancefestival": "2.4.8",
34
+ "muziek": ["2.6", "4.6.14"],
35
+ "dance": "2.6.1",
36
+ "jazz of wereldmuziek": "2.6.2",
37
+ "klassieke muziek": "2.6.3",
38
+ "lichte muziek": "2.6.4",
39
+ "pop en rock": "2.6.5",
40
+ "r&b en soul": "2.6.6",
41
+ "muziek overig": "2.6.8",
42
+ "gezelschap/orkest": "2.6.9",
43
+ "theater": "2.9",
44
+ "cabaret": "2.9.1",
45
+ "dans en ballet": "2.9.2",
46
+ "jeugdtheater": "2.9.3",
47
+ "musical of show": "2.9.4",
48
+ "opera": "2.9.5",
49
+ "theater en toneel": "2.9.6",
50
+ "tentoonstellingen": "2.12",
51
+ "tentoonstelling": "2.3.14",
52
+ "congrescentra": "1.1",
53
+ "congres- en vergaderaccommodatie": "1.1.1",
54
+ "campings": "1.2",
55
+ "camping": "1.2.1",
56
+ "logies": "1.3",
57
+ "bed and breakfast": "1.3.1",
58
+ "groepsaccommodatie": "1.3.2",
59
+ "hostel": "1.3.3",
60
+ "hotel": "1.3.4",
61
+ "stacaravan": "1.4.7",
62
+ "attracties": "2.1",
63
+ "attractie": "2.1.1",
64
+ "galerie": "2.2.4",
65
+ "museum": "2.1.6",
66
+ "rondvaart": "2.1.8",
67
+ "wellness": "2.1.2",
68
+ "winkelcentrum": "2.1.12",
69
+ "bezienswaardigheden": "2.2",
70
+ "architectuur": "2.2.1",
71
+ "kerk": "2.2.7",
72
+ "monument": "2.2.9",
73
+ "bos": "2.2.18",
74
+ "bezienswaardigheid": "2.2.19",
75
+ "haven": "2.20",
76
+ "bierbrouwerij": "2.2.20",
77
+ "routes": "2.7",
78
+ "fietsroute": "2.7.3",
79
+ "wandelroute": "2.7.9",
80
+ "natuur": "2.10",
81
+ "natuurgebied": "2.2.10",
82
+ "recreatiegebied": "2.1.7",
83
+ "park/tuin": "2.2.11",
84
+ "strand": "2.2.12",
85
+ "groepsarrangementen en activiteiten": "2.11",
86
+ "tocht": "2.11.4",
87
+ "actief en sportief": "2.11.10",
88
+ "kunst en cultuur": "2.11.11",
89
+ "restaurants": "3.1",
90
+ "restaurant": "3.1.1",
91
+ "strandpaviljoen": "3.1.5",
92
+ "visrestaurant": "3.1.6",
93
+ "kleine horeca": "3.2",
94
+ "ijssalon": "3.2.3",
95
+ "brasserie/lunchroom": "3.2.6",
96
+ "koffiebar": "3.2.7",
97
+ "viswinkel": "3.2.8",
98
+ "uitgaan": "3.3",
99
+ "café of bar": "3.3.1",
100
+ "uitgaanscentrum": "3.3.2",
101
+ "bioscoop": "3.3.3",
102
+ "filmtheater": "3.3.4",
103
+ "muziekpodium": "3.3.5",
104
+ "theaterpodium": "3.3.6",
105
+ "buiten locatie": "3.3.7",
106
+ "algemene voorzieningen ter plaatse": "4.1",
107
+ "transferium": "4.1.7",
108
+ "parkeergarage": "4.1.11",
109
+ "bedrijven ter plaatse": "4.2",
110
+ "beursgebouw": "4.2.4",
111
+ "bibliotheek": "4.2.12",
112
+ "touroperator": "4.2.17",
113
+ "evenementenbureau": "4.2.18",
114
+ "conferentie services": "4.2.21",
115
+ "gids": "4.2.23",
116
+ "vvv": "4.5.1",
117
+ "verhuurbedrijven": "4.3",
118
+ "fietsverhuurbedrijf": "4.3.4",
119
+ "bootverhuurbedrijf": "4.3.2",
120
+ "autoverhuurbedrijf": "4.3.1",
121
+ "partylocatie of zaalverhuur": "4.3.5",
122
+ "bijzonder verhuur": "4.3.9",
123
+ "bus en touringcarverhuur": "4.3.15",
124
+ "winkels": "4.6",
125
+ "huis- en tuin": "4.6.5",
126
+ "voeding/drank": "4.6.7",
127
+ "cadeau": "4.6.8",
128
+ "sport/outdoor/auto": "4.6.9",
129
+ "overige winkels": "4.6.10",
130
+ "vintage": "4.6.11",
131
+ "kinderen": "4.6.12",
132
+ "sieraden/juwelier": "4.6.15",
133
+ "schoenen": "4.6.16",
134
+ "boeken": "4.6.19",
135
+ "speelgoed": "4.6.20",
136
+ "kunst/antiek": "4.6.22",
137
+ "warenhuis": "4.6.25",
138
+ "kleding": "4.6.26",
139
+ "lichaamsverzorging/gezondheid": "4.6.27",
140
+ "hobby/vrije tijd": "4.6.29",
141
+ "vervoer": "4.6.31",
142
+ "cultuur- en sportverenigingen": "4.8",
143
+ "culturele organisaties": "4.8.2",
144
+ "functie": "8.1",
145
+ "onderwijs": "8.1.1",
146
+ "dienstverleners": "8.1.2"
147
+ };
148
+
149
+ module.exports = { categories };