@eventconnectors/ndtrc_model 1.1.0 → 1.4.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.
Files changed (41) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +105 -0
  3. package/dist/index.cjs +934 -0
  4. package/dist/index.d.cts +58227 -0
  5. package/dist/index.d.ts +58227 -0
  6. package/dist/index.js +829 -0
  7. package/package.json +51 -10
  8. package/.claude/settings.local.json +0 -14
  9. package/CLAUDE.md +0 -54
  10. package/eventconnectors-ndtrc_model-1.0.4.tgz +0 -0
  11. package/index.js +0 -36
  12. package/src/__tests__/model.test.js +0 -327
  13. package/src/model/ConvertedEntry.js +0 -22
  14. package/src/model/FetchedEntry.js +0 -55
  15. package/src/model/ff/Acl.js +0 -13
  16. package/src/model/ff/ItemLink.js +0 -25
  17. package/src/model/ff/Route.js +0 -95
  18. package/src/model/ndtrc/Address.js +0 -70
  19. package/src/model/ndtrc/Calendar.js +0 -255
  20. package/src/model/ndtrc/Categories.js +0 -54
  21. package/src/model/ndtrc/ContactInfo.js +0 -188
  22. package/src/model/ndtrc/ExtraPriceInformation.js +0 -16
  23. package/src/model/ndtrc/File.js +0 -155
  24. package/src/model/ndtrc/GISCoordinate.js +0 -19
  25. package/src/model/ndtrc/Location.js +0 -23
  26. package/src/model/ndtrc/Performer.js +0 -9
  27. package/src/model/ndtrc/PriceElement.js +0 -64
  28. package/src/model/ndtrc/Promotion.js +0 -51
  29. package/src/model/ndtrc/RouteInfo.js +0 -34
  30. package/src/model/ndtrc/SubItemGroup.js +0 -102
  31. package/src/model/ndtrc/TRCItem.js +0 -136
  32. package/src/model/ndtrc/TRCItemCategories.js +0 -105
  33. package/src/model/ndtrc/TRCItemDetail.js +0 -10
  34. package/src/model/ndtrc/TRCItemGroup.js +0 -74
  35. package/src/model/ndtrc/TRCItemRelation.js +0 -13
  36. package/src/model/ndtrc/Translations.js +0 -8
  37. package/src/model/ndtrc/enums.js +0 -33
  38. package/src/resources/schema/NDTRC-types-EVENTS.txt +0 -0
  39. package/src/resources/schema/NDTRC-types-locaties.txt +0 -0
  40. package/src/util/CategoryMap.js +0 -194
  41. package/src/util/StringUtils.js +0 -12
