feedsmith 2.3.0 → 2.4.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 (94) hide show
  1. package/README.md +18 -10
  2. package/dist/common/config.cjs +47 -0
  3. package/dist/common/config.js +47 -0
  4. package/dist/common/utils.cjs +20 -3
  5. package/dist/common/utils.js +19 -4
  6. package/dist/feeds/atom/common/types.d.cts +29 -9
  7. package/dist/feeds/atom/common/types.d.ts +29 -9
  8. package/dist/feeds/atom/detect/index.cjs +1 -1
  9. package/dist/feeds/atom/detect/index.js +1 -1
  10. package/dist/feeds/atom/generate/utils.cjs +61 -41
  11. package/dist/feeds/atom/generate/utils.js +47 -27
  12. package/dist/feeds/atom/parse/utils.cjs +60 -38
  13. package/dist/feeds/atom/parse/utils.js +48 -26
  14. package/dist/feeds/rdf/common/types.d.cts +8 -6
  15. package/dist/feeds/rdf/common/types.d.ts +8 -6
  16. package/dist/feeds/rdf/detect/index.cjs +1 -1
  17. package/dist/feeds/rdf/detect/index.js +1 -1
  18. package/dist/feeds/rdf/parse/utils.cjs +27 -25
  19. package/dist/feeds/rdf/parse/utils.js +9 -7
  20. package/dist/feeds/rss/common/types.d.cts +40 -20
  21. package/dist/feeds/rss/common/types.d.ts +40 -20
  22. package/dist/feeds/rss/detect/index.cjs +1 -1
  23. package/dist/feeds/rss/detect/index.js +1 -1
  24. package/dist/feeds/rss/generate/index.d.cts +1 -1
  25. package/dist/feeds/rss/generate/index.d.ts +1 -1
  26. package/dist/feeds/rss/generate/utils.cjs +78 -55
  27. package/dist/feeds/rss/generate/utils.js +63 -40
  28. package/dist/feeds/rss/parse/utils.cjs +67 -52
  29. package/dist/feeds/rss/parse/utils.js +52 -37
  30. package/dist/namespaces/admin/common/types.d.cts +9 -0
  31. package/dist/namespaces/admin/common/types.d.ts +9 -0
  32. package/dist/namespaces/admin/generate/utils.cjs +13 -0
  33. package/dist/namespaces/admin/generate/utils.js +13 -0
  34. package/dist/namespaces/admin/parse/utils.cjs +13 -0
  35. package/dist/namespaces/admin/parse/utils.js +13 -0
  36. package/dist/namespaces/app/common/types.d.cts +14 -0
  37. package/dist/namespaces/app/common/types.d.ts +14 -0
  38. package/dist/namespaces/app/generate/utils.cjs +17 -0
  39. package/dist/namespaces/app/generate/utils.js +17 -0
  40. package/dist/namespaces/app/parse/utils.cjs +17 -0
  41. package/dist/namespaces/app/parse/utils.js +17 -0
  42. package/dist/namespaces/arxiv/common/types.d.cts +19 -0
  43. package/dist/namespaces/arxiv/common/types.d.ts +19 -0
  44. package/dist/namespaces/arxiv/generate/utils.cjs +28 -0
  45. package/dist/namespaces/arxiv/generate/utils.js +27 -0
  46. package/dist/namespaces/arxiv/parse/utils.cjs +28 -0
  47. package/dist/namespaces/arxiv/parse/utils.js +27 -0
  48. package/dist/namespaces/cc/parse/utils.cjs +11 -18
  49. package/dist/namespaces/cc/parse/utils.js +12 -19
  50. package/dist/namespaces/creativecommons/common/types.d.cts +2 -2
  51. package/dist/namespaces/creativecommons/common/types.d.ts +2 -2
  52. package/dist/namespaces/dcterms/common/types.d.cts +2 -2
  53. package/dist/namespaces/dcterms/common/types.d.ts +2 -2
  54. package/dist/namespaces/feedpress/common/types.d.cts +2 -2
  55. package/dist/namespaces/feedpress/common/types.d.ts +2 -2
  56. package/dist/namespaces/geo/common/types.d.cts +10 -0
  57. package/dist/namespaces/geo/common/types.d.ts +10 -0
  58. package/dist/namespaces/geo/generate/utils.cjs +14 -0
  59. package/dist/namespaces/geo/generate/utils.js +14 -0
  60. package/dist/namespaces/geo/parse/utils.cjs +14 -0
  61. package/dist/namespaces/geo/parse/utils.js +14 -0
  62. package/dist/namespaces/georss/common/types.d.cts +2 -2
  63. package/dist/namespaces/georss/common/types.d.ts +2 -2
  64. package/dist/namespaces/googleplay/common/types.d.cts +25 -0
  65. package/dist/namespaces/googleplay/common/types.d.ts +25 -0
  66. package/dist/namespaces/googleplay/generate/utils.cjs +41 -0
  67. package/dist/namespaces/googleplay/generate/utils.js +40 -0
  68. package/dist/namespaces/googleplay/parse/utils.cjs +44 -0
  69. package/dist/namespaces/googleplay/parse/utils.js +43 -0
  70. package/dist/namespaces/media/generate/utils.cjs +3 -3
  71. package/dist/namespaces/media/generate/utils.js +3 -3
  72. package/dist/namespaces/opensearch/common/types.d.cts +21 -0
  73. package/dist/namespaces/opensearch/common/types.d.ts +21 -0
  74. package/dist/namespaces/opensearch/generate/utils.cjs +28 -0
  75. package/dist/namespaces/opensearch/generate/utils.js +28 -0
  76. package/dist/namespaces/opensearch/parse/utils.cjs +28 -0
  77. package/dist/namespaces/opensearch/parse/utils.js +28 -0
  78. package/dist/namespaces/pingback/common/types.d.cts +12 -0
  79. package/dist/namespaces/pingback/common/types.d.ts +12 -0
  80. package/dist/namespaces/pingback/generate/utils.cjs +18 -0
  81. package/dist/namespaces/pingback/generate/utils.js +17 -0
  82. package/dist/namespaces/pingback/parse/utils.cjs +18 -0
  83. package/dist/namespaces/pingback/parse/utils.js +17 -0
  84. package/dist/namespaces/rawvoice/common/types.d.cts +2 -2
  85. package/dist/namespaces/rawvoice/common/types.d.ts +2 -2
  86. package/dist/namespaces/source/generate/utils.cjs +7 -7
  87. package/dist/namespaces/source/generate/utils.js +8 -8
  88. package/dist/namespaces/trackback/common/types.d.cts +9 -0
  89. package/dist/namespaces/trackback/common/types.d.ts +9 -0
  90. package/dist/namespaces/trackback/generate/utils.cjs +13 -0
  91. package/dist/namespaces/trackback/generate/utils.js +13 -0
  92. package/dist/namespaces/trackback/parse/utils.cjs +13 -0
  93. package/dist/namespaces/trackback/parse/utils.js +13 -0
  94. package/package.json +6 -6
