@sockethub/platform-feeds 3.0.0-alpha.3 → 4.0.0-alpha.6

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 CHANGED
@@ -1,15 +1,68 @@
1
1
  # @sockethub/platform-feeds
2
2
 
3
- A Sockethub platform module implementing Atom/RSS feed functionality.
3
+ A Sockethub platform module for fetching and parsing RSS and Atom feeds.
4
4
 
5
5
  ## About
6
6
 
7
- This module contains all the implementation details of a `Feeds` client, Atom & RSS, and is
8
- used as a Sockethub platform.
7
+ This platform fetches RSS and Atom feeds from URLs and converts feed entries into
8
+ ActivityStreams objects. It handles various feed formats and provides structured data for
9
+ web applications to consume feed content.
9
10
 
10
- ## Implemented (`@type`)
11
+ ## Implemented Verbs (`@type`)
11
12
 
12
- <kbd>![completed](http://sockethub.org/res/img/checkmark.png) fetch</kbd>
13
+ * **fetch** - Retrieve and parse an RSS or Atom feed
13
14
 
14
- ## API
15
- API docs can be found [here](API.md)
15
+ ## Usage
16
+
17
+ ### Request Format
18
+
19
+ ```json
20
+ {
21
+ "@type": "fetch",
22
+ "context": "feeds",
23
+ "actor": {
24
+ "@id": "https://example.com/feed.xml"
25
+ }
26
+ }
27
+ ```
28
+
29
+ ### Response Format
30
+
31
+ Returns an ActivityStreams Collection with feed entries:
32
+
33
+ ```json
34
+ {
35
+ "@type": "Collection",
36
+ "context": "feeds",
37
+ "totalItems": 10,
38
+ "items": [
39
+ {
40
+ "@type": "Create",
41
+ "actor": {
42
+ "@id": "https://example.com/feed.xml",
43
+ "name": "Example Blog"
44
+ },
45
+ "object": {
46
+ "@type": "Article",
47
+ "name": "Blog Post Title",
48
+ "content": "Post content...",
49
+ "url": "https://example.com/post/1",
50
+ "published": "2023-01-01T12:00:00Z"
51
+ }
52
+ }
53
+ ]
54
+ }
55
+ ```
56
+
57
+ ## Supported Feed Formats
58
+
59
+ * **RSS 2.0**: Standard RSS feeds
60
+ * **Atom 1.0**: Atom syndication format
61
+ * **RSS 1.0/RDF**: RDF-based RSS feeds
62
+
63
+ ## Use Cases
64
+
65
+ * **Content aggregation**: Collect posts from multiple blogs and news sites
66
+ * **Feed readers**: Build web-based feed reading applications
67
+ * **Content monitoring**: Track updates from RSS/Atom feeds
68
+ * **Data integration**: Import feed content into other systems
package/package.json CHANGED
@@ -1,11 +1,21 @@
1
1
  {
2
2
  "name": "@sockethub/platform-feeds",
3
3
  "description": "A sockethub platform module implementing RSS/Atom functionality",
4
- "version": "3.0.0-alpha.3",
4
+ "version": "4.0.0-alpha.6",
5
+ "type": "module",
5
6
  "private": false,
6
7
  "author": "Nick Jennings <nick@silverbucket.net>",
7
8
  "license": "LGPL-3.0+",
8
- "main": "index.js",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "main": "./src/index.ts",
13
+ "files": [
14
+ "src/"
15
+ ],
16
+ "engines": {
17
+ "bun": ">=1.2"
18
+ },
9
19
  "keywords": [
10
20
  "sockethub",
11
21
  "messaging",
@@ -24,29 +34,22 @@
24
34
  },
25
35
  "homepage": "https://github.com/sockethub/sockethub/tree/master/packages/platform-feeds",
26
36
  "dependencies": {
27
- "feedparser": "^2.2.9",
28
- "request": "^2.83.0"
37
+ "html-tags": "3.3.1",
38
+ "htmlparser2": "9.0.0",
39
+ "podparse": "1.6.0"
29
40
  },
30
41
  "devDependencies": {
31
- "fs-then-native": "2.0.0",
32
- "jaribu": "2.2.3",
33
- "jsdoc": "3.6.10",
34
- "jsdoc-to-markdown": "7.1.1"
42
+ "@sockethub/schemas": "3.0.0-alpha.6",
43
+ "@types/bun": "latest",
44
+ "debug": "^4.4.3"
35
45
  },
36
46
  "peerDependencies": {
37
- "@sockethub/server": ">=5.0.0-alpha.2"
47
+ "@sockethub/server": "5.0.0-alpha.6"
38
48
  },
39
49
  "peerDependenciesMeta": {
40
50
  "@sockethub/server": {
41
51
  "optional": true
42
52
  }
43
53
  },
44
- "scripts": {
45
- "build": "yarn run doc",
46
- "clean:deps": "npx rimraf node_modules",
47
- "compliance": "yarn run test",
48
- "test": "jaribu",
49
- "doc": "jsdoc2md --no-gfm --heading-depth 1 index.js > API.md"
50
- },
51
- "gitHead": "f02238a478b7ffd3f31d8deea292eb67e630a86b"
54
+ "gitHead": "f8a937e071e7a209f94b94f63e68faa27784e00e"
52
55
  }
@@ -0,0 +1,299 @@
1
+ export const RSSFeed = `
2
+ <rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
3
+ <channel>
4
+ <title>
5
+ <![CDATA[ Sockethub ]]>
6
+ </title>
7
+ <description>
8
+ <![CDATA[ The polyglot solution to the federated social web ]]>
9
+ </description>
10
+ <link>https://sockethub.org</link>
11
+ <generator>metalsmith-feed</generator>
12
+ <lastBuildDate>Thu, 02 Sep 2021 22:16:22 GMT</lastBuildDate>
13
+ <atom:link href="https://sockethub.org/feed.xml" rel="self" type="application/rss+xml"/>
14
+ <author>
15
+ <![CDATA[ Nick Jennings ]]>
16
+ </author>
17
+ <item>
18
+ <title>
19
+ <![CDATA[ Sockethub 4.1.0 ]]>
20
+ </title>
21
+ <description>
22
+ <![CDATA[ <p>Sockethub 4.1.0 has been released! Lots of stability improvements, for a list see the <a href="https://github.com/sockethub/sockethub/releases/tag/v4.1.0">Sockethub release page</a>.</p> ]]>
23
+ </description>
24
+ <link>https://sockethub.org/news/2021-09-02-release-410.html</link>
25
+ <guid isPermaLink="true">https://sockethub.org/news/2021-09-02-release-410.html</guid>
26
+ <dc:creator>
27
+ <![CDATA[ Nick Jennings ]]>
28
+ </dc:creator>
29
+ <pubDate>Thu, 02 Sep 2021 00:00:00 GMT</pubDate>
30
+ </item>
31
+ <item>
32
+ <title>
33
+ <![CDATA[ Sockethub 4.0.1 ]]>
34
+ </title>
35
+ <description>
36
+ <![CDATA[ <p>Sockethub 4.0.1 has been released! This release fixes a few minor issues present in the previous release, for a list of fixes see the <a href="https://github.com/sockethub/sockethub/releases/tag/v4.0.1">Sockethub release page</a>.</p> ]]>
37
+ </description>
38
+ <link>https://sockethub.org/news/2021-05-23-release-401.html</link>
39
+ <guid isPermaLink="true">https://sockethub.org/news/2021-05-23-release-401.html</guid>
40
+ <dc:creator>
41
+ <![CDATA[ Nick Jennings ]]>
42
+ </dc:creator>
43
+ <pubDate>Sun, 23 May 2021 00:00:00 GMT</pubDate>
44
+ </item>
45
+ <item>
46
+ <title>
47
+ <![CDATA[ Sockethub 4.0.0 ]]>
48
+ </title>
49
+ <description>
50
+ <![CDATA[ <p>Sockethub 4.0.0 has been released! This release has a few major updates to the underlying system, namely switching from <code>node-simple-xmpp</code> to <code>xmpp.js</code>, from <code>Kue</code> to <code>Bull</code> and upgrading to <code>socket.io v4</code>. Additionally, as we performed these significant overhauls of the code, we added more tests and optimizations. This release should be overall a lot faster. For a full list of changes, see the <a href="https://github.com/sockethub/sockethub/releases/tag/v4.0.0">Sockethub release page</a>.</p> ]]>
51
+ </description>
52
+ <link>https://sockethub.org/news/2021-05-20-release-400.html</link>
53
+ <guid isPermaLink="true">https://sockethub.org/news/2021-05-20-release-400.html</guid>
54
+ <dc:creator>
55
+ <![CDATA[ Nick Jennings ]]>
56
+ </dc:creator>
57
+ <pubDate>Thu, 20 May 2021 00:00:00 GMT</pubDate>
58
+ </item>
59
+ <item>
60
+ <title>
61
+ <![CDATA[ Sockethub 3.2.2 ]]>
62
+ </title>
63
+ <description>
64
+ <![CDATA[ <p>Sockethub 3.2.2 has been released and focuses mainly on stability and bugfixes, highlights include pegging the sockethub.io dependency version to resolve a CORS issues, and a hotfix for the IRC platforms upstream library <code>irc-socket</code> allowing TLS connections. For a full list of changes, see <a href="https://github.com/sockethub/sockethub/releases/tag/v3.2.2">Sockethub release page</a>.</p> ]]>
65
+ </description>
66
+ <link>https://sockethub.org/news/2021-02-22-sockethub-release-322.html</link>
67
+ <guid isPermaLink="true">https://sockethub.org/news/2021-02-22-sockethub-release-322.html</guid>
68
+ <dc:creator>
69
+ <![CDATA[ Nick Jennings ]]>
70
+ </dc:creator>
71
+ <pubDate>Mon, 22 Feb 2021 00:00:00 GMT</pubDate>
72
+ </item>
73
+ <item>
74
+ <title>
75
+ <![CDATA[ Sockethub 3.2 ]]>
76
+ </title>
77
+ <description>
78
+ <![CDATA[ <p>Sockethub 3.2 has been released and includes a lot of improvements and work that has progressed throughout the year. The most notable improvement has come with the spawning of new threads for platform modules to help protect against possible platform crashes and memory leaks, which has greatly improved the stability of sockethub core. For a full list of changes, see <a href="https://github.com/sockethub/sockethub/releases/tag/v3.2.0">Sockethub release page</a>.</p> ]]>
79
+ </description>
80
+ <link>https://sockethub.org/news/2020-12-26-sockethub-release-320.html</link>
81
+ <guid isPermaLink="true">https://sockethub.org/news/2020-12-26-sockethub-release-320.html</guid>
82
+ <dc:creator>
83
+ <![CDATA[ Nick Jennings ]]>
84
+ </dc:creator>
85
+ <pubDate>Sat, 26 Dec 2020 00:00:00 GMT</pubDate>
86
+ </item>
87
+ <item>
88
+ <title>
89
+ <![CDATA[ Sockethub 3.x ]]>
90
+ </title>
91
+ <description>
92
+ <![CDATA[ <p>Sockethub 3.0 has been released and includes a lot of improvements focusing mainly on XMPP and IRC, additionally a ton of internal improvements. Ongoing releases tracked on the <a href="https://github.com/sockethub/sockethub/releases">Github page</a>. </p> ]]>
93
+ </description>
94
+ <link>https://sockethub.org/news/2019-09-26-3x.html</link>
95
+ <guid isPermaLink="true">https://sockethub.org/news/2019-09-26-3x.html</guid>
96
+ <dc:creator>
97
+ <![CDATA[ Nick Jennings ]]>
98
+ </dc:creator>
99
+ <pubDate>Thu, 26 Sep 2019 00:00:00 GMT</pubDate>
100
+ </item>
101
+ <item>
102
+ <title>
103
+ <![CDATA[ Kosmos group chat client ]]>
104
+ </title>
105
+ <description>
106
+ <![CDATA[ <p>Over the past several months, we&#39;ve been quietly working away at an open-source group chat platform, build upon Sockethub and remoteStorage, and sprinkling of other tools and services. It aims to address the same area as Slack and HipChat, but built in the open, on open protocols (IRC &amp; XMPP) allowing anyone to interface without needing to commit to a solitary platform. Today we met in Berlin and plan for a couple days of hacking and planning for our MVP target which should be coming soon.</p> <p>I haven&#39;t been announcing every Sockethub release, as they are very frequent and incremental, but be sure to check the github to see the latest activity.</p> <p>[ <a href="https://kosmos.org">kosmos</a> | <a href="https://github.com/67p/hyperchannel">github.com/67p/hyperchannel</a> | <a href="https://github.com/sockethub/sockethub">github.com/sockethub/sockethub</a>]</p> ]]>
107
+ </description>
108
+ <link>https://sockethub.org/news/2017-05-04-kosmos.html</link>
109
+ <guid isPermaLink="true">https://sockethub.org/news/2017-05-04-kosmos.html</guid>
110
+ <dc:creator>
111
+ <![CDATA[ Nick Jennings ]]>
112
+ </dc:creator>
113
+ <pubDate>Thu, 04 May 2017 00:00:00 GMT</pubDate>
114
+ </item>
115
+ <item>
116
+ <title>
117
+ <![CDATA[ Hackerbeach V milestones v1.0.4 ]]>
118
+ </title>
119
+ <description>
120
+ <![CDATA[ <p>While 2016 was a year of mostly maintenance work, 2017 has started off strong. Meeting up with several of the guys at <a href="https://5apps.com">5apps</a> for <a href="http://hackerbeach.org">Hackerbeach V</a>, we&#39;re working toward building an open-source Slack replacement using unhosted technologies Sockethub and <a href="http://remotestorage.io">remoteStorage</a>. No further details at this time, but we&#39;re close to an MVP. In the meantime, I released Sockethub v1.0.4 and activity should increase as we deploy Sockethub for multi-user use.</p> <p>[ <a href="https://github.com/sockethub/sockethub/releases/tag/v1.0.4">release v1.0.4</a> ]</p> ]]>
121
+ </description>
122
+ <link>https://sockethub.org/news/2017-01-23-hakcerbeach-v.html</link>
123
+ <guid isPermaLink="true">https://sockethub.org/news/2017-01-23-hakcerbeach-v.html</guid>
124
+ <dc:creator>
125
+ <![CDATA[ Nick Jennings ]]>
126
+ </dc:creator>
127
+ <pubDate>Mon, 23 Jan 2017 00:00:00 GMT</pubDate>
128
+ </item>
129
+ <item>
130
+ <title>
131
+ <![CDATA[ Version 1.0.0 released ]]>
132
+ </title>
133
+ <description>
134
+ <![CDATA[ <p>A branch which has been worked on for most of 2015 has been merged to the master branch and released as version 1.0.0. Currently only a couple platforms are fully ported over, but the plan is to continue to make incremental improvements. It&#39;s more stable and lightweight than the 0.x releases.</p> <p>[ <a href="https://github.com/sockethub/sockethub/releases/tag/v1.0.0">release v1.0.0</a> | <a href="https://github.com/sockethub/sockethub/blob/v1.0.0/CHANGELOG.md">CHANGELOG</a> ]</p> ]]>
135
+ </description>
136
+ <link>https://sockethub.org/news/2015-11-02-release-v1_0_0.html</link>
137
+ <guid isPermaLink="true">https://sockethub.org/news/2015-11-02-release-v1_0_0.html</guid>
138
+ <dc:creator>
139
+ <![CDATA[ Nick Jennings ]]>
140
+ </dc:creator>
141
+ <pubDate>Mon, 02 Nov 2015 00:00:00 GMT</pubDate>
142
+ </item>
143
+ <item>
144
+ <title>
145
+ <![CDATA[ The Oblivion Bar @ CCCamp2015 ]]>
146
+ </title>
147
+ <description>
148
+ <![CDATA[ <p>The team working on <a href="https://kosmos.org/">Kosmos</a> will have <a href="https://events.ccc.de/camp/2015/wiki/Village:The_Oblivion_Bar">a tent at Chaos Communication Camp 2015</a>. We&#39;ll be giving a talk on Kosmos, remoteStorage and Sockethub.</p> ]]>
149
+ </description>
150
+ <link>https://sockethub.org/news/2015-08-11-cccamp2015.html</link>
151
+ <guid isPermaLink="true">https://sockethub.org/news/2015-08-11-cccamp2015.html</guid>
152
+ <dc:creator>
153
+ <![CDATA[ Nick Jennings ]]>
154
+ </dc:creator>
155
+ <pubDate>Tue, 11 Aug 2015 00:00:00 GMT</pubDate>
156
+ </item>
157
+ <item>
158
+ <title>
159
+ <![CDATA[ Microformat2 & RSS news entries ]]>
160
+ </title>
161
+ <description>
162
+ <![CDATA[ <p>Not only do we now have an <a href="http://sockethub.org/feed.xml">RSS feed</a> but and all of our news entries contain <a href="http://microformats.org/wiki/microformats2">microformat2</a> attributes and can receive webmentions via. <a href="http://webmention.io">webmention.io</a> <em>(though we&#39;re still working on doing something with those webmentions)</em></p> ]]>
163
+ </description>
164
+ <link>https://sockethub.org/news/2015-05-10-microformat2-news.html</link>
165
+ <guid isPermaLink="true">https://sockethub.org/news/2015-05-10-microformat2-news.html</guid>
166
+ <dc:creator>
167
+ <![CDATA[ Nick Jennings ]]>
168
+ </dc:creator>
169
+ <pubDate>Sun, 10 May 2015 00:00:00 GMT</pubDate>
170
+ </item>
171
+ <item>
172
+ <title>
173
+ <![CDATA[ New website ]]>
174
+ </title>
175
+ <description>
176
+ <![CDATA[ <p>The Sockethub website has had a makeover, we&#39;re now using the awesome <a href="http://metalsmith.io">metalsmith</a> static site generator to power things, this allows us to easily maintain news updates and provide an rss feed, and just generally keep things more modular.</p> ]]>
177
+ </description>
178
+ <link>https://sockethub.org/news/2015-05-09-new-website.html</link>
179
+ <guid isPermaLink="true">https://sockethub.org/news/2015-05-09-new-website.html</guid>
180
+ <dc:creator>
181
+ <![CDATA[ Nick Jennings ]]>
182
+ </dc:creator>
183
+ <pubDate>Sat, 09 May 2015 00:00:00 GMT</pubDate>
184
+ </item>
185
+ <item>
186
+ <title>
187
+ <![CDATA[ Release v0.3.x ]]>
188
+ </title>
189
+ <description>
190
+ <![CDATA[ <p>fixes to the IRC platform and improved docker support</p> <p>[ <a href="https://github.com/sockethub/sockethub/releases/tag/v0.3.0">release v0.3.0</a> | <a href="https://github.com/sockethub/sockethub/blob/v0.3.0/CHANGELOG.md">CHANGELOG</a> ]</p> ]]>
191
+ </description>
192
+ <link>https://sockethub.org/news/2014-11-16-release-v0_3.html</link>
193
+ <guid isPermaLink="true">https://sockethub.org/news/2014-11-16-release-v0_3.html</guid>
194
+ <dc:creator>
195
+ <![CDATA[ Nick Jennings ]]>
196
+ </dc:creator>
197
+ <pubDate>Sun, 16 Nov 2014 00:00:00 GMT</pubDate>
198
+ </item>
199
+ <item>
200
+ <title>
201
+ <![CDATA[ Release v0.2.x ]]>
202
+ </title>
203
+ <description>
204
+ <![CDATA[ <p>The sockethub v0.2.x branch has been released!</p> <p>[ <a href="https://github.com/sockethub/sockethub/releases/tag/v0.2.0">release v0.2.0</a> | <a href="https://github.com/sockethub/sockethub/blob/v0.2.0/CHANGELOG.md">CHANGELOG</a> ]</p> ]]>
205
+ </description>
206
+ <link>https://sockethub.org/news/2014-09-09-release-v0_2.html</link>
207
+ <guid isPermaLink="true">https://sockethub.org/news/2014-09-09-release-v0_2.html</guid>
208
+ <dc:creator>
209
+ <![CDATA[ Nick Jennings ]]>
210
+ </dc:creator>
211
+ <pubDate>Tue, 09 Sep 2014 00:00:00 GMT</pubDate>
212
+ </item>
213
+ <item>
214
+ <title>
215
+ <![CDATA[ Dogfeed RSS/Atom Reader released ]]>
216
+ </title>
217
+ <description>
218
+ <![CDATA[ <p>A fully unhosted RSS/Atom reader using Sockethub + <a href="http://remotestorage.io">remoteStorage</a></p> <p>[ <a href="https://dogfeed.5apps.com">dogfeed</a> | <a href="https://github.com/silverbucket/dogfeed">github repository</a> | <a href="https://groups.google.com/forum/#!topic/unhosted/xzOueGY2GYA">official announcement</a> ]</p> ]]>
219
+ </description>
220
+ <link>https://sockethub.org/news/2013-09-05-dogfeed-rss-atom-reader-released.html</link>
221
+ <guid isPermaLink="true">https://sockethub.org/news/2013-09-05-dogfeed-rss-atom-reader-released.html</guid>
222
+ <dc:creator>
223
+ <![CDATA[ Nick Jennings ]]>
224
+ </dc:creator>
225
+ <pubDate>Thu, 05 Sep 2013 00:00:00 GMT</pubDate>
226
+ </item>
227
+ <item>
228
+ <title>
229
+ <![CDATA[ Sockethub lightning talk at OHM2013 ]]>
230
+ </title>
231
+ <description>
232
+ <![CDATA[ <p><a href="https://silverbucket.net">Nick Jennings</a> will be giving a talk tonight on Sockethub @ <a href="https://program.ohm2013.org">OHM2013</a></p> <p>[ <a href="https://program.ohm2013.org/event/475.html">talk overview</a> ]</p> ]]>
233
+ </description>
234
+ <link>https://sockethub.org/news/2013-07-31-sockethub-talk-OHM2013.html</link>
235
+ <guid isPermaLink="true">https://sockethub.org/news/2013-07-31-sockethub-talk-OHM2013.html</guid>
236
+ <dc:creator>
237
+ <![CDATA[ Nick Jennings ]]>
238
+ </dc:creator>
239
+ <pubDate>Wed, 31 Jul 2013 00:00:00 GMT</pubDate>
240
+ </item>
241
+ <item>
242
+ <title>
243
+ <![CDATA[ Sockethub talk @ PragueJS ]]>
244
+ </title>
245
+ <description>
246
+ <![CDATA[ <p><a href="https://silverbucket.net">Nick Jennings</a> will give a Sockethub talk at <a href="http://www.praguejs.cz">PragueJS</a></p> ]]>
247
+ </description>
248
+ <link>https://sockethub.org/news/2013-05-30-sockethub-talk-praguejs.html</link>
249
+ <guid isPermaLink="true">https://sockethub.org/news/2013-05-30-sockethub-talk-praguejs.html</guid>
250
+ <dc:creator>
251
+ <![CDATA[ Nick Jennings ]]>
252
+ </dc:creator>
253
+ <pubDate>Thu, 30 May 2013 00:00:00 GMT</pubDate>
254
+ </item>
255
+ <item>
256
+ <title>
257
+ <![CDATA[ Invoice demo ]]>
258
+ </title>
259
+ <description>
260
+ <![CDATA[ <p>Sockethub &amp; <a href="http://remotestorage.io">remoteStorage</a> invoice demo on noBackend! <a href="http://invoice.nobackend.org/">http://invoice.nobackend.org/</a></p> ]]>
261
+ </description>
262
+ <link>https://sockethub.org/news/2013-05-27-invoice-demo.html</link>
263
+ <guid isPermaLink="true">https://sockethub.org/news/2013-05-27-invoice-demo.html</guid>
264
+ <dc:creator>
265
+ <![CDATA[ Nick Jennings ]]>
266
+ </dc:creator>
267
+ <pubDate>Mon, 27 May 2013 00:00:00 GMT</pubDate>
268
+ </item>
269
+ <item>
270
+ <title>
271
+ <![CDATA[ Sockethub video from re:publica posted ]]>
272
+ </title>
273
+ <description>
274
+ <![CDATA[ <p>Sockethub video from re:publica is up on youtube: <a href="https://www.youtube.com/watch?v=KU4PZK48-dg">https://www.youtube.com/watch?v=KU4PZK48-dg</a></p> ]]>
275
+ </description>
276
+ <link>https://sockethub.org/news/2013-05-13-sockethub-video-posted.html</link>
277
+ <guid isPermaLink="true">https://sockethub.org/news/2013-05-13-sockethub-video-posted.html</guid>
278
+ <dc:creator>
279
+ <![CDATA[ Nick Jennings ]]>
280
+ </dc:creator>
281
+ <pubDate>Mon, 13 May 2013 00:00:00 GMT</pubDate>
282
+ </item>
283
+ <item>
284
+ <title>
285
+ <![CDATA[ Sockethub meetup & hackathon ]]>
286
+ </title>
287
+ <description>
288
+ <![CDATA[ <p>Sockethub meetup &amp; hackathon, May 11th and 12th. <a href="http://lanyrd.com/2013/sockethub/">http://lanyrd.com/2013/sockethub/</a></p> ]]>
289
+ </description>
290
+ <link>https://sockethub.org/news/2013-05-11-sockethub-meetup-hackathon.html</link>
291
+ <guid isPermaLink="true">https://sockethub.org/news/2013-05-11-sockethub-meetup-hackathon.html</guid>
292
+ <dc:creator>
293
+ <![CDATA[ Nick Jennings ]]>
294
+ </dc:creator>
295
+ <pubDate>Sat, 11 May 2013 00:00:00 GMT</pubDate>
296
+ </item>
297
+ </channel>
298
+ </rss>
299
+ `;
@@ -0,0 +1,139 @@
1
+ import { beforeEach, describe, expect, it } from "bun:test";
2
+ import { RSSFeed} from "./index.test.data";
3
+ import Feeds from "./index";
4
+ import { ASCollection, PlatformSession } from "@sockethub/schemas";
5
+ import debug from "debug";
6
+
7
+ describe("platform-feeds", () => {
8
+ let platform;
9
+ beforeEach(() => {
10
+ platform = new Feeds({
11
+ debug: debug("sockethub:platform:feeds")
12
+ } as unknown as PlatformSession);
13
+
14
+ platform.makeRequest = (
15
+ url: string,
16
+ ): Promise<string> => {
17
+ return Promise.resolve(RSSFeed);
18
+ };
19
+ });
20
+
21
+ it("fetches expected feed", () => {
22
+ platform.fetch({
23
+ id: "an id",
24
+ actor: {
25
+ id: "some url"
26
+ }
27
+ }, (err, results: ASCollection) => {
28
+ expect(results['totalItems']).toEqual(20);
29
+ expect(results['items'][5]['object']).toEqual({
30
+ type: "article",
31
+ title: "Sockethub 3.x",
32
+ id: "https://sockethub.org/news/2019-09-26-3x.html",
33
+ brief: undefined,
34
+ content: "<p>Sockethub 3.0 has been released and includes a lot of improvements focusing mainly on XMPP and IRC, additionally a ton of internal improvements. Ongoing releases tracked on the <a href=\"https://github.com/sockethub/sockethub/releases\">Github page</a>. </p>",
35
+ contentType: "html",
36
+ url: "https://sockethub.org/news/2019-09-26-3x.html",
37
+ published: "2019-09-26T00:00:00.000Z",
38
+ updated: undefined,
39
+ datenum: 1569456000000,
40
+ tags: undefined,
41
+ media: undefined,
42
+ source: undefined,
43
+ })
44
+ })
45
+ })
46
+
47
+ it("handles empty feed gracefully", () => {
48
+ // Mock empty feed
49
+ platform.makeRequest = (): Promise<string> => {
50
+ return Promise.resolve('<rss><channel><title>Empty Feed</title></channel></rss>');
51
+ };
52
+
53
+ platform.fetch({
54
+ id: "empty-feed-id",
55
+ actor: {
56
+ id: "http://example.com/empty.xml"
57
+ }
58
+ }, (err, results: ASCollection) => {
59
+ expect(err).toBeNull();
60
+ expect(results.type).toEqual("collection");
61
+ expect(results.totalItems).toEqual(0);
62
+ expect(results.items).toEqual([]);
63
+ expect(results.summary).toEqual("Unknown Feed");
64
+ })
65
+ })
66
+
67
+ it("handles feed with no actor name", () => {
68
+ // Mock feed with no title/name but proper structure
69
+ platform.makeRequest = (): Promise<string> => {
70
+ return Promise.resolve(`
71
+ <rss>
72
+ <channel>
73
+ <item>
74
+ <title>Test Item</title>
75
+ <description>Test content</description>
76
+ <link>http://example.com/item</link>
77
+ <pubDate>Thu, 01 Jan 2024 00:00:00 GMT</pubDate>
78
+ </item>
79
+ </channel>
80
+ </rss>
81
+ `);
82
+ };
83
+
84
+ platform.fetch({
85
+ id: "no-name-feed-id",
86
+ actor: {
87
+ id: "http://example.com/noname.xml"
88
+ }
89
+ }, (err, results: ASCollection) => {
90
+ expect(err).toBeNull();
91
+ // When no title is provided, buildFeedChannel falls back to URL
92
+ expect(results.summary).toEqual("http://example.com/noname.xml");
93
+ })
94
+ })
95
+
96
+ it("handles network errors properly", () => {
97
+ platform.makeRequest = (): Promise<string> => {
98
+ return Promise.reject(new Error("Network timeout"));
99
+ };
100
+
101
+ platform.fetch({
102
+ id: "error-test-id",
103
+ actor: {
104
+ id: "http://example.com/timeout.xml"
105
+ }
106
+ }, (err, results: ASCollection) => {
107
+ expect(err).toBeInstanceOf(Error);
108
+ expect(err.message).toEqual("Network timeout");
109
+ expect(results).toBeUndefined();
110
+ })
111
+ })
112
+
113
+ it("validates collection structure matches ASCollection interface", () => {
114
+ platform.fetch({
115
+ id: "validation-test-id",
116
+ actor: {
117
+ id: "some url"
118
+ }
119
+ }, (err, results: ASCollection) => {
120
+ expect(err).toBeNull();
121
+
122
+ // Validate required ASCollection properties
123
+ expect(results).toHaveProperty("context");
124
+ expect(results).toHaveProperty("type", "collection");
125
+ expect(results).toHaveProperty("summary");
126
+ expect(results).toHaveProperty("totalItems");
127
+ expect(results).toHaveProperty("items");
128
+
129
+ // Validate types
130
+ expect(typeof results.context).toBe("string");
131
+ expect(typeof results.summary).toBe("string");
132
+ expect(typeof results.totalItems).toBe("number");
133
+ expect(Array.isArray(results.items)).toBe(true);
134
+
135
+ // Validate collection consistency
136
+ expect(results.items.length).toEqual(results.totalItems);
137
+ })
138
+ })
139
+ })