@@ -1,155 +0,0 @@
1
- class File {
2
- constructor({
3
- trcid = '',
4
- main = false,
5
- copyright = '',
6
- filename = '',
7
- hlink = '',
8
- filetype = null,
9
- mediatype = null,
10
- targetLanguage = '',
11
- title = null
12
- } = {}) {
13
- this.trcid = trcid;
14
- this.main = main;
15
- this.copyright = copyright;
16
- this.filename = filename;
17
- this.hlink = hlink;
18
- this.filetype = filetype;
19
- this.mediatype = mediatype;
20
- this.targetLanguage = targetLanguage;
21
- this.title = title ? new File.Title(title) : null;
22
- }
23
-
24
- /**
25
- * Schoont de data van de file op.
26
- */
27
- cleanupData() {
28
- if (this.filetype && !this.mediatype) {
29
- if (['vimeo', 'youtube'].includes(this.filetype)) {
30
- this.mediatype = File.MediaType.video;
31
- } else if (
32
- ['jpg', 'jpeg', 'gif', 'png', 'bmp', 'jfif', 'tiff', 'webp'].includes(this.filetype)
33
- ) {
34
- this.mediatype = File.MediaType.photo;
35
- }
36
- }
37
-
38
- if (this.hlink && this.filetype === File.FileType.youtube) {
39
- this.hlink = File.normalizeYouTubeURL(this.hlink);
40
- this.filename = File.youtubeVideoID(this.hlink);
41
- }
42
- }
43
-
44
- /**
45
- * Normaliseert een YouTube-URL naar een standaardformaat.
46
- * @param {string} url
47
- * @returns {string} Genormaliseerde YouTube-URL
48
- */
49
- static normalizeYouTubeURL(url) {
50
- if (!url?.trim()) return url;
51
-
52
- const standardPattern = /https:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/;
53
- const shortenedPattern = /https:\/\/youtu\.be\/([a-zA-Z0-9_-]+)/;
54
- const embedPattern = /https:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9_-]+)/;
55
-
56
- let match = url.match(standardPattern);
57
- if (match) return `https://www.youtube.com/watch?v=${match[1]}`;
58
-
59
- match = url.match(shortenedPattern);
60
- if (match) return `https://www.youtube.com/watch?v=${match[1]}`;
61
-
62
- match = url.match(embedPattern);
63
- if (match) return `https://www.youtube.com/watch?v=${match[1]}`;
64
-
65
- return url; // Als geen van de patronen overeenkomt, retourneer de oorspronkelijke URL
66
- }
67
-
68
- /**
69
- * Extraheert de video-ID van een YouTube-URL.
70
- * @param {string} url
71
- * @returns {string|null} YouTube-video-ID
72
- */
73
- static youtubeVideoID(url) {
74
- if (!url?.trim()) return null;
75
-
76
- const standardPattern = /https:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/;
77
- const shortenedPattern = /https:\/\/youtu\.be\/([a-zA-Z0-9_-]+)/;
78
- const embedPattern = /https:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9_-]+)/;
79
-
80
- let match = url.match(standardPattern);
81
- if (match) return match[1];
82
-
83
- match = url.match(shortenedPattern);
84
- if (match) return match[1];
85
-
86
- match = url.match(embedPattern);
87
- if (match) return match[1];
88
-
89
- return null;
90
- }
91
- }
92
-
93
- /**
94
- * Subklasse: Title
95
- */
96
- File.Title = class Title {
97
- constructor({ label = '', titleTranslations = [] } = {}) {
98
- this.label = label;
99
- this.titleTranslations = titleTranslations.map(
100
- translation => new File.Title.TitleTranslation(translation)
101
- );
102
- }
103
- };
104
-
105
- /**
106
- * Subklasse: TitleTranslation
107
- */
108
- File.Title.TitleTranslation = class TitleTranslation {
109
- constructor({ lang = '', label = '' } = {}) {
110
- this.lang = lang;
111
- this.label = label;
112
- }
113
- };
114
-
115
- /**
116
- * Enum: FileType
117
- */
118
- File.FileType = {
119
- jpeg: 'jpeg',
120
- jpg: 'jpg',
121
- gif: 'gif',
122
- png: 'png',
123
- mp3: 'mp3',
124
- pdf: 'pdf',
125
- gpx: 'gpx',
126
- kml: 'kml',
127
- youtube: 'youtube',
128
- kmz: 'kmz',
129
- vimeo: 'vimeo',
130
- tif: 'tif',
131
- bmp: 'bmp',
132
- jfif: 'jfif',
133
- tiff: 'tiff',
134
- webp: 'webp'
135
- };
136
-
137
- /**
138
- * Enum: MediaType
139
- */
140
- File.MediaType = {
141
- poster: 'poster',
142
- other: 'other',
143
- audio: 'audio',
144
- brochure: 'brochure',
145
- floorplan: 'floorplan',
146
- photo: 'photo',
147
- logo: 'logo',
148
- video: 'video',
149
- roadmap: 'roadmap',
150
- text: 'text',
151
- attachment: 'attachment',
152
- qr: 'qr'
153
- };
154
-
155
- module.exports = File;
@@ -1,19 +0,0 @@
1
- const StringUtils = require('../../util/StringUtils'); // Import StringUtils voor validaties
2
-
3
- class GISCoordinate {
4
- constructor({ xcoordinate = '', ycoordinate = '', label = '' } = {}) {
5
- this.xcoordinate = xcoordinate;
6
- this.ycoordinate = ycoordinate;
7
- this.label = label;
8
- }
9
-
10
- /**
11
- * Controleert of de GIS-coördinaten leeg zijn.
12
- * @returns {boolean}
13
- */
14
- isEmpty() {
15
- return StringUtils.isEmpty(this.xcoordinate) && StringUtils.isEmpty(this.ycoordinate);
16
- }
17
- }
18
-
19
- module.exports = GISCoordinate;
@@ -1,23 +0,0 @@
1
- const Address = require('./Address'); // Importeer de Address-klasse
2
-
3
- class Location {
4
- constructor({ address = null, label = '', locationItem = null, venueItem = null } = {}) {
5
- this.address = address ? new Address(address) : null;
6
- this.label = label;
7
- this.locationItem = locationItem ? new Location.LocationItem(locationItem) : null;
8
- this.venueItem = venueItem ? new Location.LocationItem(venueItem) : null;
9
- }
10
- }
11
-
12
- /**
13
- * Subklasse: LocationItem
14
- */
15
- Location.LocationItem = class LocationItem {
16
- constructor({ id = '', trcid = '', text = '' } = {}) {
17
- this.id = id;
18
- this.trcid = trcid;
19
- this.text = text;
20
- }
21
- };
22
-
23
- module.exports = Location;
@@ -1,9 +0,0 @@
1
- class Performer {
2
- constructor({ roleid = '', label = '', rolelabel = '' } = {}) {
3
- this.roleid = roleid;
4
- this.label = label;
5
- this.rolelabel = rolelabel;
6
- }
7
- }
8
-
9
- module.exports = Performer;
@@ -1,64 +0,0 @@
1
- class PriceElement {
2
- constructor({
3
- freeentrance = false,
4
- priceValue = null,
5
- description = null,
6
- comments = [],
7
- extraPriceInformations = []
8
- } = {}) {
9
- this.freeentrance = freeentrance;
10
- this.priceValue = priceValue ? new PriceElement.PriceValue(priceValue) : null;
11
- this.description = description ? new PriceElement.Description(description) : null;
12
- this.comments = comments.map(comment => new PriceElement.Comment(comment));
13
- this.extraPriceInformations = extraPriceInformations.map(
14
- info => new PriceElement.ExtraPriceInformation(info)
15
- );
16
- }
17
- }
18
-
19
- PriceElement.Description = class Description {
20
- constructor({ value = null, descriptionTranslations = [] } = {}) {
21
- this.value = value;
22
- this.descriptionTranslations = descriptionTranslations.map(
23
- translation => new PriceElement.Description.DescriptionTranslation(translation)
24
- );
25
- }
26
- };
27
-
28
- PriceElement.Description.PriceDescriptionValue = {
29
- Adults: 'Adults',
30
- Children: 'Children',
31
- Groups: 'Groups',
32
- CJP: 'CJP',
33
- Pasholders: 'Pasholders',
34
- Lastminute: 'Lastminute'
35
- };
36
-
37
- PriceElement.Description.DescriptionTranslation = class DescriptionTranslation {
38
- constructor({ lang = '', text = '' } = {}) {
39
- this.lang = lang;
40
- this.text = text;
41
- }
42
- };
43
-
44
- PriceElement.ExtraPriceInformation = class ExtraPriceInformation {
45
- constructor({ lang = '', text = '' } = {}) {
46
- this.lang = lang;
47
- this.text = text;
48
- }
49
- };
50
-
51
- PriceElement.PriceValue = class PriceValue {
52
- constructor({ from = null, until = null } = {}) {
53
- this.from = from;
54
- this.until = until;
55
- }
56
- };
57
-
58
- PriceElement.Comment = class Comment {
59
- constructor({ text = '' } = {}) {
60
- this.text = text;
61
- }
62
- };
63
-
64
- module.exports = PriceElement;
@@ -1,51 +0,0 @@
1
- const moment = require('moment');
2
- const Contactinfo = require('./ContactInfo');
3
- const Calendar = require('./Calendar');
4
-
5
- class Promotion {
6
- constructor({
7
- product = '',
8
- promotionType = null,
9
- discount = null,
10
- translations = [],
11
- detailsUrls = [],
12
- startDate = null,
13
- endDate = null,
14
- enabled = true,
15
- opens = []
16
- } = {}) {
17
- this.product = product;
18
- this.promotionType = promotionType;
19
- this.discount = discount ? new Promotion.Discount(discount) : null;
20
- this.translations = translations.map(translation => new Promotion.PromotionTranslation(translation));
21
- this.detailsUrls = detailsUrls.map(url => new Contactinfo.Url(url));
22
- this.startDate = startDate ? moment(startDate) : null;
23
- this.endDate = endDate ? moment(endDate) : null;
24
- this.enabled = enabled;
25
- this.opens = opens.map(open => new Calendar.PatternDate.Open(open));
26
- }
27
- }
28
-
29
- Promotion.Discount = class Discount {
30
- constructor({ free = false, percentage = null, amount = null } = {}) {
31
- this.free = free;
32
- this.percentage = percentage;
33
- this.amount = amount;
34
- }
35
- };
36
-
37
- Promotion.PromotionTranslation = class PromotionTranslation {
38
- constructor({ lang = '', description = '' } = {}) {
39
- this.lang = lang;
40
- this.description = description;
41
- }
42
- };
43
-
44
- Promotion.PromotionType = {
45
- free: 'free',
46
- discount: 'discount',
47
- gift: 'gift',
48
- allowance: 'allowance'
49
- };
50
-
51
- module.exports = Promotion;
@@ -1,34 +0,0 @@
1
- const Address = require('./Address');
2
-
3
- class RouteInfo {
4
- constructor({
5
- type = null,
6
- url = '',
7
- distanceInKilometers = null,
8
- durationInMinutes = null,
9
- start = null,
10
- end = null
11
- } = {}) {
12
- this.type = type;
13
- this.url = url;
14
- this.distanceInKilometers = distanceInKilometers;
15
- this.durationInMinutes = durationInMinutes;
16
- this.start = start ? new Address(start) : null;
17
- this.end = end ? new Address(end) : null;
18
- }
19
-
20
- static Type = {
21
- ROUTE_MAKER: 'route_maker',
22
- ROUTE_IQ: 'route_iq',
23
- ODP_ROUTES: 'odp_routes',
24
-
25
- fromString(type) {
26
- if (Object.values(RouteInfo.Type).includes(type)) {
27
- return type;
28
- }
29
- throw new Error(`Invalid Type: ${type}`);
30
- }
31
- };
32
- }
33
-
34
- module.exports = RouteInfo;
@@ -1,102 +0,0 @@
1
- class SubItemGroup {
2
- constructor({
3
- trcid = '',
4
- type = null,
5
- categories = [],
6
- subItemTranslations = [],
7
- media = []
8
- } = {}) {
9
- this.trcid = trcid;
10
- this.type = type ? new SubItemGroup.Type(type) : null;
11
- this.categories = categories.map(category => new SubItemGroup.Category(category));
12
- this.subItemTranslations = subItemTranslations.map(
13
- translation => new SubItemGroup.SubItemTranslation(translation)
14
- );
15
- this.media = media.map(file => new File(file));
16
- }
17
-
18
- cleanEmptyItems() {
19
- this.categories = this.categories.filter(category => {
20
- const dataType = category.datatype?.toLowerCase();
21
- if (dataType === 'freetext' && !category.value) return false;
22
- if (['multichoice', 'choice'].includes(dataType) && !category.valueid) return false;
23
- return true;
24
- });
25
- }
26
- }
27
-
28
- SubItemGroup.SubItemTranslation = class SubItemTranslation {
29
- constructor({ lang = '', title = '' } = {}) {
30
- this.lang = lang;
31
- this.title = title;
32
- }
33
- };
34
-
35
- SubItemGroup.Type = class Type {
36
- constructor({ catid = '', isDefault = false, categoryTranslations = [] } = {}) {
37
- this.catid = catid;
38
- this.isDefault = isDefault;
39
- this.categoryTranslations = categoryTranslations.map(
40
- translation => new SubItemGroup.CategoryTranslation(translation)
41
- );
42
- }
43
- };
44
-
45
- SubItemGroup.Category = class Category {
46
- constructor({
47
- catid = '',
48
- valueid = '',
49
- value = '',
50
- datatype = '',
51
- categoryvalues = [],
52
- categoryTranslations = [],
53
- parentCategoryTranslations = [],
54
- valueCategoryTranslations = []
55
- } = {}) {
56
- this.catid = catid;
57
- this.valueid = valueid;
58
- this.value = value;
59
- this.datatype = datatype;
60
- this.categoryvalues = categoryvalues.map(
61
- value => new SubItemGroup.CategoryValue(value)
62
- );
63
- this.categoryTranslations = categoryTranslations.map(
64
- translation => new SubItemGroup.CategoryTranslation(translation)
65
- );
66
- this.parentCategoryTranslations = parentCategoryTranslations.map(
67
- translation => new SubItemGroup.CategoryTranslation(translation)
68
- );
69
- this.valueCategoryTranslations = valueCategoryTranslations.map(
70
- translation => new SubItemGroup.CategoryTranslation(translation)
71
- );
72
- }
73
- };
74
-
75
- SubItemGroup.CategoryValue = class CategoryValue {
76
- constructor({ catid = '', categorytranslations = [] } = {}) {
77
- this.catid = catid;
78
- this.categorytranslations = categorytranslations.map(
79
- translation => new SubItemGroup.CategoryTranslation(translation)
80
- );
81
- }
82
- };
83
-
84
- SubItemGroup.CategoryTranslation = class CategoryTranslation {
85
- constructor({
86
- catid = '',
87
- lang = '',
88
- label = '',
89
- unit = '',
90
- value = '',
91
- explanation = ''
92
- } = {}) {
93
- this.catid = catid;
94
- this.lang = lang;
95
- this.label = label;
96
- this.unit = unit;
97
- this.value = value;
98
- this.explanation = explanation;
99
- }
100
- };
101
-
102
- module.exports = SubItemGroup;
@@ -1,136 +0,0 @@
1
- const moment = require('moment');
2
- const Calendar = require('./Calendar');
3
- const Contactinfo = require('./ContactInfo');
4
- const TRCItemCategories = require('./TRCItemCategories');
5
- const Performer = require('./Performer');
6
- const File = require('./File');
7
- const TRCItemDetail = require('./TRCItemDetail');
8
- const TrcitemRelation = require('./TRCItemRelation');
9
- const Location = require('./Location');
10
- const PriceElement = require('./PriceElement');
11
- const ExtraPriceInformation = require('./ExtraPriceInformation');
12
- const RouteInfo = require('./RouteInfo');
13
- const Translations = require('./Translations');
14
- const Promotion = require('./Promotion');
15
-
16
- class TRCItem {
17
- constructor({
18
- trcid = '',
19
- creationdate = null,
20
- availablefrom = null,
21
- availableto = null,
22
- lastupdated = null,
23
- lastimportedon = null,
24
- createdby = '',
25
- lastupdatedby = '',
26
- owner = '',
27
- legalowner = '',
28
- externalid = '',
29
- slug = '',
30
- validator = '',
31
- validatedby = null,
32
- wfstatus = null,
33
- cidn = '',
34
- published = false,
35
- deleted = false,
36
- offline = null,
37
- isprivate = null,
38
- entitytype = null,
39
- productiontrcid = '',
40
- calendar = null,
41
- contactinfo = null,
42
- trcItemCategories = null,
43
- performers = [],
44
- files = [],
45
- trcItemDetails = [],
46
- trcitemRelation = null,
47
- keywords = '',
48
- markers = '',
49
- location = null,
50
- locationRef = '',
51
- userorganisation = '',
52
- priceElements = [],
53
- extrapriceinformations = [],
54
- routeInfo = null,
55
- translations = null,
56
- promotions = [],
57
- forceOverwrite = false
58
- } = {}) {
59
- this.trcid = trcid;
60
- this.creationdate = creationdate ? moment(creationdate) : null;
61
- this.availablefrom = availablefrom ? moment(availablefrom) : null;
62
- this.availableto = availableto ? moment(availableto) : null;
63
- this.lastupdated = lastupdated ? moment(lastupdated) : null;
64
- this.lastimportedon = lastimportedon ? moment(lastimportedon) : null;
65
- this.createdby = createdby;
66
- this.lastupdatedby = lastupdatedby;
67
- this.owner = owner;
68
- this.legalowner = legalowner;
69
- this.externalid = externalid;
70
- this.slug = slug;
71
- this.validator = validator;
72
- this.validatedby = validatedby;
73
- this.wfstatus = wfstatus;
74
- this.cidn = cidn;
75
- this.published = published;
76
- this.deleted = deleted;
77
- this.offline = offline;
78
- this.isprivate = isprivate;
79
- this.entitytype = entitytype;
80
- this.productiontrcid = productiontrcid;
81
- this.calendar = calendar ? new Calendar(calendar) : null;
82
- this.contactinfo = contactinfo ? new Contactinfo(contactinfo) : null;
83
- this.trcItemCategories = trcItemCategories ? new TRCItemCategories(trcItemCategories) : null;
84
- this.performers = performers.map(performer => new Performer(performer));
85
- this.files = files.map(file => new File(file));
86
- this.trcItemDetails = trcItemDetails.map(detail => new TRCItemDetail(detail));
87
- this.trcitemRelation = trcitemRelation ? new TrcitemRelation(trcitemRelation) : null;
88
- this.keywords = keywords;
89
- this.markers = markers;
90
- this.location = location ? new Location(location) : null;
91
- this.locationRef = locationRef;
92
- this.userorganisation = userorganisation;
93
- this.priceElements = priceElements.map(element => new PriceElement(element));
94
- this.extrapriceinformations = extrapriceinformations.map(
95
- info => new ExtraPriceInformation(info)
96
- );
97
- this.routeInfo = routeInfo ? new RouteInfo(routeInfo) : null;
98
- this.translations = translations ? new Translations(translations) : new Translations();
99
- this.promotions = promotions.map(promotion => new Promotion(promotion));
100
- this.forceOverwrite = forceOverwrite;
101
- }
102
- }
103
-
104
- TRCItem.WFStatus = {
105
- DRAFT: 'draft',
106
- READY_FOR_VALIDATION: 'readyforvalidation',
107
- APPROVED: 'approved',
108
- REJECTED: 'rejected',
109
- DELETED: 'deleted',
110
- ARCHIVED: 'archived'
111
- };
112
-
113
- TRCItem.EntityType = {
114
- EVENEMENT: 'EVENEMENT',
115
- LOCATIE: 'LOCATIE',
116
- EVENEMENTGROEP: 'EVENEMENTGROEP',
117
- PLAATSREGIO: 'PLAATSREGIO',
118
- ROUTE: 'ROUTE',
119
- VENUE: 'VENUE'
120
- };
121
-
122
- TRCItem.Category = class Category {
123
- constructor({ id = '', translations = [] } = {}) {
124
- this.id = id;
125
- this.translations = translations.map(translation => new TRCItem.Category.Translation(translation));
126
- }
127
- };
128
-
129
- TRCItem.Category.Translation = class Translation {
130
- constructor({ lang = '', text = '' } = {}) {
131
- this.lang = lang;
132
- this.text = text;
133
- }
134
- };
135
-
136
- module.exports = TRCItem;