package/README.md CHANGED
@@ -60,7 +60,7 @@ Feedsmith aims to fully support all major feed formats and namespaces in complet
60
60
  |--------|----------|---------|------------|
61
61
  | [RSS](http://cyber.law.harvard.edu/rss/rss.html) | 0.9x, 2.0 | ✅ | ✅ |
62
62
  | [Atom](https://tools.ietf.org/html/rfc4287) | 0.3, 1.0 | ✅ | ✅ |
63
- | [RDF](https://web.resource.org/rss/1.0/spec) | 0.9, 1.0 | ✅ | ⏳ |
63
+ | [RDF](https://web.resource.org/rss/1.0/spec) | 0.9, 1.0 | ✅ | 📋 |
64
64
  | [JSON Feed](https://jsonfeed.org) | 1.0, 1.1 | ✅ | ✅ |
65
65
 
66
66
  ### Namespaces
@@ -69,24 +69,32 @@ Feedsmith aims to fully support all major feed formats and namespaces in complet
69
69
  |------|---------|--------------|---------|------------|
70
70
  | [Atom](http://www.w3.org/2005/Atom) | `<atom:*>` | RSS, RDF | ✅ | ✅ |
71
71
  | [Dublin Core](http://purl.org/dc/elements/1.1/) | `<dc:*>` | RSS, Atom, RDF | ✅ | ✅ |
72
+ | [Dublin Core Terms](http://purl.org/dc/terms/) | `<dcterms:*>` | RSS, Atom, RDF | ✅ | ✅ |
72
73
  | [Syndication](http://purl.org/rss/1.0/modules/syndication/) | `<sy:*>` | RSS, Atom, RDF | ✅ | ✅ |
73
74
  | [Content](http://purl.org/rss/1.0/modules/content/) | `<content:*>` | RSS, RDF | ✅ | ✅ |
74
75
  | [Slash](http://purl.org/rss/1.0/modules/slash/) | `<slash:*>` | RSS, Atom, RDF | ✅ | ✅ |
75
76
  | [iTunes](http://www.itunes.com/dtds/podcast-1.0.dtd) | `<itunes:*>` | RSS, Atom | ✅ | ✅ |
76
- | [Podcast](https://podcastindex.org/namespace/1.0) | `<podcast:*>` | RSS | ✅ | ✅ |
77
- | [RawVoice](https://blubrry.com/developer/rawvoice-rss/) | `<rawvoice:*>` | RSS | ✅ | ✅ |
77
+ | [Podcast Index](https://podcastindex.org/namespace/1.0) | `<podcast:*>` | RSS | ✅ | ✅ |
78
78
  | [Podlove Simple Chapters](http://podlove.org/simple-chapters) | `<psc:*>` | RSS, Atom | ✅ | ✅ |
79
- | [Spotify](http://www.spotify.com/ns/rss) | `<spotify:*>` | RSS | ✅ | ✅ |
80
79
  | [Media RSS](http://search.yahoo.com/mrss/) | `<media:*>` | RSS, Atom, RDF | ✅ | ✅ |
81
- | [GeoRSS-Simple](http://www.georss.org/georss) | `<georss:*>` | RSS, Atom, RDF | ✅ | ✅ |
82
- | [Atom Threading](https://www.ietf.org/rfc/rfc4685.txt) | `<thr:*>` | RSS, Atom | ✅ | ✅ |
83
- | [Dublin Core Terms](http://purl.org/dc/terms/) | `<dcterms:*>` | RSS, Atom, RDF | ✅ | ✅ |
84
- | [Well-Formed Web](http://wellformedweb.org/CommentAPI/) | `<wfw:*>` | RSS, Atom, RDF | ✅ | ✅ |
85
- | [Source](http://source.scripting.com/) | `<source:*>` | RSS | ✅ | ✅ |
80
+ | [Google Play Podcast](https://www.google.com/schemas/play-podcasts/1.0/) | `<googleplay:*>` | RSS, Atom | ✅ | ✅ |
81
+ | [Spotify](http://www.spotify.com/ns/rss) | `<spotify:*>` | RSS | ✅ | ✅ |
82
+ | [RawVoice](https://blubrry.com/developer/rawvoice-rss/) | `<rawvoice:*>` | RSS | ✅ | ✅ |
83
+ | [FeedPress](https://feedpress.com/xmlns) | `<feedpress:*>` | RSS | ✅ | ✅ |
84
+ | [arXiv](http://arxiv.org/schemas/atom) | `<arxiv:*>` | Atom | ✅ | ✅ |
85
+ | [OpenSearch](http://a9.com/-/spec/opensearch/1.1/) | `<opensearch:*>` | RSS, Atom | ✅ | ✅ |
86
86
  | [ccREL](http://creativecommons.org/ns#) | `<cc:*>` | RSS, Atom | ✅ | ✅ |
87
87
  | [Creative Commons](http://backend.userland.com/creativeCommonsRssModule) | `<creativeCommons:*>` | RSS, Atom | ✅ | ✅ |
88
- | [FeedPress](https://feedpress.com/xmlns) | `<feedpress:*>` | RSS | ✅ | ✅ |
88
+ | [Atom Threading](https://www.ietf.org/rfc/rfc4685.txt) | `<thr:*>` | RSS, Atom | ✅ | ✅ |
89
+ | [Atom Publishing Protocol](http://www.w3.org/2007/app) | `<app:*>` | Atom | ✅ | ✅ |
90
+ | [Comment API](http://wellformedweb.org/CommentAPI/) | `<wfw:*>` | RSS, Atom, RDF | ✅ | ✅ |
91
+ | [Administrative](http://webns.net/mvcb/) | `<admin:*>` | RSS, Atom, RDF | ✅ | ✅ |
92
+ | [Pingback](http://madskills.com/public/xml/rss/module/pingback/) | `<pingback:*>` | RSS, Atom | ✅ | ✅ |
93
+ | [Trackback](http://madskills.com/public/xml/rss/module/trackback/) | `<trackback:*>` | RSS, Atom | ✅ | ✅ |
94
+ | [Source](http://source.scripting.com/) | `<source:*>` | RSS | ✅ | ✅ |
89
95
  | [YouTube](https://www.youtube.com/feeds/videos.xml) | `<yt:*>` | Atom | ✅ | ✅ |
96
+ | [W3C Basic Geo](http://www.w3.org/2003/01/geo/wgs84_pos#) | `<geo:*>` | RSS, Atom | ✅ | ✅ |
97
+ | [GeoRSS Simple](http://www.georss.org/georss) | `<georss:*>` | RSS, Atom, RDF | ✅ | ✅ |
90
98
 
91
99
  ### Other
92
100
 
@@ -32,6 +32,12 @@ const locales = {
32
32
  invalidInputRss: "Invalid input RSS"
33
33
  };
34
34
  const namespaceUris = {
35
+ admin: [
36
+ "http://webns.net/mvcb/",
37
+ "https://webns.net/mvcb/",
38
+ "http://webns.net/mvcb",
39
+ "https://webns.net/mvcb"
40
+ ],
35
41
  atom: [
36
42
  "http://www.w3.org/2005/Atom",
37
43
  "https://www.w3.org/2005/Atom",
@@ -40,6 +46,12 @@ const namespaceUris = {
40
46
  "http://purl.org/atom/ns#",
41
47
  "https://purl.org/atom/ns#"
42
48
  ],
49
+ app: [
50
+ "http://www.w3.org/2007/app",
51
+ "https://www.w3.org/2007/app",
52
+ "http://www.w3.org/2007/app/",
53
+ "https://www.w3.org/2007/app/"
54
+ ],
43
55
  dc: [
44
56
  "http://purl.org/dc/elements/1.1/",
45
57
  "https://purl.org/dc/elements/1.1/",
@@ -124,6 +136,7 @@ const namespaceUris = {
124
136
  "https://www.georss.org/georss",
125
137
  "https://www.georss.org/georss/"
126
138
  ],
139
+ geo: ["http://www.w3.org/2003/01/geo/wgs84_pos#", "https://www.w3.org/2003/01/geo/wgs84_pos#"],
127
140
  thr: [
128
141
  "http://purl.org/syndication/thread/1.0",
129
142
  "https://purl.org/syndication/thread/1.0",
@@ -180,6 +193,14 @@ const namespaceUris = {
180
193
  "http://www.youtube.com/xml/schemas/2015/",
181
194
  "https://www.youtube.com/xml/schemas/2015/"
182
195
  ],
196
+ googleplay: [
197
+ "https://www.google.com/schemas/play-podcasts/1.0/",
198
+ "http://www.google.com/schemas/play-podcasts/1.0/",
199
+ "https://www.google.com/schemas/play-podcasts/1.0",
200
+ "http://www.google.com/schemas/play-podcasts/1.0",
201
+ "https://www.google.com/schemas/play-podcasts/1.0/play-podcasts.xsd",
202
+ "http://www.google.com/schemas/play-podcasts/1.0/play-podcasts.xsd"
203
+ ],
183
204
  spotify: [
184
205
  "http://www.spotify.com/ns/rss",
185
206
  "https://www.spotify.com/ns/rss",
@@ -204,6 +225,32 @@ const namespaceUris = {
204
225
  "https://web.resource.org/cc/",
205
226
  "http://web.resource.org/cc",
206
227
  "https://web.resource.org/cc"
228
+ ],
229
+ opensearch: [
230
+ "http://a9.com/-/spec/opensearch/1.1/",
231
+ "https://a9.com/-/spec/opensearch/1.1/",
232
+ "http://a9.com/-/spec/opensearch/1.0/",
233
+ "https://a9.com/-/spec/opensearch/1.0/",
234
+ "http://a9.com/-/spec/opensearchrss/1.0/",
235
+ "https://a9.com/-/spec/opensearchrss/1.0/"
236
+ ],
237
+ arxiv: [
238
+ "http://arxiv.org/schemas/atom",
239
+ "https://arxiv.org/schemas/atom",
240
+ "http://arxiv.org/schemas/atom/",
241
+ "https://arxiv.org/schemas/atom/"
242
+ ],
243
+ pingback: [
244
+ "http://madskills.com/public/xml/rss/module/pingback/",
245
+ "https://madskills.com/public/xml/rss/module/pingback/",
246
+ "http://madskills.com/public/xml/rss/module/pingback",
247
+ "https://madskills.com/public/xml/rss/module/pingback"
248
+ ],
249
+ trackback: [
250
+ "http://madskills.com/public/xml/rss/module/trackback/",
251
+ "https://madskills.com/public/xml/rss/module/trackback/",
252
+ "http://madskills.com/public/xml/rss/module/trackback",
253
+ "https://madskills.com/public/xml/rss/module/trackback"
207
254
  ]
208
255
  };
209
256
  const namespacePrefixes = Object.entries(namespaceUris).reduce((prefixes, [prefix, uris]) => {
@@ -31,6 +31,12 @@ const locales = {
31
31
  invalidInputRss: "Invalid input RSS"
32
32
  };
33
33
  const namespaceUris = {
34
+ admin: [
35
+ "http://webns.net/mvcb/",
36
+ "https://webns.net/mvcb/",
37
+ "http://webns.net/mvcb",
38
+ "https://webns.net/mvcb"
39
+ ],
34
40
  atom: [
35
41
  "http://www.w3.org/2005/Atom",
36
42
  "https://www.w3.org/2005/Atom",
@@ -39,6 +45,12 @@ const namespaceUris = {
39
45
  "http://purl.org/atom/ns#",
40
46
  "https://purl.org/atom/ns#"
41
47
  ],
48
+ app: [
49
+ "http://www.w3.org/2007/app",
50
+ "https://www.w3.org/2007/app",
51
+ "http://www.w3.org/2007/app/",
52
+ "https://www.w3.org/2007/app/"
53
+ ],
42
54
  dc: [
43
55
  "http://purl.org/dc/elements/1.1/",
44
56
  "https://purl.org/dc/elements/1.1/",
@@ -123,6 +135,7 @@ const namespaceUris = {
123
135
  "https://www.georss.org/georss",
124
136
  "https://www.georss.org/georss/"
125
137
  ],
138
+ geo: ["http://www.w3.org/2003/01/geo/wgs84_pos#", "https://www.w3.org/2003/01/geo/wgs84_pos#"],
126
139
  thr: [
127
140
  "http://purl.org/syndication/thread/1.0",
128
141
  "https://purl.org/syndication/thread/1.0",
@@ -179,6 +192,14 @@ const namespaceUris = {
179
192
  "http://www.youtube.com/xml/schemas/2015/",
180
193
  "https://www.youtube.com/xml/schemas/2015/"
181
194
  ],
195
+ googleplay: [
196
+ "https://www.google.com/schemas/play-podcasts/1.0/",
197
+ "http://www.google.com/schemas/play-podcasts/1.0/",
198
+ "https://www.google.com/schemas/play-podcasts/1.0",
199
+ "http://www.google.com/schemas/play-podcasts/1.0",
200
+ "https://www.google.com/schemas/play-podcasts/1.0/play-podcasts.xsd",
201
+ "http://www.google.com/schemas/play-podcasts/1.0/play-podcasts.xsd"
202
+ ],
182
203
  spotify: [
183
204
  "http://www.spotify.com/ns/rss",
184
205
  "https://www.spotify.com/ns/rss",
@@ -203,6 +224,32 @@ const namespaceUris = {
203
224
  "https://web.resource.org/cc/",
204
225
  "http://web.resource.org/cc",
205
226
  "https://web.resource.org/cc"
227
+ ],
228
+ opensearch: [
229
+ "http://a9.com/-/spec/opensearch/1.1/",
230
+ "https://a9.com/-/spec/opensearch/1.1/",
231
+ "http://a9.com/-/spec/opensearch/1.0/",
232
+ "https://a9.com/-/spec/opensearch/1.0/",
233
+ "http://a9.com/-/spec/opensearchrss/1.0/",
234
+ "https://a9.com/-/spec/opensearchrss/1.0/"
235
+ ],
236
+ arxiv: [
237
+ "http://arxiv.org/schemas/atom",
238
+ "https://arxiv.org/schemas/atom",
239
+ "http://arxiv.org/schemas/atom/",
240
+ "https://arxiv.org/schemas/atom/"
241
+ ],
242
+ pingback: [
243
+ "http://madskills.com/public/xml/rss/module/pingback/",
244
+ "https://madskills.com/public/xml/rss/module/pingback/",
245
+ "http://madskills.com/public/xml/rss/module/pingback",
246
+ "https://madskills.com/public/xml/rss/module/pingback"
247
+ ],
248
+ trackback: [
249
+ "http://madskills.com/public/xml/rss/module/trackback/",
250
+ "https://madskills.com/public/xml/rss/module/trackback/",
251
+ "http://madskills.com/public/xml/rss/module/trackback",
252
+ "https://madskills.com/public/xml/rss/module/trackback"
206
253
  ]
207
254
  };
208
255
  const namespacePrefixes = Object.entries(namespaceUris).reduce((prefixes, [prefix, uris]) => {
@@ -19,6 +19,15 @@ const isNonEmptyStringOrNumber = (value) => {
19
19
  const retrieveText = (value) => {
20
20
  return value?.["#text"] ?? value;
21
21
  };
22
+ const retrieveRdfResourceOrText = (value, parse) => {
23
+ if (isObject(value)) {
24
+ const rdfResource = parse(value["@rdf:resource"]);
25
+ if (isPresent(rdfResource)) return rdfResource;
26
+ const resource = parse(value["@resource"]);
27
+ if (isPresent(resource)) return resource;
28
+ }
29
+ return parse(retrieveText(value));
30
+ };
22
31
  const trimObject = (object) => {
23
32
  let result;
24
33
  for (const key in object) {
@@ -213,7 +222,7 @@ const detectNamespaces = (value, recursive = false) => {
213
222
  if (isObject(current)) for (const key in current) {
214
223
  if (seenKeys.has(key)) continue;
215
224
  seenKeys.add(key);
216
- const keyWithoutAt = key.indexOf("@") === 0 ? key.slice(1) : key;
225
+ const keyWithoutAt = key.charCodeAt(0) === 64 ? key.slice(1) : key;
217
226
  const colonIndex = keyWithoutAt.indexOf(":");
218
227
  if (colonIndex > 0) namespaces.add(keyWithoutAt.slice(0, colonIndex));
219
228
  if (recursive) traverse(current[key]);
@@ -222,9 +231,10 @@ const detectNamespaces = (value, recursive = false) => {
222
231
  traverse(value);
223
232
  return namespaces;
224
233
  };
234
+ const cdataSpecialCharsRegex = /[<>&]|]]>/;
225
235
  const generateCdataString = (value) => {
226
236
  if (!isNonEmptyString(value)) return;
227
- if (value.indexOf("<") !== -1 || value.indexOf(">") !== -1 || value.indexOf("&") !== -1 || value.indexOf("]]>") !== -1) return { "#cdata": value.trim() };
237
+ if (cdataSpecialCharsRegex.test(value)) return { "#cdata": value.trim() };
228
238
  return value.trim();
229
239
  };
230
240
  const generateTextOrCdataString = (value) => {
@@ -239,6 +249,11 @@ const generatePlainString = (value) => {
239
249
  const generateNumber = (value) => {
240
250
  if (typeof value === "number" && Number.isFinite(value)) return value;
241
251
  };
252
+ const generateRdfResource = (value, generate) => {
253
+ const rdfResource = generate(value);
254
+ if (!isPresent(rdfResource)) return;
255
+ return { "@rdf:resource": rdfResource };
256
+ };
242
257
  const generateNamespaceAttrs = (value, namespaceUris) => {
243
258
  if (!isObject(value)) return;
244
259
  let namespaceAttrs;
@@ -286,7 +301,7 @@ const createNamespaceNormalizator = (namespaceUris, namespacePrefixes, primaryNa
286
301
  return name;
287
302
  };
288
303
  const normalizeKey = (key, context) => {
289
- if (key.indexOf("@") === 0) return `@${normalizeWithContext(key.substring(1), context, false)}`;
304
+ if (key.charCodeAt(0) === 64) return `@${normalizeWithContext(key.substring(1), context, false)}`;
290
305
  return normalizeWithContext(key, context, true);
291
306
  };
292
307
  const traverseAndNormalize = (object, parentContext = {}) => {
@@ -339,6 +354,7 @@ exports.generateCsvOf = generateCsvOf;
339
354
  exports.generateNamespaceAttrs = generateNamespaceAttrs;
340
355
  exports.generateNumber = generateNumber;
341
356
  exports.generatePlainString = generatePlainString;
357
+ exports.generateRdfResource = generateRdfResource;
342
358
  exports.generateRfc3339Date = generateRfc3339Date;
343
359
  exports.generateRfc822Date = generateRfc822Date;
344
360
  exports.generateSingularOrArray = generateSingularOrArray;
@@ -358,6 +374,7 @@ exports.parseSingular = parseSingular;
358
374
  exports.parseSingularOf = parseSingularOf;
359
375
  exports.parseString = parseString;
360
376
  exports.parseYesNoBoolean = parseYesNoBoolean;
377
+ exports.retrieveRdfResourceOrText = retrieveRdfResourceOrText;
361
378
  exports.retrieveText = retrieveText;
362
379
  exports.trimArray = trimArray;
363
380
  exports.trimObject = trimObject;
@@ -17,6 +17,15 @@ const isNonEmptyStringOrNumber = (value) => {
17
17
  const retrieveText = (value) => {
18
18
  return value?.["#text"] ?? value;
19
19
  };
20
+ const retrieveRdfResourceOrText = (value, parse) => {
21
+ if (isObject(value)) {
22
+ const rdfResource = parse(value["@rdf:resource"]);
23
+ if (isPresent(rdfResource)) return rdfResource;
24
+ const resource = parse(value["@resource"]);
25
+ if (isPresent(resource)) return resource;
26
+ }
27
+ return parse(retrieveText(value));
28
+ };
20
29
  const trimObject = (object) => {
21
30
  let result;
22
31
  for (const key in object) {
@@ -211,7 +220,7 @@ const detectNamespaces = (value, recursive = false) => {
211
220
  if (isObject(current)) for (const key in current) {
212
221
  if (seenKeys.has(key)) continue;
213
222
  seenKeys.add(key);
214
- const keyWithoutAt = key.indexOf("@") === 0 ? key.slice(1) : key;
223
+ const keyWithoutAt = key.charCodeAt(0) === 64 ? key.slice(1) : key;
215
224
  const colonIndex = keyWithoutAt.indexOf(":");
216
225
  if (colonIndex > 0) namespaces.add(keyWithoutAt.slice(0, colonIndex));
217
226
  if (recursive) traverse(current[key]);
@@ -220,9 +229,10 @@ const detectNamespaces = (value, recursive = false) => {
220
229
  traverse(value);
221
230
  return namespaces;
222
231
  };
232
+ const cdataSpecialCharsRegex = /[<>&]|]]>/;
223
233
  const generateCdataString = (value) => {
224
234
  if (!isNonEmptyString(value)) return;
225
- if (value.indexOf("<") !== -1 || value.indexOf(">") !== -1 || value.indexOf("&") !== -1 || value.indexOf("]]>") !== -1) return { "#cdata": value.trim() };
235
+ if (cdataSpecialCharsRegex.test(value)) return { "#cdata": value.trim() };
226
236
  return value.trim();
227
237
  };
228
238
  const generateTextOrCdataString = (value) => {
@@ -237,6 +247,11 @@ const generatePlainString = (value) => {
237
247
  const generateNumber = (value) => {
238
248
  if (typeof value === "number" && Number.isFinite(value)) return value;
239
249
  };
250
+ const generateRdfResource = (value, generate) => {
251
+ const rdfResource = generate(value);
252
+ if (!isPresent(rdfResource)) return;
253
+ return { "@rdf:resource": rdfResource };
254
+ };
240
255
  const generateNamespaceAttrs = (value, namespaceUris) => {
241
256
  if (!isObject(value)) return;
242
257
  let namespaceAttrs;
@@ -284,7 +299,7 @@ const createNamespaceNormalizator = (namespaceUris, namespacePrefixes, primaryNa
284
299
  return name;
285
300
  };
286
301
  const normalizeKey = (key, context) => {
287
- if (key.indexOf("@") === 0) return `@${normalizeWithContext(key.substring(1), context, false)}`;
302
+ if (key.charCodeAt(0) === 64) return `@${normalizeWithContext(key.substring(1), context, false)}`;
288
303
  return normalizeWithContext(key, context, true);
289
304
  };
290
305
  const traverseAndNormalize = (object, parentContext = {}) => {
@@ -328,4 +343,4 @@ const createNamespaceNormalizator = (namespaceUris, namespacePrefixes, primaryNa
328
343
  };
329
344
 
330
345
  //#endregion
331
- export { createNamespaceNormalizator, detectNamespaces, generateArrayOrSingular, generateBoolean, generateCdataString, generateCsvOf, generateNamespaceAttrs, generateNumber, generatePlainString, generateRfc3339Date, generateRfc822Date, generateSingularOrArray, generateTextOrCdataString, generateXml, generateYesNoBoolean, isNonEmptyString, isNonEmptyStringOrNumber, isObject, isPresent, parseArrayOf, parseBoolean, parseCsvOf, parseDate, parseNumber, parseSingular, parseSingularOf, parseString, parseYesNoBoolean, retrieveText, trimArray, trimObject };
346
+ export { createNamespaceNormalizator, detectNamespaces, generateArrayOrSingular, generateBoolean, generateCdataString, generateCsvOf, generateNamespaceAttrs, generateNumber, generatePlainString, generateRdfResource, generateRfc3339Date, generateRfc822Date, generateSingularOrArray, generateTextOrCdataString, generateXml, generateYesNoBoolean, isNonEmptyString, isNonEmptyStringOrNumber, isObject, isPresent, parseArrayOf, parseBoolean, parseCsvOf, parseDate, parseNumber, parseSingular, parseSingularOf, parseString, parseYesNoBoolean, retrieveRdfResourceOrText, retrieveText, trimArray, trimObject };
@@ -1,15 +1,23 @@
1
1
  import { DateLike } from "../../../common/types.cjs";
2
+ import { AdminNs } from "../../../namespaces/admin/common/types.cjs";
3
+ import { AppNs } from "../../../namespaces/app/common/types.cjs";
4
+ import { ArxivNs } from "../../../namespaces/arxiv/common/types.cjs";
2
5
  import { CcNs } from "../../../namespaces/cc/common/types.cjs";
3
- import { CreativecommonsNs } from "../../../namespaces/creativecommons/common/types.cjs";
6
+ import { CreativeCommonsNs } from "../../../namespaces/creativecommons/common/types.cjs";
4
7
  import { DcNs } from "../../../namespaces/dc/common/types.cjs";
5
- import { DctermsNs } from "../../../namespaces/dcterms/common/types.cjs";
6
- import { GeorssNs } from "../../../namespaces/georss/common/types.cjs";
8
+ import { DcTermsNs } from "../../../namespaces/dcterms/common/types.cjs";
9
+ import { GeoNs } from "../../../namespaces/geo/common/types.cjs";
10
+ import { GeoRssNs } from "../../../namespaces/georss/common/types.cjs";
11
+ import { GooglePlayNs } from "../../../namespaces/googleplay/common/types.cjs";
7
12
  import { ItunesNs } from "../../../namespaces/itunes/common/types.cjs";
8
13
  import { MediaNs } from "../../../namespaces/media/common/types.cjs";
14
+ import { OpenSearchNs } from "../../../namespaces/opensearch/common/types.cjs";
15
+ import { PingbackNs } from "../../../namespaces/pingback/common/types.cjs";
9
16
  import { PscNs } from "../../../namespaces/psc/common/types.cjs";
10
17
  import { SlashNs } from "../../../namespaces/slash/common/types.cjs";
11
18
  import { SyNs } from "../../../namespaces/sy/common/types.cjs";
12
19
  import { ThrNs } from "../../../namespaces/thr/common/types.cjs";
20
+ import { TrackbackNs } from "../../../namespaces/trackback/common/types.cjs";
13
21
  import { WfwNs } from "../../../namespaces/wfw/common/types.cjs";
14
22
  import { YtNs } from "../../../namespaces/yt/common/types.cjs";
15
23
 
@@ -30,6 +38,7 @@ declare namespace Atom {
30
38
  name: string;
31
39
  uri?: string;
32
40
  email?: string;
41
+ arxiv?: ArxivNs.Author;
33
42
  };
34
43
  type Category = {
35
44
  term: string;
@@ -68,18 +77,24 @@ declare namespace Atom {
68
77
  summary?: Text;
69
78
  title: Text;
70
79
  updated: TDate;
80
+ app?: AppNs.Entry<TDate>;
81
+ arxiv?: ArxivNs.Entry;
71
82
  cc?: CcNs.ItemOrFeed;
72
83
  dc?: DcNs.ItemOrFeed<TDate>;
73
84
  slash?: SlashNs.Item;
74
85
  itunes?: ItunesNs.Item;
86
+ googleplay?: GooglePlayNs.Item;
75
87
  psc?: PscNs.Item;
76
88
  media?: MediaNs.ItemOrFeed;
77
- georss?: GeorssNs.ItemOrFeed;
89
+ georss?: GeoRssNs.ItemOrFeed;
90
+ geo?: GeoNs.ItemOrFeed;
78
91
  thr?: ThrNs.Item;
79
- dcterms?: DctermsNs.ItemOrFeed<TDate>;
80
- creativeCommons?: CreativecommonsNs.ItemOrFeed;
92
+ dcterms?: DcTermsNs.ItemOrFeed<TDate>;
93
+ creativeCommons?: CreativeCommonsNs.ItemOrFeed;
81
94
  wfw?: WfwNs.Item;
82
95
  yt?: YtNs.Item;
96
+ pingback?: PingbackNs.Item;
97
+ trackback?: TrackbackNs.Item;
83
98
  };
84
99
  type Feed<TDate extends DateLike> = {
85
100
  authors?: Array<Person>;
@@ -99,11 +114,16 @@ declare namespace Atom {
99
114
  dc?: DcNs.ItemOrFeed<TDate>;
100
115
  sy?: SyNs.Feed<TDate>;
101
116
  itunes?: ItunesNs.Feed;
117
+ googleplay?: GooglePlayNs.Feed;
102
118
  media?: MediaNs.ItemOrFeed;
103
- georss?: GeorssNs.ItemOrFeed;
104
- dcterms?: DctermsNs.ItemOrFeed<TDate>;
105
- creativeCommons?: CreativecommonsNs.ItemOrFeed;
119
+ georss?: GeoRssNs.ItemOrFeed;
120
+ geo?: GeoNs.ItemOrFeed;
121
+ dcterms?: DcTermsNs.ItemOrFeed<TDate>;
122
+ creativeCommons?: CreativeCommonsNs.ItemOrFeed;
123
+ opensearch?: OpenSearchNs.Feed;
106
124
  yt?: YtNs.Feed;
125
+ admin?: AdminNs.Feed;
126
+ pingback?: PingbackNs.Feed;
107
127
  };
108
128
  }
109
129
  //#endregion
@@ -1,15 +1,23 @@
1
1
  import { DateLike } from "../../../common/types.js";
2
+ import { AdminNs } from "../../../namespaces/admin/common/types.js";
3
+ import { AppNs } from "../../../namespaces/app/common/types.js";
4
+ import { ArxivNs } from "../../../namespaces/arxiv/common/types.js";
2
5
  import { CcNs } from "../../../namespaces/cc/common/types.js";
3
- import { CreativecommonsNs } from "../../../namespaces/creativecommons/common/types.js";
6
+ import { CreativeCommonsNs } from "../../../namespaces/creativecommons/common/types.js";
4
7
  import { DcNs } from "../../../namespaces/dc/common/types.js";
5
- import { DctermsNs } from "../../../namespaces/dcterms/common/types.js";
6
- import { GeorssNs } from "../../../namespaces/georss/common/types.js";
8
+ import { DcTermsNs } from "../../../namespaces/dcterms/common/types.js";
9
+ import { GeoNs } from "../../../namespaces/geo/common/types.js";
10
+ import { GeoRssNs } from "../../../namespaces/georss/common/types.js";
11
+ import { GooglePlayNs } from "../../../namespaces/googleplay/common/types.js";
7
12
  import { ItunesNs } from "../../../namespaces/itunes/common/types.js";
8
13
  import { MediaNs } from "../../../namespaces/media/common/types.js";
14
+ import { OpenSearchNs } from "../../../namespaces/opensearch/common/types.js";
15
+ import { PingbackNs } from "../../../namespaces/pingback/common/types.js";
9
16
  import { PscNs } from "../../../namespaces/psc/common/types.js";
10
17
  import { SlashNs } from "../../../namespaces/slash/common/types.js";
11
18
  import { SyNs } from "../../../namespaces/sy/common/types.js";
12
19
  import { ThrNs } from "../../../namespaces/thr/common/types.js";
20
+ import { TrackbackNs } from "../../../namespaces/trackback/common/types.js";
13
21
  import { WfwNs } from "../../../namespaces/wfw/common/types.js";
14
22
  import { YtNs } from "../../../namespaces/yt/common/types.js";
15
23
 
@@ -30,6 +38,7 @@ declare namespace Atom {
30
38
  name: string;
31
39
  uri?: string;
32
40
  email?: string;
41
+ arxiv?: ArxivNs.Author;
33
42
  };
34
43
  type Category = {
35
44
  term: string;
@@ -68,18 +77,24 @@ declare namespace Atom {
68
77
  summary?: Text;
69
78
  title: Text;
70
79
  updated: TDate;
80
+ app?: AppNs.Entry<TDate>;
81
+ arxiv?: ArxivNs.Entry;
71
82
  cc?: CcNs.ItemOrFeed;
72
83
  dc?: DcNs.ItemOrFeed<TDate>;
73
84
  slash?: SlashNs.Item;
74
85
  itunes?: ItunesNs.Item;
86
+ googleplay?: GooglePlayNs.Item;
75
87
  psc?: PscNs.Item;
76
88
  media?: MediaNs.ItemOrFeed;
77
- georss?: GeorssNs.ItemOrFeed;
89
+ georss?: GeoRssNs.ItemOrFeed;
90
+ geo?: GeoNs.ItemOrFeed;
78
91
  thr?: ThrNs.Item;
79
- dcterms?: DctermsNs.ItemOrFeed<TDate>;
80
- creativeCommons?: CreativecommonsNs.ItemOrFeed;
92
+ dcterms?: DcTermsNs.ItemOrFeed<TDate>;
93
+ creativeCommons?: CreativeCommonsNs.ItemOrFeed;
81
94
  wfw?: WfwNs.Item;
82
95
  yt?: YtNs.Item;
96
+ pingback?: PingbackNs.Item;
97
+ trackback?: TrackbackNs.Item;
83
98
  };
84
99
  type Feed<TDate extends DateLike> = {
85
100
  authors?: Array<Person>;
@@ -99,11 +114,16 @@ declare namespace Atom {
99
114
  dc?: DcNs.ItemOrFeed<TDate>;
100
115
  sy?: SyNs.Feed<TDate>;
101
116
  itunes?: ItunesNs.Feed;
117
+ googleplay?: GooglePlayNs.Feed;
102
118
  media?: MediaNs.ItemOrFeed;
103
- georss?: GeorssNs.ItemOrFeed;
104
- dcterms?: DctermsNs.ItemOrFeed<TDate>;
105
- creativeCommons?: CreativecommonsNs.ItemOrFeed;
119
+ georss?: GeoRssNs.ItemOrFeed;
120
+ geo?: GeoNs.ItemOrFeed;
121
+ dcterms?: DcTermsNs.ItemOrFeed<TDate>;
122
+ creativeCommons?: CreativeCommonsNs.ItemOrFeed;
123
+ opensearch?: OpenSearchNs.Feed;
106
124
  yt?: YtNs.Feed;
125
+ admin?: AdminNs.Feed;
126
+ pingback?: PingbackNs.Feed;
107
127
  };
108
128
  }
109
129
  //#endregion
@@ -3,7 +3,7 @@ const require_utils = require('../../../common/utils.cjs');
3
3
  //#region src/feeds/atom/detect/index.ts
4
4
  const detect = (value) => {
5
5
  if (!require_utils.isNonEmptyString(value)) return false;
6
- if (!/(?:^|\s|>)\s*<(?:\w+:)?feed[\s>]/im.test(value)) return false;
6
+ if (!/(?:^|[\s>])<(?:\w+:)?feed[\s>]/im.test(value)) return false;
7
7
  const hasAtomNamespace = value.includes("http://www.w3.org/2005/Atom");
8
8
  const hasAtomElements = /(<(?:\w+:)?(entry|title|link|id|updated|summary)[\s>])/i.test(value);
9
9
  return hasAtomNamespace || hasAtomElements;
@@ -3,7 +3,7 @@ import { isNonEmptyString } from "../../../common/utils.js";
3
3
  //#region src/feeds/atom/detect/index.ts
4
4
  const detect = (value) => {
5
5
  if (!isNonEmptyString(value)) return false;
6
- if (!/(?:^|\s|>)\s*<(?:\w+:)?feed[\s>]/im.test(value)) return false;
6
+ if (!/(?:^|[\s>])<(?:\w+:)?feed[\s>]/im.test(value)) return false;
7
7
  const hasAtomNamespace = value.includes("http://www.w3.org/2005/Atom");
8
8
  const hasAtomElements = /(<(?:\w+:)?(entry|title|link|id|updated|summary)[\s>])/i.test(value);
9
9
  return hasAtomNamespace || hasAtomElements;