feedsmith 2.2.1 → 2.3.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/README.md +2 -0
- package/dist/common/config.cjs +64 -11
- package/dist/common/config.js +64 -12
- package/dist/common/types.d.cts +5 -5
- package/dist/common/types.d.ts +5 -5
- package/dist/common/utils.cjs +23 -21
- package/dist/common/utils.js +22 -22
- package/dist/feeds/atom/common/types.d.cts +6 -0
- package/dist/feeds/atom/common/types.d.ts +6 -0
- package/dist/feeds/atom/generate/utils.cjs +35 -29
- package/dist/feeds/atom/generate/utils.js +18 -12
- package/dist/feeds/atom/parse/index.cjs +1 -1
- package/dist/feeds/atom/parse/index.js +2 -2
- package/dist/feeds/atom/parse/utils.cjs +35 -29
- package/dist/feeds/atom/parse/utils.js +18 -12
- package/dist/feeds/rdf/parse/index.cjs +1 -1
- package/dist/feeds/rdf/parse/index.js +2 -2
- package/dist/feeds/rss/common/types.d.cts +7 -0
- package/dist/feeds/rss/common/types.d.ts +7 -0
- package/dist/feeds/rss/generate/utils.cjs +52 -45
- package/dist/feeds/rss/generate/utils.js +27 -20
- package/dist/feeds/rss/parse/index.cjs +1 -1
- package/dist/feeds/rss/parse/index.js +2 -2
- package/dist/feeds/rss/parse/utils.cjs +50 -43
- package/dist/feeds/rss/parse/utils.js +25 -18
- package/dist/namespaces/cc/common/types.d.cts +18 -0
- package/dist/namespaces/cc/common/types.d.ts +18 -0
- package/dist/namespaces/cc/generate/utils.cjs +22 -0
- package/dist/namespaces/cc/generate/utils.js +22 -0
- package/dist/namespaces/cc/parse/utils.cjs +29 -0
- package/dist/namespaces/cc/parse/utils.js +29 -0
- package/dist/namespaces/creativecommons/common/types.d.cts +8 -0
- package/dist/namespaces/creativecommons/common/types.d.ts +8 -0
- package/dist/namespaces/creativecommons/generate/utils.cjs +10 -0
- package/dist/namespaces/creativecommons/generate/utils.js +10 -0
- package/dist/namespaces/creativecommons/parse/utils.cjs +10 -0
- package/dist/namespaces/creativecommons/parse/utils.js +10 -0
- package/dist/namespaces/itunes/common/types.d.cts +2 -1
- package/dist/namespaces/itunes/common/types.d.ts +2 -1
- package/dist/namespaces/itunes/generate/utils.cjs +1 -0
- package/dist/namespaces/itunes/generate/utils.js +1 -0
- package/dist/namespaces/itunes/parse/utils.cjs +1 -0
- package/dist/namespaces/itunes/parse/utils.js +1 -0
- package/dist/namespaces/media/common/types.d.cts +5 -3
- package/dist/namespaces/media/common/types.d.ts +5 -3
- package/dist/namespaces/media/generate/utils.cjs +1 -1
- package/dist/namespaces/media/generate/utils.js +2 -2
- package/dist/namespaces/media/parse/utils.cjs +3 -2
- package/dist/namespaces/media/parse/utils.js +3 -2
- package/dist/namespaces/podcast/common/types.d.cts +17 -5
- package/dist/namespaces/podcast/common/types.d.ts +17 -5
- package/dist/namespaces/podcast/generate/utils.cjs +6 -6
- package/dist/namespaces/podcast/generate/utils.js +7 -7
- package/dist/namespaces/podcast/parse/utils.cjs +12 -6
- package/dist/namespaces/podcast/parse/utils.js +12 -6
- package/dist/namespaces/psc/common/types.d.cts +1 -1
- package/dist/namespaces/psc/common/types.d.ts +1 -1
- package/dist/namespaces/rawvoice/common/types.d.cts +8 -3
- package/dist/namespaces/rawvoice/common/types.d.ts +8 -3
- package/dist/namespaces/rawvoice/generate/utils.cjs +12 -4
- package/dist/namespaces/rawvoice/generate/utils.js +13 -5
- package/dist/namespaces/rawvoice/parse/utils.cjs +12 -4
- package/dist/namespaces/rawvoice/parse/utils.js +13 -5
- package/dist/namespaces/spotify/common/types.d.cts +20 -0
- package/dist/namespaces/spotify/common/types.d.ts +20 -0
- package/dist/namespaces/spotify/generate/utils.cjs +31 -2
- package/dist/namespaces/spotify/generate/utils.js +31 -3
- package/dist/namespaces/spotify/parse/utils.cjs +34 -2
- package/dist/namespaces/spotify/parse/utils.js +34 -3
- package/dist/opml/common/types.d.cts +2 -2
- package/dist/opml/common/types.d.ts +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -83,6 +83,8 @@ Feedsmith aims to fully support all major feed formats and namespaces in complet
|
|
|
83
83
|
| [Dublin Core Terms](http://purl.org/dc/terms/) | `<dcterms:*>` | RSS, Atom, RDF | ✅ | ✅ |
|
|
84
84
|
| [Well-Formed Web](http://wellformedweb.org/CommentAPI/) | `<wfw:*>` | RSS, Atom, RDF | ✅ | ✅ |
|
|
85
85
|
| [Source](http://source.scripting.com/) | `<source:*>` | RSS | ✅ | ✅ |
|
|
86
|
+
| [ccREL](http://creativecommons.org/ns#) | `<cc:*>` | RSS, Atom | ✅ | ✅ |
|
|
87
|
+
| [Creative Commons](http://backend.userland.com/creativeCommonsRssModule) | `<creativeCommons:*>` | RSS, Atom | ✅ | ✅ |
|
|
86
88
|
| [FeedPress](https://feedpress.com/xmlns) | `<feedpress:*>` | RSS | ✅ | ✅ |
|
|
87
89
|
| [YouTube](https://www.youtube.com/feeds/videos.xml) | `<yt:*>` | Atom | ✅ | ✅ |
|
|
88
90
|
|
package/dist/common/config.cjs
CHANGED
|
@@ -36,13 +36,23 @@ const namespaceUris = {
|
|
|
36
36
|
"http://www.w3.org/2005/Atom",
|
|
37
37
|
"https://www.w3.org/2005/Atom",
|
|
38
38
|
"http://www.w3.org/2005/Atom/",
|
|
39
|
-
"https://www.w3.org/2005/Atom/"
|
|
39
|
+
"https://www.w3.org/2005/Atom/",
|
|
40
|
+
"http://purl.org/atom/ns#",
|
|
41
|
+
"https://purl.org/atom/ns#"
|
|
40
42
|
],
|
|
41
43
|
dc: [
|
|
42
44
|
"http://purl.org/dc/elements/1.1/",
|
|
43
45
|
"https://purl.org/dc/elements/1.1/",
|
|
44
46
|
"http://purl.org/dc/elements/1.1",
|
|
45
|
-
"https://purl.org/dc/elements/1.1"
|
|
47
|
+
"https://purl.org/dc/elements/1.1",
|
|
48
|
+
"http://dublincore.org/documents/dcmi-namespace/",
|
|
49
|
+
"https://dublincore.org/documents/dcmi-namespace/",
|
|
50
|
+
"http://dublincore.org/documents/dcmi-namespace",
|
|
51
|
+
"https://dublincore.org/documents/dcmi-namespace",
|
|
52
|
+
"http://purl.org/dc/elements/1.0/",
|
|
53
|
+
"https://purl.org/dc/elements/1.0/",
|
|
54
|
+
"http://purl.org/dc/elements/1.0",
|
|
55
|
+
"https://purl.org/dc/elements/1.0"
|
|
46
56
|
],
|
|
47
57
|
sy: [
|
|
48
58
|
"http://purl.org/rss/1.0/modules/syndication/",
|
|
@@ -56,6 +66,16 @@ const namespaceUris = {
|
|
|
56
66
|
"http://purl.org/rss/1.0/modules/content",
|
|
57
67
|
"https://purl.org/rss/1.0/modules/content"
|
|
58
68
|
],
|
|
69
|
+
creativeCommons: [
|
|
70
|
+
"http://backend.userland.com/creativeCommonsRssModule",
|
|
71
|
+
"https://backend.userland.com/creativeCommonsRssModule",
|
|
72
|
+
"http://backend.userland.com/creativeCommonsRssModule/",
|
|
73
|
+
"https://backend.userland.com/creativeCommonsRssModule/",
|
|
74
|
+
"http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html",
|
|
75
|
+
"https://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html",
|
|
76
|
+
"http://cyber.law.harvard.edu/rss/creativeCommonsRssModule",
|
|
77
|
+
"https://cyber.law.harvard.edu/rss/creativeCommonsRssModule"
|
|
78
|
+
],
|
|
59
79
|
slash: [
|
|
60
80
|
"http://purl.org/rss/1.0/modules/slash/",
|
|
61
81
|
"https://purl.org/rss/1.0/modules/slash/",
|
|
@@ -67,7 +87,8 @@ const namespaceUris = {
|
|
|
67
87
|
"https://podcastindex.org/namespace/1.0",
|
|
68
88
|
"http://podcastindex.org/namespace/1.0",
|
|
69
89
|
"https://podcastindex.org/namespace/1.0/",
|
|
70
|
-
"http://podcastindex.org/namespace/1.0/"
|
|
90
|
+
"http://podcastindex.org/namespace/1.0/",
|
|
91
|
+
"https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md"
|
|
71
92
|
],
|
|
72
93
|
psc: [
|
|
73
94
|
"http://podlove.org/simple-chapters",
|
|
@@ -87,7 +108,15 @@ const namespaceUris = {
|
|
|
87
108
|
"http://www.rssboard.org/media-rss",
|
|
88
109
|
"http://www.rssboard.org/media-rss/",
|
|
89
110
|
"https://www.rssboard.org/media-rss",
|
|
90
|
-
"https://www.rssboard.org/media-rss/"
|
|
111
|
+
"https://www.rssboard.org/media-rss/",
|
|
112
|
+
"http://search.yahoo.com/searchmonkey/media/",
|
|
113
|
+
"https://search.yahoo.com/searchmonkey/media/",
|
|
114
|
+
"http://search.yahoo.com/searchmonkey/media",
|
|
115
|
+
"https://search.yahoo.com/searchmonkey/media",
|
|
116
|
+
"http://tools.search.yahoo.com/mrss/",
|
|
117
|
+
"https://tools.search.yahoo.com/mrss/",
|
|
118
|
+
"http://tools.search.yahoo.com/mrss",
|
|
119
|
+
"https://tools.search.yahoo.com/mrss"
|
|
91
120
|
],
|
|
92
121
|
georss: [
|
|
93
122
|
"http://www.georss.org/georss",
|
|
@@ -99,7 +128,11 @@ const namespaceUris = {
|
|
|
99
128
|
"http://purl.org/syndication/thread/1.0",
|
|
100
129
|
"https://purl.org/syndication/thread/1.0",
|
|
101
130
|
"http://purl.org/syndication/thread/1.0/",
|
|
102
|
-
"https://purl.org/syndication/thread/1.0/"
|
|
131
|
+
"https://purl.org/syndication/thread/1.0/",
|
|
132
|
+
"http://purl.org/rss/1.0/modules/threading/",
|
|
133
|
+
"https://purl.org/rss/1.0/modules/threading/",
|
|
134
|
+
"http://purl.org/rss/1.0/modules/threading",
|
|
135
|
+
"https://purl.org/rss/1.0/modules/threading"
|
|
103
136
|
],
|
|
104
137
|
dcterms: [
|
|
105
138
|
"http://purl.org/dc/terms/",
|
|
@@ -135,7 +168,11 @@ const namespaceUris = {
|
|
|
135
168
|
"https://feedpress.com/xmlns",
|
|
136
169
|
"http://feedpress.com/xmlns",
|
|
137
170
|
"https://feedpress.com/xmlns/",
|
|
138
|
-
"http://feedpress.com/xmlns/"
|
|
171
|
+
"http://feedpress.com/xmlns/",
|
|
172
|
+
"http://feedpress.it/xmlns",
|
|
173
|
+
"https://feedpress.it/xmlns",
|
|
174
|
+
"http://feedpress.it/xmlns/",
|
|
175
|
+
"https://feedpress.it/xmlns/"
|
|
139
176
|
],
|
|
140
177
|
yt: [
|
|
141
178
|
"http://www.youtube.com/xml/schemas/2015",
|
|
@@ -151,19 +188,35 @@ const namespaceUris = {
|
|
|
151
188
|
],
|
|
152
189
|
rdf: ["http://www.w3.org/1999/02/22-rdf-syntax-ns#", "https://www.w3.org/1999/02/22-rdf-syntax-ns#"],
|
|
153
190
|
rawvoice: [
|
|
191
|
+
"http://www.rawvoice.com/rawvoiceRssModule/",
|
|
192
|
+
"https://www.rawvoice.com/rawvoiceRssModule/",
|
|
193
|
+
"http://www.rawvoice.com/rawvoiceRssModule",
|
|
194
|
+
"https://www.rawvoice.com/rawvoiceRssModule",
|
|
154
195
|
"https://blubrry.com/developer/rawvoice-rss",
|
|
155
196
|
"http://blubrry.com/developer/rawvoice-rss",
|
|
156
197
|
"https://blubrry.com/developer/rawvoice-rss/",
|
|
157
|
-
"http://blubrry.com/developer/rawvoice-rss/"
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
"http://
|
|
161
|
-
"https://
|
|
198
|
+
"http://blubrry.com/developer/rawvoice-rss/"
|
|
199
|
+
],
|
|
200
|
+
cc: [
|
|
201
|
+
"http://creativecommons.org/ns#",
|
|
202
|
+
"https://creativecommons.org/ns#",
|
|
203
|
+
"http://web.resource.org/cc/",
|
|
204
|
+
"https://web.resource.org/cc/",
|
|
205
|
+
"http://web.resource.org/cc",
|
|
206
|
+
"https://web.resource.org/cc"
|
|
162
207
|
]
|
|
163
208
|
};
|
|
209
|
+
const namespacePrefixes = Object.entries(namespaceUris).reduce((prefixes, [prefix, uris]) => {
|
|
210
|
+
for (const uri of uris) {
|
|
211
|
+
const normalizedUri = uri.toLowerCase();
|
|
212
|
+
prefixes[normalizedUri] = prefix.toLowerCase();
|
|
213
|
+
}
|
|
214
|
+
return prefixes;
|
|
215
|
+
}, {});
|
|
164
216
|
|
|
165
217
|
//#endregion
|
|
166
218
|
exports.builderConfig = builderConfig;
|
|
167
219
|
exports.locales = locales;
|
|
220
|
+
exports.namespacePrefixes = namespacePrefixes;
|
|
168
221
|
exports.namespaceUris = namespaceUris;
|
|
169
222
|
exports.parserConfig = parserConfig;
|
package/dist/common/config.js
CHANGED
|
@@ -35,13 +35,23 @@ const namespaceUris = {
|
|
|
35
35
|
"http://www.w3.org/2005/Atom",
|
|
36
36
|
"https://www.w3.org/2005/Atom",
|
|
37
37
|
"http://www.w3.org/2005/Atom/",
|
|
38
|
-
"https://www.w3.org/2005/Atom/"
|
|
38
|
+
"https://www.w3.org/2005/Atom/",
|
|
39
|
+
"http://purl.org/atom/ns#",
|
|
40
|
+
"https://purl.org/atom/ns#"
|
|
39
41
|
],
|
|
40
42
|
dc: [
|
|
41
43
|
"http://purl.org/dc/elements/1.1/",
|
|
42
44
|
"https://purl.org/dc/elements/1.1/",
|
|
43
45
|
"http://purl.org/dc/elements/1.1",
|
|
44
|
-
"https://purl.org/dc/elements/1.1"
|
|
46
|
+
"https://purl.org/dc/elements/1.1",
|
|
47
|
+
"http://dublincore.org/documents/dcmi-namespace/",
|
|
48
|
+
"https://dublincore.org/documents/dcmi-namespace/",
|
|
49
|
+
"http://dublincore.org/documents/dcmi-namespace",
|
|
50
|
+
"https://dublincore.org/documents/dcmi-namespace",
|
|
51
|
+
"http://purl.org/dc/elements/1.0/",
|
|
52
|
+
"https://purl.org/dc/elements/1.0/",
|
|
53
|
+
"http://purl.org/dc/elements/1.0",
|
|
54
|
+
"https://purl.org/dc/elements/1.0"
|
|
45
55
|
],
|
|
46
56
|
sy: [
|
|
47
57
|
"http://purl.org/rss/1.0/modules/syndication/",
|
|
@@ -55,6 +65,16 @@ const namespaceUris = {
|
|
|
55
65
|
"http://purl.org/rss/1.0/modules/content",
|
|
56
66
|
"https://purl.org/rss/1.0/modules/content"
|
|
57
67
|
],
|
|
68
|
+
creativeCommons: [
|
|
69
|
+
"http://backend.userland.com/creativeCommonsRssModule",
|
|
70
|
+
"https://backend.userland.com/creativeCommonsRssModule",
|
|
71
|
+
"http://backend.userland.com/creativeCommonsRssModule/",
|
|
72
|
+
"https://backend.userland.com/creativeCommonsRssModule/",
|
|
73
|
+
"http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html",
|
|
74
|
+
"https://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html",
|
|
75
|
+
"http://cyber.law.harvard.edu/rss/creativeCommonsRssModule",
|
|
76
|
+
"https://cyber.law.harvard.edu/rss/creativeCommonsRssModule"
|
|
77
|
+
],
|
|
58
78
|
slash: [
|
|
59
79
|
"http://purl.org/rss/1.0/modules/slash/",
|
|
60
80
|
"https://purl.org/rss/1.0/modules/slash/",
|
|
@@ -66,7 +86,8 @@ const namespaceUris = {
|
|
|
66
86
|
"https://podcastindex.org/namespace/1.0",
|
|
67
87
|
"http://podcastindex.org/namespace/1.0",
|
|
68
88
|
"https://podcastindex.org/namespace/1.0/",
|
|
69
|
-
"http://podcastindex.org/namespace/1.0/"
|
|
89
|
+
"http://podcastindex.org/namespace/1.0/",
|
|
90
|
+
"https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md"
|
|
70
91
|
],
|
|
71
92
|
psc: [
|
|
72
93
|
"http://podlove.org/simple-chapters",
|
|
@@ -86,7 +107,15 @@ const namespaceUris = {
|
|
|
86
107
|
"http://www.rssboard.org/media-rss",
|
|
87
108
|
"http://www.rssboard.org/media-rss/",
|
|
88
109
|
"https://www.rssboard.org/media-rss",
|
|
89
|
-
"https://www.rssboard.org/media-rss/"
|
|
110
|
+
"https://www.rssboard.org/media-rss/",
|
|
111
|
+
"http://search.yahoo.com/searchmonkey/media/",
|
|
112
|
+
"https://search.yahoo.com/searchmonkey/media/",
|
|
113
|
+
"http://search.yahoo.com/searchmonkey/media",
|
|
114
|
+
"https://search.yahoo.com/searchmonkey/media",
|
|
115
|
+
"http://tools.search.yahoo.com/mrss/",
|
|
116
|
+
"https://tools.search.yahoo.com/mrss/",
|
|
117
|
+
"http://tools.search.yahoo.com/mrss",
|
|
118
|
+
"https://tools.search.yahoo.com/mrss"
|
|
90
119
|
],
|
|
91
120
|
georss: [
|
|
92
121
|
"http://www.georss.org/georss",
|
|
@@ -98,7 +127,11 @@ const namespaceUris = {
|
|
|
98
127
|
"http://purl.org/syndication/thread/1.0",
|
|
99
128
|
"https://purl.org/syndication/thread/1.0",
|
|
100
129
|
"http://purl.org/syndication/thread/1.0/",
|
|
101
|
-
"https://purl.org/syndication/thread/1.0/"
|
|
130
|
+
"https://purl.org/syndication/thread/1.0/",
|
|
131
|
+
"http://purl.org/rss/1.0/modules/threading/",
|
|
132
|
+
"https://purl.org/rss/1.0/modules/threading/",
|
|
133
|
+
"http://purl.org/rss/1.0/modules/threading",
|
|
134
|
+
"https://purl.org/rss/1.0/modules/threading"
|
|
102
135
|
],
|
|
103
136
|
dcterms: [
|
|
104
137
|
"http://purl.org/dc/terms/",
|
|
@@ -134,7 +167,11 @@ const namespaceUris = {
|
|
|
134
167
|
"https://feedpress.com/xmlns",
|
|
135
168
|
"http://feedpress.com/xmlns",
|
|
136
169
|
"https://feedpress.com/xmlns/",
|
|
137
|
-
"http://feedpress.com/xmlns/"
|
|
170
|
+
"http://feedpress.com/xmlns/",
|
|
171
|
+
"http://feedpress.it/xmlns",
|
|
172
|
+
"https://feedpress.it/xmlns",
|
|
173
|
+
"http://feedpress.it/xmlns/",
|
|
174
|
+
"https://feedpress.it/xmlns/"
|
|
138
175
|
],
|
|
139
176
|
yt: [
|
|
140
177
|
"http://www.youtube.com/xml/schemas/2015",
|
|
@@ -150,16 +187,31 @@ const namespaceUris = {
|
|
|
150
187
|
],
|
|
151
188
|
rdf: ["http://www.w3.org/1999/02/22-rdf-syntax-ns#", "https://www.w3.org/1999/02/22-rdf-syntax-ns#"],
|
|
152
189
|
rawvoice: [
|
|
190
|
+
"http://www.rawvoice.com/rawvoiceRssModule/",
|
|
191
|
+
"https://www.rawvoice.com/rawvoiceRssModule/",
|
|
192
|
+
"http://www.rawvoice.com/rawvoiceRssModule",
|
|
193
|
+
"https://www.rawvoice.com/rawvoiceRssModule",
|
|
153
194
|
"https://blubrry.com/developer/rawvoice-rss",
|
|
154
195
|
"http://blubrry.com/developer/rawvoice-rss",
|
|
155
196
|
"https://blubrry.com/developer/rawvoice-rss/",
|
|
156
|
-
"http://blubrry.com/developer/rawvoice-rss/"
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
"http://
|
|
160
|
-
"https://
|
|
197
|
+
"http://blubrry.com/developer/rawvoice-rss/"
|
|
198
|
+
],
|
|
199
|
+
cc: [
|
|
200
|
+
"http://creativecommons.org/ns#",
|
|
201
|
+
"https://creativecommons.org/ns#",
|
|
202
|
+
"http://web.resource.org/cc/",
|
|
203
|
+
"https://web.resource.org/cc/",
|
|
204
|
+
"http://web.resource.org/cc",
|
|
205
|
+
"https://web.resource.org/cc"
|
|
161
206
|
]
|
|
162
207
|
};
|
|
208
|
+
const namespacePrefixes = Object.entries(namespaceUris).reduce((prefixes, [prefix, uris]) => {
|
|
209
|
+
for (const uri of uris) {
|
|
210
|
+
const normalizedUri = uri.toLowerCase();
|
|
211
|
+
prefixes[normalizedUri] = prefix.toLowerCase();
|
|
212
|
+
}
|
|
213
|
+
return prefixes;
|
|
214
|
+
}, {});
|
|
163
215
|
|
|
164
216
|
//#endregion
|
|
165
|
-
export { builderConfig, locales, namespaceUris, parserConfig };
|
|
217
|
+
export { builderConfig, locales, namespacePrefixes, namespaceUris, parserConfig };
|
package/dist/common/types.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/common/types.d.ts
|
|
2
2
|
type DateLike = Date | string;
|
|
3
|
-
type ExtraFields<F
|
|
3
|
+
type ExtraFields<F extends ReadonlyArray<string>, V = unknown> = { [K in F[number]]?: V };
|
|
4
4
|
type IsPlainObject<T> = T extends Array<unknown> ? false : T extends ((...args: Array<unknown>) => unknown) ? false : T extends Date ? false : T extends object ? T extends null ? false : true : false;
|
|
5
5
|
type RemoveUndefined<T> = T extends undefined ? never : T;
|
|
6
6
|
type DeepPartial<T> = IsPlainObject<T> extends true ? { [P in keyof T]?: DeepPartial<RemoveUndefined<T[P]>> } : T extends Array<infer U> ? Array<DeepPartial<U>> : T;
|
|
@@ -12,12 +12,12 @@ type XmlStylesheet = {
|
|
|
12
12
|
charset?: string;
|
|
13
13
|
alternate?: boolean;
|
|
14
14
|
};
|
|
15
|
-
type XmlGenerateOptions<O, F
|
|
16
|
-
lenient?: F
|
|
15
|
+
type XmlGenerateOptions<O, F extends boolean = false> = O & {
|
|
16
|
+
lenient?: F;
|
|
17
17
|
stylesheets?: Array<XmlStylesheet>;
|
|
18
18
|
};
|
|
19
|
-
type JsonGenerateOptions<O, F
|
|
20
|
-
lenient?: F
|
|
19
|
+
type JsonGenerateOptions<O, F extends boolean = false> = O & {
|
|
20
|
+
lenient?: F;
|
|
21
21
|
};
|
|
22
22
|
type XmlGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: XmlGenerateOptions<O, F>) => string;
|
|
23
23
|
type JsonGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: JsonGenerateOptions<O, F>) => unknown;
|
package/dist/common/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/common/types.d.ts
|
|
2
2
|
type DateLike = Date | string;
|
|
3
|
-
type ExtraFields<F
|
|
3
|
+
type ExtraFields<F extends ReadonlyArray<string>, V = unknown> = { [K in F[number]]?: V };
|
|
4
4
|
type IsPlainObject<T> = T extends Array<unknown> ? false : T extends ((...args: Array<unknown>) => unknown) ? false : T extends Date ? false : T extends object ? T extends null ? false : true : false;
|
|
5
5
|
type RemoveUndefined<T> = T extends undefined ? never : T;
|
|
6
6
|
type DeepPartial<T> = IsPlainObject<T> extends true ? { [P in keyof T]?: DeepPartial<RemoveUndefined<T[P]>> } : T extends Array<infer U> ? Array<DeepPartial<U>> : T;
|
|
@@ -12,12 +12,12 @@ type XmlStylesheet = {
|
|
|
12
12
|
charset?: string;
|
|
13
13
|
alternate?: boolean;
|
|
14
14
|
};
|
|
15
|
-
type XmlGenerateOptions<O, F
|
|
16
|
-
lenient?: F
|
|
15
|
+
type XmlGenerateOptions<O, F extends boolean = false> = O & {
|
|
16
|
+
lenient?: F;
|
|
17
17
|
stylesheets?: Array<XmlStylesheet>;
|
|
18
18
|
};
|
|
19
|
-
type JsonGenerateOptions<O, F
|
|
20
|
-
lenient?: F
|
|
19
|
+
type JsonGenerateOptions<O, F extends boolean = false> = O & {
|
|
20
|
+
lenient?: F;
|
|
21
21
|
};
|
|
22
22
|
type XmlGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: XmlGenerateOptions<O, F>) => string;
|
|
23
23
|
type JsonGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: JsonGenerateOptions<O, F>) => unknown;
|
package/dist/common/utils.cjs
CHANGED
|
@@ -47,6 +47,14 @@ const trimArray = (value, parse) => {
|
|
|
47
47
|
}
|
|
48
48
|
return result.length > 0 ? result : void 0;
|
|
49
49
|
};
|
|
50
|
+
const generateArrayOrSingular = (pluralValues, singularValue, generator) => {
|
|
51
|
+
if (isPresent(pluralValues)) return trimArray(pluralValues.map(generator));
|
|
52
|
+
if (isPresent(singularValue)) return generator(singularValue);
|
|
53
|
+
};
|
|
54
|
+
const generateSingularOrArray = (singularValue, pluralValues, generator) => {
|
|
55
|
+
if (isPresent(singularValue)) return generator(singularValue);
|
|
56
|
+
if (isPresent(pluralValues)) return trimArray(pluralValues.map(generator));
|
|
57
|
+
};
|
|
50
58
|
const cdataStartTag = "<![CDATA[";
|
|
51
59
|
const cdataEndTag = "]]>";
|
|
52
60
|
const stripCdata = (text) => {
|
|
@@ -235,39 +243,32 @@ const generateNamespaceAttrs = (value, namespaceUris) => {
|
|
|
235
243
|
if (!isObject(value)) return;
|
|
236
244
|
let namespaceAttrs;
|
|
237
245
|
const valueNamespaces = detectNamespaces(value, true);
|
|
238
|
-
for (const
|
|
239
|
-
if (!valueNamespaces.has(
|
|
246
|
+
for (const prefix in namespaceUris) {
|
|
247
|
+
if (!valueNamespaces.has(prefix)) continue;
|
|
240
248
|
if (!namespaceAttrs) namespaceAttrs = {};
|
|
241
|
-
namespaceAttrs[`@xmlns:${
|
|
249
|
+
namespaceAttrs[`@xmlns:${prefix}`] = namespaceUris[prefix][0];
|
|
242
250
|
}
|
|
243
251
|
return namespaceAttrs;
|
|
244
252
|
};
|
|
245
|
-
const createNamespaceNormalizator = (namespaceUris, primaryNamespace) => {
|
|
246
|
-
const
|
|
253
|
+
const createNamespaceNormalizator = (namespaceUris, namespacePrefixes, primaryNamespace) => {
|
|
254
|
+
const normalizeNamespaceUri = (uri) => {
|
|
247
255
|
return typeof uri === "string" ? uri.trim().toLowerCase() : uri;
|
|
248
256
|
};
|
|
249
|
-
const
|
|
250
|
-
for (const prefix in namespaceUris) {
|
|
251
|
-
const uris = namespaceUris[prefix];
|
|
252
|
-
for (const uri of uris) {
|
|
253
|
-
const normalizedUri = normalizeUri(uri);
|
|
254
|
-
namespacesMap[normalizedUri] = prefix;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
+
const primaryNamespaceUris = primaryNamespace && namespaceUris[primaryNamespace] ? namespaceUris[primaryNamespace].map(normalizeNamespaceUri) : void 0;
|
|
257
258
|
const resolveNamespacePrefix = (uri, localName, fallback) => {
|
|
258
|
-
const normalizedUri =
|
|
259
|
-
if (
|
|
260
|
-
const standardPrefix =
|
|
259
|
+
const normalizedUri = normalizeNamespaceUri(uri);
|
|
260
|
+
if (primaryNamespaceUris?.includes(normalizedUri)) return localName;
|
|
261
|
+
const standardPrefix = namespacePrefixes[normalizedUri];
|
|
261
262
|
if (standardPrefix) return `${standardPrefix}:${localName}`;
|
|
262
263
|
return fallback;
|
|
263
264
|
};
|
|
264
265
|
const extractNamespaceDeclarations = (element) => {
|
|
265
266
|
const declarations = {};
|
|
266
267
|
if (isObject(element)) {
|
|
267
|
-
for (const key in element) if (key === "@xmlns") declarations[""] =
|
|
268
|
+
for (const key in element) if (key === "@xmlns") declarations[""] = normalizeNamespaceUri(element[key]);
|
|
268
269
|
else if (key.indexOf("@xmlns:") === 0) {
|
|
269
270
|
const prefix = key.substring(7);
|
|
270
|
-
declarations[prefix] =
|
|
271
|
+
declarations[prefix] = normalizeNamespaceUri(element[key]);
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
return declarations;
|
|
@@ -286,7 +287,7 @@ const createNamespaceNormalizator = (namespaceUris, primaryNamespace) => {
|
|
|
286
287
|
};
|
|
287
288
|
const normalizeKey = (key, context) => {
|
|
288
289
|
if (key.indexOf("@") === 0) return `@${normalizeWithContext(key.substring(1), context, false)}`;
|
|
289
|
-
|
|
290
|
+
return normalizeWithContext(key, context, true);
|
|
290
291
|
};
|
|
291
292
|
const traverseAndNormalize = (object, parentContext = {}) => {
|
|
292
293
|
if (!isObject(object)) return object;
|
|
@@ -310,8 +311,7 @@ const createNamespaceNormalizator = (namespaceUris, primaryNamespace) => {
|
|
|
310
311
|
const group = keyGroups.get(normalizedKey);
|
|
311
312
|
if (group) group.push(normalizedValue);
|
|
312
313
|
}
|
|
313
|
-
for (const [normalizedKey, values] of keyGroups)
|
|
314
|
-
else normalizedObject[normalizedKey] = values;
|
|
314
|
+
for (const [normalizedKey, values] of keyGroups) normalizedObject[normalizedKey] = values.length === 1 ? values[0] : values;
|
|
315
315
|
return normalizedObject;
|
|
316
316
|
};
|
|
317
317
|
const normalizeRoot = (object) => {
|
|
@@ -332,6 +332,7 @@ const createNamespaceNormalizator = (namespaceUris, primaryNamespace) => {
|
|
|
332
332
|
//#endregion
|
|
333
333
|
exports.createNamespaceNormalizator = createNamespaceNormalizator;
|
|
334
334
|
exports.detectNamespaces = detectNamespaces;
|
|
335
|
+
exports.generateArrayOrSingular = generateArrayOrSingular;
|
|
335
336
|
exports.generateBoolean = generateBoolean;
|
|
336
337
|
exports.generateCdataString = generateCdataString;
|
|
337
338
|
exports.generateCsvOf = generateCsvOf;
|
|
@@ -340,6 +341,7 @@ exports.generateNumber = generateNumber;
|
|
|
340
341
|
exports.generatePlainString = generatePlainString;
|
|
341
342
|
exports.generateRfc3339Date = generateRfc3339Date;
|
|
342
343
|
exports.generateRfc822Date = generateRfc822Date;
|
|
344
|
+
exports.generateSingularOrArray = generateSingularOrArray;
|
|
343
345
|
exports.generateTextOrCdataString = generateTextOrCdataString;
|
|
344
346
|
exports.generateXml = generateXml;
|
|
345
347
|
exports.generateYesNoBoolean = generateYesNoBoolean;
|
package/dist/common/utils.js
CHANGED
|
@@ -45,6 +45,14 @@ const trimArray = (value, parse) => {
|
|
|
45
45
|
}
|
|
46
46
|
return result.length > 0 ? result : void 0;
|
|
47
47
|
};
|
|
48
|
+
const generateArrayOrSingular = (pluralValues, singularValue, generator) => {
|
|
49
|
+
if (isPresent(pluralValues)) return trimArray(pluralValues.map(generator));
|
|
50
|
+
if (isPresent(singularValue)) return generator(singularValue);
|
|
51
|
+
};
|
|
52
|
+
const generateSingularOrArray = (singularValue, pluralValues, generator) => {
|
|
53
|
+
if (isPresent(singularValue)) return generator(singularValue);
|
|
54
|
+
if (isPresent(pluralValues)) return trimArray(pluralValues.map(generator));
|
|
55
|
+
};
|
|
48
56
|
const cdataStartTag = "<![CDATA[";
|
|
49
57
|
const cdataEndTag = "]]>";
|
|
50
58
|
const stripCdata = (text) => {
|
|
@@ -233,39 +241,32 @@ const generateNamespaceAttrs = (value, namespaceUris) => {
|
|
|
233
241
|
if (!isObject(value)) return;
|
|
234
242
|
let namespaceAttrs;
|
|
235
243
|
const valueNamespaces = detectNamespaces(value, true);
|
|
236
|
-
for (const
|
|
237
|
-
if (!valueNamespaces.has(
|
|
244
|
+
for (const prefix in namespaceUris) {
|
|
245
|
+
if (!valueNamespaces.has(prefix)) continue;
|
|
238
246
|
if (!namespaceAttrs) namespaceAttrs = {};
|
|
239
|
-
namespaceAttrs[`@xmlns:${
|
|
247
|
+
namespaceAttrs[`@xmlns:${prefix}`] = namespaceUris[prefix][0];
|
|
240
248
|
}
|
|
241
249
|
return namespaceAttrs;
|
|
242
250
|
};
|
|
243
|
-
const createNamespaceNormalizator = (namespaceUris, primaryNamespace) => {
|
|
244
|
-
const
|
|
251
|
+
const createNamespaceNormalizator = (namespaceUris, namespacePrefixes, primaryNamespace) => {
|
|
252
|
+
const normalizeNamespaceUri = (uri) => {
|
|
245
253
|
return typeof uri === "string" ? uri.trim().toLowerCase() : uri;
|
|
246
254
|
};
|
|
247
|
-
const
|
|
248
|
-
for (const prefix in namespaceUris) {
|
|
249
|
-
const uris = namespaceUris[prefix];
|
|
250
|
-
for (const uri of uris) {
|
|
251
|
-
const normalizedUri = normalizeUri(uri);
|
|
252
|
-
namespacesMap[normalizedUri] = prefix;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
+
const primaryNamespaceUris = primaryNamespace && namespaceUris[primaryNamespace] ? namespaceUris[primaryNamespace].map(normalizeNamespaceUri) : void 0;
|
|
255
256
|
const resolveNamespacePrefix = (uri, localName, fallback) => {
|
|
256
|
-
const normalizedUri =
|
|
257
|
-
if (
|
|
258
|
-
const standardPrefix =
|
|
257
|
+
const normalizedUri = normalizeNamespaceUri(uri);
|
|
258
|
+
if (primaryNamespaceUris?.includes(normalizedUri)) return localName;
|
|
259
|
+
const standardPrefix = namespacePrefixes[normalizedUri];
|
|
259
260
|
if (standardPrefix) return `${standardPrefix}:${localName}`;
|
|
260
261
|
return fallback;
|
|
261
262
|
};
|
|
262
263
|
const extractNamespaceDeclarations = (element) => {
|
|
263
264
|
const declarations = {};
|
|
264
265
|
if (isObject(element)) {
|
|
265
|
-
for (const key in element) if (key === "@xmlns") declarations[""] =
|
|
266
|
+
for (const key in element) if (key === "@xmlns") declarations[""] = normalizeNamespaceUri(element[key]);
|
|
266
267
|
else if (key.indexOf("@xmlns:") === 0) {
|
|
267
268
|
const prefix = key.substring(7);
|
|
268
|
-
declarations[prefix] =
|
|
269
|
+
declarations[prefix] = normalizeNamespaceUri(element[key]);
|
|
269
270
|
}
|
|
270
271
|
}
|
|
271
272
|
return declarations;
|
|
@@ -284,7 +285,7 @@ const createNamespaceNormalizator = (namespaceUris, primaryNamespace) => {
|
|
|
284
285
|
};
|
|
285
286
|
const normalizeKey = (key, context) => {
|
|
286
287
|
if (key.indexOf("@") === 0) return `@${normalizeWithContext(key.substring(1), context, false)}`;
|
|
287
|
-
|
|
288
|
+
return normalizeWithContext(key, context, true);
|
|
288
289
|
};
|
|
289
290
|
const traverseAndNormalize = (object, parentContext = {}) => {
|
|
290
291
|
if (!isObject(object)) return object;
|
|
@@ -308,8 +309,7 @@ const createNamespaceNormalizator = (namespaceUris, primaryNamespace) => {
|
|
|
308
309
|
const group = keyGroups.get(normalizedKey);
|
|
309
310
|
if (group) group.push(normalizedValue);
|
|
310
311
|
}
|
|
311
|
-
for (const [normalizedKey, values] of keyGroups)
|
|
312
|
-
else normalizedObject[normalizedKey] = values;
|
|
312
|
+
for (const [normalizedKey, values] of keyGroups) normalizedObject[normalizedKey] = values.length === 1 ? values[0] : values;
|
|
313
313
|
return normalizedObject;
|
|
314
314
|
};
|
|
315
315
|
const normalizeRoot = (object) => {
|
|
@@ -328,4 +328,4 @@ const createNamespaceNormalizator = (namespaceUris, primaryNamespace) => {
|
|
|
328
328
|
};
|
|
329
329
|
|
|
330
330
|
//#endregion
|
|
331
|
-
export { createNamespaceNormalizator, detectNamespaces, generateBoolean, generateCdataString, generateCsvOf, generateNamespaceAttrs, generateNumber, generatePlainString, generateRfc3339Date, generateRfc822Date, generateTextOrCdataString, generateXml, generateYesNoBoolean, isNonEmptyString, isNonEmptyStringOrNumber, isObject, isPresent, parseArrayOf, parseBoolean, parseCsvOf, parseDate, parseNumber, parseSingular, parseSingularOf, parseString, parseYesNoBoolean, retrieveText, trimArray, trimObject };
|
|
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 };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { DateLike } from "../../../common/types.cjs";
|
|
2
|
+
import { CcNs } from "../../../namespaces/cc/common/types.cjs";
|
|
3
|
+
import { CreativecommonsNs } from "../../../namespaces/creativecommons/common/types.cjs";
|
|
2
4
|
import { DcNs } from "../../../namespaces/dc/common/types.cjs";
|
|
3
5
|
import { DctermsNs } from "../../../namespaces/dcterms/common/types.cjs";
|
|
4
6
|
import { GeorssNs } from "../../../namespaces/georss/common/types.cjs";
|
|
@@ -66,6 +68,7 @@ declare namespace Atom {
|
|
|
66
68
|
summary?: Text;
|
|
67
69
|
title: Text;
|
|
68
70
|
updated: TDate;
|
|
71
|
+
cc?: CcNs.ItemOrFeed;
|
|
69
72
|
dc?: DcNs.ItemOrFeed<TDate>;
|
|
70
73
|
slash?: SlashNs.Item;
|
|
71
74
|
itunes?: ItunesNs.Item;
|
|
@@ -74,6 +77,7 @@ declare namespace Atom {
|
|
|
74
77
|
georss?: GeorssNs.ItemOrFeed;
|
|
75
78
|
thr?: ThrNs.Item;
|
|
76
79
|
dcterms?: DctermsNs.ItemOrFeed<TDate>;
|
|
80
|
+
creativeCommons?: CreativecommonsNs.ItemOrFeed;
|
|
77
81
|
wfw?: WfwNs.Item;
|
|
78
82
|
yt?: YtNs.Item;
|
|
79
83
|
};
|
|
@@ -91,12 +95,14 @@ declare namespace Atom {
|
|
|
91
95
|
title: Text;
|
|
92
96
|
updated: TDate;
|
|
93
97
|
entries?: Array<Entry<TDate>>;
|
|
98
|
+
cc?: CcNs.ItemOrFeed;
|
|
94
99
|
dc?: DcNs.ItemOrFeed<TDate>;
|
|
95
100
|
sy?: SyNs.Feed<TDate>;
|
|
96
101
|
itunes?: ItunesNs.Feed;
|
|
97
102
|
media?: MediaNs.ItemOrFeed;
|
|
98
103
|
georss?: GeorssNs.ItemOrFeed;
|
|
99
104
|
dcterms?: DctermsNs.ItemOrFeed<TDate>;
|
|
105
|
+
creativeCommons?: CreativecommonsNs.ItemOrFeed;
|
|
100
106
|
yt?: YtNs.Feed;
|
|
101
107
|
};
|
|
102
108
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { DateLike } from "../../../common/types.js";
|
|
2
|
+
import { CcNs } from "../../../namespaces/cc/common/types.js";
|
|
3
|
+
import { CreativecommonsNs } from "../../../namespaces/creativecommons/common/types.js";
|
|
2
4
|
import { DcNs } from "../../../namespaces/dc/common/types.js";
|
|
3
5
|
import { DctermsNs } from "../../../namespaces/dcterms/common/types.js";
|
|
4
6
|
import { GeorssNs } from "../../../namespaces/georss/common/types.js";
|
|
@@ -66,6 +68,7 @@ declare namespace Atom {
|
|
|
66
68
|
summary?: Text;
|
|
67
69
|
title: Text;
|
|
68
70
|
updated: TDate;
|
|
71
|
+
cc?: CcNs.ItemOrFeed;
|
|
69
72
|
dc?: DcNs.ItemOrFeed<TDate>;
|
|
70
73
|
slash?: SlashNs.Item;
|
|
71
74
|
itunes?: ItunesNs.Item;
|
|
@@ -74,6 +77,7 @@ declare namespace Atom {
|
|
|
74
77
|
georss?: GeorssNs.ItemOrFeed;
|
|
75
78
|
thr?: ThrNs.Item;
|
|
76
79
|
dcterms?: DctermsNs.ItemOrFeed<TDate>;
|
|
80
|
+
creativeCommons?: CreativecommonsNs.ItemOrFeed;
|
|
77
81
|
wfw?: WfwNs.Item;
|
|
78
82
|
yt?: YtNs.Item;
|
|
79
83
|
};
|
|
@@ -91,12 +95,14 @@ declare namespace Atom {
|
|
|
91
95
|
title: Text;
|
|
92
96
|
updated: TDate;
|
|
93
97
|
entries?: Array<Entry<TDate>>;
|
|
98
|
+
cc?: CcNs.ItemOrFeed;
|
|
94
99
|
dc?: DcNs.ItemOrFeed<TDate>;
|
|
95
100
|
sy?: SyNs.Feed<TDate>;
|
|
96
101
|
itunes?: ItunesNs.Feed;
|
|
97
102
|
media?: MediaNs.ItemOrFeed;
|
|
98
103
|
georss?: GeorssNs.ItemOrFeed;
|
|
99
104
|
dcterms?: DctermsNs.ItemOrFeed<TDate>;
|
|
105
|
+
creativeCommons?: CreativecommonsNs.ItemOrFeed;
|
|
100
106
|
yt?: YtNs.Feed;
|
|
101
107
|
};
|
|
102
108
|
}
|