@molecule/api-feed-rss 1.0.1 → 1.0.3
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/LICENSE +111 -24
- package/README.md +244 -231
- package/package.json +5 -4
package/LICENSE
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
Apache License
|
|
2
3
|
Version 2.0, January 2004
|
|
3
4
|
http://www.apache.org/licenses/
|
|
@@ -34,21 +35,33 @@
|
|
|
34
35
|
|
|
35
36
|
"Work" shall mean the work of authorship, whether in Source or
|
|
36
37
|
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
38
40
|
|
|
39
41
|
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
42
|
form, that is based on (or derived from) the Work and for which the
|
|
41
43
|
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
-
represent, as a whole, an original work of authorship.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
49
62
|
|
|
50
63
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
51
|
-
on behalf of whom a Contribution has been received by
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
52
65
|
subsequently incorporated within the Work.
|
|
53
66
|
|
|
54
67
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
@@ -61,8 +74,18 @@
|
|
|
61
74
|
3. Grant of Patent License. Subject to the terms and conditions of
|
|
62
75
|
this License, each Contributor hereby grants to You a perpetual,
|
|
63
76
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
64
|
-
|
|
65
|
-
and otherwise transfer the Work
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
66
89
|
|
|
67
90
|
4. Redistribution. You may reproduce and distribute copies of the
|
|
68
91
|
Work or Derivative Works thereof in any medium, with or without
|
|
@@ -84,23 +107,87 @@
|
|
|
84
107
|
(d) If the Work includes a "NOTICE" text file as part of its
|
|
85
108
|
distribution, then any Derivative Works that You distribute must
|
|
86
109
|
include a readable copy of the attribution notices contained
|
|
87
|
-
within such NOTICE file
|
|
88
|
-
|
|
89
|
-
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
90
138
|
|
|
91
139
|
6. Trademarks. This License does not grant permission to use the trade
|
|
92
|
-
names, trademarks, service marks, or product names of the Licensor
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
93
143
|
|
|
94
144
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
95
|
-
agreed to in writing, Licensor provides the Work
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
104
191
|
|
|
105
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
106
193
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -3,15 +3,11 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-10-16T23:29:38.981Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-feed-rss
|
|
10
10
|
|
|
11
|
-
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
-
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
-
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
-
|
|
15
11
|
RSS / Atom / JSON Feed **producer** for molecule.dev — pure-function
|
|
16
12
|
serializers that turn a single normalized {@link Feed} structure into
|
|
17
13
|
a valid RSS 2.0, Atom 1.0, or JSON Feed 1.1 document.
|
|
@@ -27,6 +23,10 @@ Apps that use this:
|
|
|
27
23
|
- `news-aggregator` — re-publish curated cross-source feeds.
|
|
28
24
|
- `podcast` — RSS 2.0 with the iTunes namespace (set `feed.itunes`).
|
|
29
25
|
|
|
26
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
27
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
28
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
29
|
+
|
|
30
30
|
## Quick Start
|
|
31
31
|
|
|
32
32
|
One serializer per call
|
|
@@ -132,72 +132,78 @@ interface CreateFeedHandlerOptions {
|
|
|
132
132
|
}
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
#### `
|
|
135
|
+
#### `FeedRequest`
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
every serializer.
|
|
137
|
+
Minimal request shape consumed by the generated handler.
|
|
139
138
|
|
|
140
139
|
```typescript
|
|
141
|
-
interface
|
|
142
|
-
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
interface FeedRequest {
|
|
141
|
+
/**
|
|
142
|
+
* URL extension portion — `'rss'`, `'atom'`, `'json'`, or any custom key
|
|
143
|
+
* the caller wired in {@link CreateFeedHandlerOptions.extensions}.
|
|
144
|
+
*
|
|
145
|
+
* Callers compute this from the request URL (e.g.
|
|
146
|
+
* `req.path.split('.').pop()` for Express).
|
|
147
|
+
*/
|
|
148
|
+
extension: string
|
|
147
149
|
|
|
148
|
-
/**
|
|
149
|
-
|
|
150
|
+
/** Optional `If-None-Match` ETag value, for 304 short-circuiting. */
|
|
151
|
+
ifNoneMatch?: string
|
|
152
|
+
}
|
|
153
|
+
```
|
|
150
154
|
|
|
151
|
-
|
|
152
|
-
feedUrl?: string
|
|
155
|
+
#### `FeedResponse`
|
|
153
156
|
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
Minimal response shape returned by the handler. Framework adapters map
|
|
158
|
+
this onto their native response API (`res.status().set().send()` for
|
|
159
|
+
Express, `new Response(body, { status, headers })` for fetch, etc.).
|
|
156
160
|
|
|
157
|
-
|
|
158
|
-
|
|
161
|
+
```typescript
|
|
162
|
+
interface FeedResponse {
|
|
163
|
+
/** HTTP status code: `200` / `304` / `404` / `503`. */
|
|
164
|
+
status: number
|
|
159
165
|
|
|
160
|
-
/**
|
|
161
|
-
|
|
166
|
+
/** Headers — always includes `Content-Type` on `200`. */
|
|
167
|
+
headers: Record<string, string>
|
|
162
168
|
|
|
163
|
-
/**
|
|
164
|
-
|
|
169
|
+
/** Body — empty string on `304` / `404` / errors. */
|
|
170
|
+
body: string
|
|
171
|
+
}
|
|
172
|
+
```
|
|
165
173
|
|
|
166
|
-
|
|
167
|
-
imageUrl?: string
|
|
174
|
+
#### `FeedItemItunes`
|
|
168
175
|
|
|
169
|
-
|
|
170
|
-
categories?: string[]
|
|
176
|
+
Optional iTunes podcast metadata for an item.
|
|
171
177
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
When supplied AND the channel-level {@link Feed.itunes} block is also
|
|
179
|
+
present, the RSS 2.0 serializer emits the iTunes podcast namespace
|
|
180
|
+
(`xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"`) and per-item
|
|
181
|
+
`<itunes:duration>`, `<itunes:author>`, `<itunes:explicit>`,
|
|
182
|
+
`<itunes:image>`, `<itunes:episode>`, `<itunes:season>`, `<itunes:summary>`
|
|
183
|
+
elements.
|
|
178
184
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
```typescript
|
|
186
|
+
interface FeedItemItunes {
|
|
187
|
+
/** Episode duration in seconds. Serialized as HH:MM:SS. */
|
|
188
|
+
durationSeconds?: number
|
|
183
189
|
|
|
184
|
-
|
|
190
|
+
/** Episode artwork URL. Emitted as `<itunes:image href="...">`. */
|
|
191
|
+
imageUrl?: string
|
|
185
192
|
|
|
186
|
-
Author
|
|
193
|
+
/** Author display name (overrides item-level `<itunes:author>`). */
|
|
194
|
+
author?: string
|
|
187
195
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
/** Display name. Required for Atom; optional everywhere else. */
|
|
191
|
-
name: string
|
|
196
|
+
/** Whether the episode contains explicit material. */
|
|
197
|
+
explicit?: boolean
|
|
192
198
|
|
|
193
|
-
/**
|
|
194
|
-
|
|
199
|
+
/** Episode number within the season / series. */
|
|
200
|
+
episode?: number
|
|
195
201
|
|
|
196
|
-
/**
|
|
197
|
-
|
|
202
|
+
/** Season number. */
|
|
203
|
+
season?: number
|
|
198
204
|
|
|
199
|
-
/**
|
|
200
|
-
|
|
205
|
+
/** Plain-text episode summary (`<itunes:summary>`). */
|
|
206
|
+
summary?: string
|
|
201
207
|
}
|
|
202
208
|
```
|
|
203
209
|
|
|
@@ -242,6 +248,52 @@ interface FeedChannelItunes {
|
|
|
242
248
|
}
|
|
243
249
|
```
|
|
244
250
|
|
|
251
|
+
#### `FeedItemEnclosure`
|
|
252
|
+
|
|
253
|
+
Media enclosure (podcast audio, video, image, etc.).
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
interface FeedItemEnclosure {
|
|
257
|
+
/** Direct URL to the media resource. Required. */
|
|
258
|
+
url: string
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* MIME type. Required by RSS 2.0 spec — defaults to
|
|
262
|
+
* `application/octet-stream` when omitted.
|
|
263
|
+
*/
|
|
264
|
+
type?: string
|
|
265
|
+
|
|
266
|
+
/** Length in bytes. Required by RSS 2.0 spec — defaults to `0` when omitted. */
|
|
267
|
+
length?: number
|
|
268
|
+
|
|
269
|
+
/** Display title or alt text. JSON Feed only. */
|
|
270
|
+
title?: string
|
|
271
|
+
|
|
272
|
+
/** Duration in seconds. Used by JSON Feed `attachments[].duration_in_seconds`. */
|
|
273
|
+
durationSeconds?: number
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
#### `FeedAuthor`
|
|
278
|
+
|
|
279
|
+
Author of a feed or item.
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
interface FeedAuthor {
|
|
283
|
+
/** Display name. Required for Atom; optional everywhere else. */
|
|
284
|
+
name: string
|
|
285
|
+
|
|
286
|
+
/** Author email address. Optional. */
|
|
287
|
+
email?: string
|
|
288
|
+
|
|
289
|
+
/** Author profile / homepage URL. Optional. */
|
|
290
|
+
url?: string
|
|
291
|
+
|
|
292
|
+
/** Avatar URL (JSON Feed only). */
|
|
293
|
+
avatarUrl?: string
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
245
297
|
#### `FeedItem`
|
|
246
298
|
|
|
247
299
|
A single feed item / entry / post.
|
|
@@ -299,104 +351,65 @@ interface FeedItem {
|
|
|
299
351
|
}
|
|
300
352
|
```
|
|
301
353
|
|
|
302
|
-
#### `
|
|
354
|
+
#### `Feed`
|
|
303
355
|
|
|
304
|
-
|
|
356
|
+
Feed-level metadata + items, format-agnostic input shape consumed by
|
|
357
|
+
every serializer.
|
|
305
358
|
|
|
306
359
|
```typescript
|
|
307
|
-
interface
|
|
308
|
-
/**
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* MIME type. Required by RSS 2.0 spec — defaults to
|
|
313
|
-
* `application/octet-stream` when omitted.
|
|
314
|
-
*/
|
|
315
|
-
type?: string
|
|
360
|
+
interface Feed {
|
|
361
|
+
/** Channel / feed title. Required. */
|
|
362
|
+
title: string
|
|
316
363
|
|
|
317
|
-
/**
|
|
318
|
-
|
|
364
|
+
/** Canonical website URL (NOT the feed self-link). Required. */
|
|
365
|
+
link: string
|
|
319
366
|
|
|
320
|
-
/**
|
|
321
|
-
|
|
367
|
+
/** Long-form description / subtitle / tagline. Required by RSS 2.0. */
|
|
368
|
+
description: string
|
|
322
369
|
|
|
323
|
-
/**
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
```
|
|
370
|
+
/** Self-referential URL of the feed document. Recommended for Atom + JSON Feed. */
|
|
371
|
+
feedUrl?: string
|
|
327
372
|
|
|
328
|
-
|
|
373
|
+
/** RFC 5646 / BCP 47 language tag (e.g. `en`, `en-US`). */
|
|
374
|
+
language?: string
|
|
329
375
|
|
|
330
|
-
|
|
376
|
+
/** ISO 8601 / `Date` of the feed's last update. Defaults to "now" for Atom. */
|
|
377
|
+
updatedAt?: string | Date
|
|
331
378
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
(`xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"`) and per-item
|
|
335
|
-
`<itunes:duration>`, `<itunes:author>`, `<itunes:explicit>`,
|
|
336
|
-
`<itunes:image>`, `<itunes:episode>`, `<itunes:season>`, `<itunes:summary>`
|
|
337
|
-
elements.
|
|
379
|
+
/** Channel author(s). */
|
|
380
|
+
authors?: FeedAuthor[]
|
|
338
381
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
/** Episode duration in seconds. Serialized as HH:MM:SS. */
|
|
342
|
-
durationSeconds?: number
|
|
382
|
+
/** Copyright / rights statement. */
|
|
383
|
+
copyright?: string
|
|
343
384
|
|
|
344
|
-
/**
|
|
385
|
+
/** Channel image / logo / icon URL. */
|
|
345
386
|
imageUrl?: string
|
|
346
387
|
|
|
347
|
-
/**
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
/** Whether the episode contains explicit material. */
|
|
351
|
-
explicit?: boolean
|
|
352
|
-
|
|
353
|
-
/** Episode number within the season / series. */
|
|
354
|
-
episode?: number
|
|
355
|
-
|
|
356
|
-
/** Season number. */
|
|
357
|
-
season?: number
|
|
358
|
-
|
|
359
|
-
/** Plain-text episode summary (`<itunes:summary>`). */
|
|
360
|
-
summary?: string
|
|
361
|
-
}
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
#### `FeedRequest`
|
|
365
|
-
|
|
366
|
-
Minimal request shape consumed by the generated handler.
|
|
388
|
+
/** Channel-level categories (RSS only). */
|
|
389
|
+
categories?: string[]
|
|
367
390
|
|
|
368
|
-
```typescript
|
|
369
|
-
interface FeedRequest {
|
|
370
391
|
/**
|
|
371
|
-
*
|
|
372
|
-
* the
|
|
373
|
-
*
|
|
374
|
-
* Callers compute this from the request URL (e.g.
|
|
375
|
-
* `req.path.split('.').pop()` for Express).
|
|
392
|
+
* Channel-level iTunes podcast metadata. Presence of this field switches
|
|
393
|
+
* the RSS 2.0 serializer into "podcast mode" — it declares
|
|
394
|
+
* `xmlns:itunes` and emits per-item `<itunes:*>` elements.
|
|
376
395
|
*/
|
|
377
|
-
|
|
396
|
+
itunes?: FeedChannelItunes
|
|
378
397
|
|
|
379
|
-
/**
|
|
380
|
-
|
|
398
|
+
/** Items in display order. The serializer does not re-sort by date. */
|
|
399
|
+
items: FeedItem[]
|
|
381
400
|
}
|
|
382
401
|
```
|
|
383
402
|
|
|
384
|
-
#### `
|
|
403
|
+
#### `SerializeRss2Options`
|
|
385
404
|
|
|
386
|
-
|
|
387
|
-
this onto their native response API (`res.status().set().send()` for
|
|
388
|
-
Express, `new Response(body, { status, headers })` for fetch, etc.).
|
|
405
|
+
Options controlling {@link serializeRss2}.
|
|
389
406
|
|
|
390
407
|
```typescript
|
|
391
|
-
interface
|
|
392
|
-
/**
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
headers: Record<string, string>
|
|
397
|
-
|
|
398
|
-
/** Body — empty string on `304` / `404` / errors. */
|
|
399
|
-
body: string
|
|
408
|
+
interface SerializeRss2Options {
|
|
409
|
+
/** XML declaration. Defaults to `<?xml version="1.0" encoding="UTF-8"?>`. */
|
|
410
|
+
xmlDeclaration?: string
|
|
411
|
+
/** Pretty-print with 2-space indentation. Defaults to `true`. */
|
|
412
|
+
pretty?: boolean
|
|
400
413
|
}
|
|
401
414
|
```
|
|
402
415
|
|
|
@@ -424,19 +437,6 @@ interface SerializeJsonFeedOptions {
|
|
|
424
437
|
}
|
|
425
438
|
```
|
|
426
439
|
|
|
427
|
-
#### `SerializeRss2Options`
|
|
428
|
-
|
|
429
|
-
Options controlling {@link serializeRss2}.
|
|
430
|
-
|
|
431
|
-
```typescript
|
|
432
|
-
interface SerializeRss2Options {
|
|
433
|
-
/** XML declaration. Defaults to `<?xml version="1.0" encoding="UTF-8"?>`. */
|
|
434
|
-
xmlDeclaration?: string
|
|
435
|
-
/** Pretty-print with 2-space indentation. Defaults to `true`. */
|
|
436
|
-
pretty?: boolean
|
|
437
|
-
}
|
|
438
|
-
```
|
|
439
|
-
|
|
440
440
|
### Types
|
|
441
441
|
|
|
442
442
|
#### `FeedOutputFormat`
|
|
@@ -460,49 +460,65 @@ Error raised when the {@link Feed} input fails minimum-viability checks
|
|
|
460
460
|
(missing required `title` / `link` / `description`, missing item `id` or
|
|
461
461
|
`title`, etc.).
|
|
462
462
|
|
|
463
|
+
```typescript
|
|
464
|
+
class FeedSerializeError extends Error {
|
|
465
|
+
/** Output format hint at the point of failure, if known. */
|
|
466
|
+
format?: FeedOutputFormat
|
|
467
|
+
|
|
468
|
+
constructor(message: string, format?: FeedOutputFormat) {
|
|
469
|
+
super(message)
|
|
470
|
+
this.name = 'FeedSerializeError'
|
|
471
|
+
this.format = format
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
463
476
|
### Functions
|
|
464
477
|
|
|
465
|
-
#### `
|
|
478
|
+
#### `escapeXml(value)`
|
|
466
479
|
|
|
467
|
-
|
|
468
|
-
|
|
480
|
+
Escape a string for inclusion in an XML text node or attribute value.
|
|
481
|
+
|
|
482
|
+
Maps the five XML predefined entities:
|
|
483
|
+
|
|
484
|
+
- `&` → `&`
|
|
485
|
+
- `<` → `<`
|
|
486
|
+
- `>` → `>`
|
|
487
|
+
- `"` → `"`
|
|
488
|
+
- `'` → `'`
|
|
489
|
+
|
|
490
|
+
Also strips XML 1.0 illegal control characters (`U+0000`–`U+0008`,
|
|
491
|
+
`U+000B`, `U+000C`, `U+000E`–`U+001F`). `\t`, `\n`, `\r` are preserved.
|
|
469
492
|
|
|
470
493
|
```typescript
|
|
471
|
-
function
|
|
494
|
+
function escapeXml(value: string | number | boolean | null | undefined): string
|
|
472
495
|
```
|
|
473
496
|
|
|
474
|
-
- `
|
|
475
|
-
- `format` — Target serialization format.
|
|
476
|
-
|
|
477
|
-
#### `createFeedHandler(options)`
|
|
497
|
+
- `value` — Raw string. `undefined` / `null` collapse to `''`.
|
|
478
498
|
|
|
479
|
-
|
|
499
|
+
**Returns:** Escaped string safe for any XML position.
|
|
480
500
|
|
|
481
|
-
|
|
482
|
-
{@link FeedResponse}. It serves three formats by default — RSS 2.0,
|
|
483
|
-
Atom 1.0, JSON Feed — keyed by URL extension.
|
|
501
|
+
#### `wrapCdata(value)`
|
|
484
502
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
503
|
+
Wrap an HTML payload in a `<![CDATA[ ... ]]>` section, splitting any
|
|
504
|
+
accidental closing-marker (`]]>`) inside the payload across two CDATA
|
|
505
|
+
sections so the result remains valid XML.
|
|
488
506
|
|
|
489
|
-
|
|
490
|
-
|
|
507
|
+
Use for `<description>` / `<content:encoded>` / Atom `<content type="html">`
|
|
508
|
+
where the body is HTML and we want to avoid double-escaping.
|
|
491
509
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
510
|
+
Also strips XML 1.0 illegal control characters before wrapping (`\t`,
|
|
511
|
+
`\n`, `\r` preserved). The CDATA payload still cannot contain raw
|
|
512
|
+
`<![CDATA[` openers, but those are not produced by typical HTML and
|
|
513
|
+
any literal occurrence is treated as ordinary text by browsers.
|
|
496
514
|
|
|
497
515
|
```typescript
|
|
498
|
-
function
|
|
499
|
-
options: CreateFeedHandlerOptions,
|
|
500
|
-
): (req: FeedRequest) => Promise<FeedResponse>
|
|
516
|
+
function wrapCdata(value: string | null | undefined): string
|
|
501
517
|
```
|
|
502
518
|
|
|
503
|
-
- `
|
|
519
|
+
- `value` — Raw HTML / text. `undefined` / `null` collapse to `''`.
|
|
504
520
|
|
|
505
|
-
**Returns:**
|
|
521
|
+
**Returns:** A complete CDATA section, e.g. `<![CDATA[<p>x</p>]]>`.
|
|
506
522
|
|
|
507
523
|
#### `escapeAttr(value)`
|
|
508
524
|
|
|
@@ -535,54 +551,35 @@ function escapeUrl(value: string | null | undefined): string
|
|
|
535
551
|
|
|
536
552
|
**Returns:** Escaped URL or `'about:blank'` for disallowed schemes.
|
|
537
553
|
|
|
538
|
-
#### `
|
|
539
|
-
|
|
540
|
-
Escape a string for inclusion in an XML text node or attribute value.
|
|
541
|
-
|
|
542
|
-
Maps the five XML predefined entities:
|
|
543
|
-
|
|
544
|
-
- `&` → `&`
|
|
545
|
-
- `<` → `<`
|
|
546
|
-
- `>` → `>`
|
|
547
|
-
- `"` → `"`
|
|
548
|
-
- `'` → `'`
|
|
549
|
-
|
|
550
|
-
Also strips XML 1.0 illegal control characters (`U+0000`–`U+0008`,
|
|
551
|
-
`U+000B`, `U+000C`, `U+000E`–`U+001F`). `\t`, `\n`, `\r` are preserved.
|
|
552
|
-
|
|
553
|
-
```typescript
|
|
554
|
-
function escapeXml(value: string | number | boolean | null | undefined): string
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
- `value` — Raw string. `undefined` / `null` collapse to `''`.
|
|
558
|
-
|
|
559
|
-
**Returns:** Escaped string safe for any XML position.
|
|
560
|
-
|
|
561
|
-
#### `indent(body, pad)`
|
|
562
|
-
|
|
563
|
-
Indent each newline of `body` by `pad` spaces. Used for pretty-printing.
|
|
554
|
+
#### `createFeedHandler(options)`
|
|
564
555
|
|
|
565
|
-
|
|
566
|
-
function indent(body: string, pad: number): string
|
|
567
|
-
```
|
|
556
|
+
Create a framework-agnostic feed HTTP handler with built-in TTL caching.
|
|
568
557
|
|
|
569
|
-
|
|
570
|
-
|
|
558
|
+
The returned handler accepts a {@link FeedRequest} and returns a
|
|
559
|
+
{@link FeedResponse}. It serves three formats by default — RSS 2.0,
|
|
560
|
+
Atom 1.0, JSON Feed — keyed by URL extension.
|
|
571
561
|
|
|
572
|
-
**
|
|
562
|
+
**Caching** — feed payloads are cached per-format for `cacheTtlMs`
|
|
563
|
+
(default 1 minute). Each cache entry carries an ETag computed from the
|
|
564
|
+
payload hash; matching `If-None-Match` triggers a `304` response.
|
|
573
565
|
|
|
574
|
-
|
|
566
|
+
**Error handling** — if `loadFeed` throws, the handler returns `503`
|
|
567
|
+
with body `''`. The error is forwarded to `onError` if provided.
|
|
575
568
|
|
|
576
|
-
|
|
577
|
-
|
|
569
|
+
**No XSS surface** — all interpolation runs through the underlying
|
|
570
|
+
serializers (`serializeRss2` / `serializeAtom1` / `serializeJsonFeed`),
|
|
571
|
+
which escape every user-supplied field. The handler itself never
|
|
572
|
+
concatenates request data into the response body.
|
|
578
573
|
|
|
579
574
|
```typescript
|
|
580
|
-
function
|
|
575
|
+
function createFeedHandler(
|
|
576
|
+
options: CreateFeedHandlerOptions,
|
|
577
|
+
): (req: FeedRequest) => Promise<FeedResponse>
|
|
581
578
|
```
|
|
582
579
|
|
|
583
|
-
- `
|
|
580
|
+
- `options` — See {@link CreateFeedHandlerOptions}.
|
|
584
581
|
|
|
585
|
-
**Returns:**
|
|
582
|
+
**Returns:** Async handler function `(req: FeedRequest) => Promise<FeedResponse>`.
|
|
586
583
|
|
|
587
584
|
#### `serializeAtom1(feed, options)`
|
|
588
585
|
|
|
@@ -670,20 +667,6 @@ function serializeRss2(feed: Feed, options?: SerializeRss2Options): string
|
|
|
670
667
|
|
|
671
668
|
**Returns:** Complete RSS 2.0 XML document string.
|
|
672
669
|
|
|
673
|
-
#### `toHhMmSs(seconds)`
|
|
674
|
-
|
|
675
|
-
Format a duration in seconds as `HH:MM:SS`, used for `<itunes:duration>`.
|
|
676
|
-
|
|
677
|
-
Returns `undefined` for non-finite or negative input.
|
|
678
|
-
|
|
679
|
-
```typescript
|
|
680
|
-
function toHhMmSs(seconds: number | null | undefined): string | undefined
|
|
681
|
-
```
|
|
682
|
-
|
|
683
|
-
- `seconds` — Whole or fractional seconds.
|
|
684
|
-
|
|
685
|
-
**Returns:** `HH:MM:SS` string or `undefined`.
|
|
686
|
-
|
|
687
670
|
#### `toIso(value)`
|
|
688
671
|
|
|
689
672
|
Coerce a `Date` / ISO string / arbitrary string into an ISO 8601 string.
|
|
@@ -716,27 +699,57 @@ function toRfc822(value: string | Date | null | undefined): string | undefined
|
|
|
716
699
|
|
|
717
700
|
**Returns:** RFC 822 timestamp (`Mon, 28 Apr 2026 15:00:00 GMT`) or `undefined`.
|
|
718
701
|
|
|
719
|
-
#### `
|
|
702
|
+
#### `toHhMmSs(seconds)`
|
|
720
703
|
|
|
721
|
-
|
|
722
|
-
accidental closing-marker (`]]>`) inside the payload across two CDATA
|
|
723
|
-
sections so the result remains valid XML.
|
|
704
|
+
Format a duration in seconds as `HH:MM:SS`, used for `<itunes:duration>`.
|
|
724
705
|
|
|
725
|
-
|
|
726
|
-
where the body is HTML and we want to avoid double-escaping.
|
|
706
|
+
Returns `undefined` for non-finite or negative input.
|
|
727
707
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
708
|
+
```typescript
|
|
709
|
+
function toHhMmSs(seconds: number | null | undefined): string | undefined
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
- `seconds` — Whole or fractional seconds.
|
|
713
|
+
|
|
714
|
+
**Returns:** `HH:MM:SS` string or `undefined`.
|
|
715
|
+
|
|
716
|
+
#### `assertFeedShape(feed, format)`
|
|
717
|
+
|
|
718
|
+
Validate {@link Feed} input has the minimum required fields for the
|
|
719
|
+
given output format.
|
|
732
720
|
|
|
733
721
|
```typescript
|
|
734
|
-
function
|
|
722
|
+
function assertFeedShape(feed: Feed, format: FeedOutputFormat): void
|
|
735
723
|
```
|
|
736
724
|
|
|
737
|
-
- `
|
|
725
|
+
- `feed` — Feed input.
|
|
726
|
+
- `format` — Target serialization format.
|
|
738
727
|
|
|
739
|
-
|
|
728
|
+
#### `indent(body, pad)`
|
|
729
|
+
|
|
730
|
+
Indent each newline of `body` by `pad` spaces. Used for pretty-printing.
|
|
731
|
+
|
|
732
|
+
```typescript
|
|
733
|
+
function indent(body: string, pad: number): string
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
- `body` — Multi-line text. Empty input returns empty string.
|
|
737
|
+
- `pad` — Number of spaces to prepend to each line.
|
|
738
|
+
|
|
739
|
+
**Returns:** Indented text.
|
|
740
|
+
|
|
741
|
+
#### `looksLikeHttpUrl(value)`
|
|
742
|
+
|
|
743
|
+
Whether a string looks like an HTTP(S) URL — used to set
|
|
744
|
+
`<guid isPermaLink>` and to fall back to `link` for `<id>` synthesis.
|
|
745
|
+
|
|
746
|
+
```typescript
|
|
747
|
+
function looksLikeHttpUrl(value: string | null | undefined): boolean
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
- `value` — Candidate string.
|
|
751
|
+
|
|
752
|
+
**Returns:** `true` if the value parses as `http:` or `https:` URL.
|
|
740
753
|
|
|
741
754
|
### Constants
|
|
742
755
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-feed-rss",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "RSS/Atom/JSON Feed producer — pure-function serializers for RSS 2.0, Atom 1.0, JSON Feed 1.1; emits valid XML/JSON with full XML escaping and CDATA wrapping. Includes optional HTTP handler factory.",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/api-feed-rss",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "dist/index.js",
|
|
7
8
|
"types": "dist/index.d.ts",
|
|
@@ -37,9 +38,9 @@
|
|
|
37
38
|
"directory": "packages/api/utilities/feed-rss"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@molecule/api-feed-rss-parser": "1.0.
|
|
41
|
-
"@types/node": "26.
|
|
41
|
+
"@molecule/api-feed-rss-parser": "1.0.3",
|
|
42
|
+
"@types/node": "26.6.5",
|
|
42
43
|
"typescript": "6.0.3",
|
|
43
|
-
"vitest": "4.1.
|
|
44
|
+
"vitest": "4.1.12"
|
|
44
45
|
}
|
|
45
46
|
}
|