webring 1.1.0 → 1.1.2

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/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.2](https://github.com/shepherdjerred/webring/compare/v1.1.1...v1.1.2) (2024-07-14)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update npm ([bfaf883](https://github.com/shepherdjerred/webring/commit/bfaf88347ae769e00e93e514774b2c760694f902))
14
+
15
+ ## [1.1.1](https://github.com/shepherdjerred/webring/compare/v1.1.0...v1.1.1) (2024-07-07)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **deps:** update dependency astro to v4.11.5 ([a61f733](https://github.com/shepherdjerred/webring/commit/a61f733cbd3f7bd659d4a608f58473885a5bcc61))
21
+ * **deps:** update dependency remeda to v2.2.2 ([97a6c06](https://github.com/shepherdjerred/webring/commit/97a6c064138e0c204e231efb2ca45defd82b61f9))
22
+ * **deps:** update dependency remeda to v2.3.0 ([7a4c8d5](https://github.com/shepherdjerred/webring/commit/7a4c8d51ad5722be0a8dced10eb0b14a279b0bf6))
23
+ * update snapshot ([c73cdf7](https://github.com/shepherdjerred/webring/commit/c73cdf779433e6e7e8c5f2beee3fb2aefec9a0e0))
24
+ * use import instead of triple-slash ([971a77e](https://github.com/shepherdjerred/webring/commit/971a77ecd0c612850faeb9d16f7775d3e7ca7253))
25
+
8
26
  ## [1.1.0](https://github.com/shepherdjerred/webring/compare/v1.0.3...v1.1.0) (2024-06-28)
9
27
 
10
28
 
package/README.md CHANGED
@@ -1,13 +1,17 @@
1
- # webring
1
+ <div align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://cdn.rawgit.com/shepherdjerred/webring/main/assets/logo-dark.png">
4
+ <source media="(prefers-color-scheme: light)" srcset="https://cdn.rawgit.com/shepherdjerred/webring/main/assets/logo-light.png">
5
+ <img alt="webring logo" src="https://cdn.rawgit.com/shepherdjerred/webring/main/assets/logo-light.png" height=150>
6
+ </picture>
2
7
 
3
8
  [![webring](https://img.shields.io/npm/v/webring.svg)](https://www.npmjs.com/package/webring)
4
9
 
5
- `webring` gathers the latest posts from your favorite RSS feeds so that you can embed them on your site.
10
+ `webring` fetches the latest updates from your favorite RSS feeds.
6
11
 
7
- Inspired by:
12
+ This project is actively maintained. If you have a feature request or need help, please [create an issue](https://github.com/shepherdjerred/webring/issues/new).
8
13
 
9
- - https://github.com/lukehsiao/openring-rs
10
- - https://git.sr.ht/~sircmpwn/openring
14
+ </div>
11
15
 
12
16
  ## Installation
13
17
 
@@ -15,13 +19,92 @@ Inspired by:
15
19
  npm i webring
16
20
  ```
17
21
 
22
+ ## Features
23
+
24
+ - Written in TypeScript
25
+ - Caching
26
+ - HTML sanitization and truncation
27
+
18
28
  ## Quick Start
19
29
 
20
- This library is meant to be used with static site generators. It is framework agnostic. I use this with [Astro](https://astro.build/) on my [personal website](https://github.com/shepherdjerred/sjer.red/blob/main/src/components/BlogWebring.astro#L17-L22).
30
+ This library is intended to be used with a static site generator. I use this with [Astro](https://astro.build/) on my [personal website](https://github.com/shepherdjerred/sjer.red/blob/1220ebef2e43956ba385402ed8529870e9084de8/src/components/BlogWebring.astro#L17-L22).
21
31
 
22
32
  ```typescript
23
33
  import { run } from "webring";
24
- import { type Configuration, type Result } from "webring";
34
+
35
+ const result = await run({
36
+ sources: [
37
+ {
38
+ url: "https://drewdevault.com/blog/index.xml",
39
+ title: "Drew DeVault",
40
+ },
41
+ {
42
+ url: "https://danluu.com/atom.xml",
43
+ title: "Dan Luu",
44
+ },
45
+ {
46
+ url: "https://jakelazaroff.com/rss.xml",
47
+ title: "Jake Lazaroff",
48
+ },
49
+ ],
50
+ });
51
+
52
+ console.log(result);
53
+ // [
54
+ // {
55
+ // title: 'A discussion of discussions on AI bias',
56
+ // url: 'https://danluu.com/ai-bias/',
57
+ // date: 2024-06-16T00:00:00.000Z,
58
+ // source: { url: 'https://danluu.com/atom.xml', title: 'Dan Luu' },
59
+ // preview: `There've been regular viral stories about ML/AI bias with LLMs and generative AI for the past couple years. One thing I find interesting about discussions of bias is how different the reaction is in the LLM and generative AI case when compared to "classical" bugs in cases where there's a clear bug. ...`
60
+ // },
61
+ // {
62
+ // title: 'Writing a Unix clone in about a month',
63
+ // url: 'https://drewdevault.com/2024/05/24/2024-05-24-Bunnix.html',
64
+ // date: 2024-05-24T00:00:00.000Z,
65
+ // source: {
66
+ // url: 'https://drewdevault.com/blog/index.xml',
67
+ // title: 'Drew DeVault'
68
+ // },
69
+ // preview: 'I needed a bit of a break from “real work” recently, so I started a new programming project that was low-stakes and purely recreational. On April 21st, I set out to see how much of a Unix-like operating system for x86_64 targets that I could put together in about a month. The result is Bunnix. Not i...'
70
+ // },
71
+ // {
72
+ // title: 'The Web Component Success Story',
73
+ // url: 'https://jakelazaroff.com/words/the-web-component-success-story/',
74
+ // date: 2024-01-29T00:00:00.000Z,
75
+ // source: { url: 'https://jakelazaroff.com/rss.xml', title: 'Jake Lazaroff' },
76
+ // preview: "Web components won't take web development by storm, or show us the One True Way to build websites. What they will do is let us collectively build a rich ecosystem of dynamic components that work with any web stack."
77
+ // }
78
+ // ]
79
+ ```
80
+
81
+ ## Configuration
82
+
83
+ `webring` is configured by passing in a `Configuration` object into the `run` method.
84
+
85
+ All possible configuration values can be seen by looking at the [`typedoc` site](https://shepherdjerred.github.io/webring/types/Configuration.html).
86
+
87
+ ## Example
88
+
89
+ An example of using this project with Astro is located in `example`. The relevant file is [`src/pages/blog/[...slug].astro`](https://github.com/shepherdjerred/webring/blob/971a77ecd0c612850faeb9d16f7775d3e7ca7253/example/src/pages/blog/%5B...slug%5D.astro#L18).
90
+
91
+ ```typescript
92
+ ---
93
+ import { type CollectionEntry, getCollection } from "astro:content";
94
+ import BlogPost from "../../layouts/BlogPost.astro";
95
+ import { type Configuration, type Result, run } from "webring";
96
+
97
+ export async function getStaticPaths() {
98
+ const posts = await getCollection("blog");
99
+ return posts.map((post) => ({
100
+ params: { slug: post.slug },
101
+ props: post,
102
+ }));
103
+ }
104
+ type Props = CollectionEntry<"blog">;
105
+
106
+ const post = Astro.props;
107
+ const { Content } = await post.render();
25
108
 
26
109
  export const config: Configuration = {
27
110
  sources: [
@@ -38,39 +121,33 @@ export const config: Configuration = {
38
121
  title: "Jake Lazaroff",
39
122
  },
40
123
  ],
41
- // the output will return the three most recent posts from the above sources
42
124
  number: 3,
43
- // the output will return santized HTML truncated to 300 characters
44
125
  truncate: 300,
45
- // if this is defined, we'll cache the results
46
126
  cache: {
47
- // the file to use as a cache
48
127
  cache_file: "webring.json",
49
- // how long the cache should remain valid for
50
128
  cache_duration_minutes: 60,
51
129
  },
52
130
  };
53
131
 
54
- // type Result = {
55
- // title: string,
56
- // url: string,
57
- // date: Date,
58
- // source: {
59
- // url: string,
60
- // title: string,
61
- // },
62
- // // this will be undefined if the RSS feed is empty
63
- // preview?: string
64
- // }[]
65
132
  export const result: Result = await run(config);
133
+ ---
66
134
 
67
- result.map((entry) => {
68
- // do something with the results
69
- // for example, you might render each item as an HTML block
70
- });
135
+ <BlogPost {...post.data}>
136
+ <Content />
137
+ <h2>Posts from blogs I read</h2>
138
+ <ul>
139
+ {
140
+ result.map((post) => (
141
+ <li>
142
+ <a href={post.url}>{post.title}</a>
143
+ </li>
144
+ ))
145
+ }
146
+ </ul>
147
+ </BlogPost>
71
148
  ```
72
149
 
73
- Here's what I do for my blog:
150
+ ## Inspiration
74
151
 
75
- 1. Run `map` against the resulting array ([code](https://github.com/shepherdjerred/sjer.red/blob/f72b2b75bf0722ba8ff0fdd45f31c02c2ee5089d/src/components/BlogWebring.astro#L17-L22)).
76
- 1. Render a component for each entry ([code](https://github.com/shepherdjerred/sjer.red/blob/f72b2b75bf0722ba8ff0fdd45f31c02c2ee5089d/src/components/WebringEntry.astro)).
152
+ - https://github.com/lukehsiao/openring-rs
153
+ - https://git.sr.ht/~sircmpwn/openring
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,WAAW,EAEhB,KAAK,MAAM,EACX,KAAK,mBAAmB,EAGzB,MAAM,YAAY,CAAC;AAsCpB,wBAAsB,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQjF;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAgBlC"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,WAAW,EAEhB,KAAK,MAAM,EACX,KAAK,mBAAmB,EAGzB,MAAM,YAAY,CAAC;AAyCpB,wBAAsB,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQjF;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAgBlC"}
package/dist/cache.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as R from "remeda";
2
2
  import { CacheSchema, } from "./types.js";
3
3
  import { fetch } from "./fetch.js";
4
- import fs from "fs/promises";
5
4
  import { asyncMapFilterUndefined } from "./util.js";
5
+ import fs from "fs/promises";
6
6
  async function loadCache({ cache_file }) {
7
7
  try {
8
8
  await fs.access(cache_file);
@@ -14,7 +14,10 @@ async function loadCache({ cache_file }) {
14
14
  }
15
15
  }
16
16
  async function saveCache({ cache_file }, cache) {
17
- await fs.mkdir(cache_file.split("/").slice(0, -1).join("/"), { recursive: true });
17
+ const dir = cache_file.split("/").slice(0, -1).join("/");
18
+ if (dir !== "") {
19
+ await fs.mkdir(cache_file.split("/").slice(0, -1).join("/"), { recursive: true });
20
+ }
18
21
  await fs.writeFile(cache_file, JSON.stringify(cache));
19
22
  }
20
23
  function toCacheEntry(result, now) {
package/dist/cache.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAOL,WAAW,GAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpD,KAAK,UAAU,SAAS,CAAC,EAAE,UAAU,EAAsB;IACzD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC5B,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAChD,OAAO,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,EAAE,UAAU,EAAsB,EAAE,KAAY;IACvE,MAAM,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,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CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,sBAAsB,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAmB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAOhG,wBAAsB,QAAQ,CAAC,MAAM,EAAE,aAAa;;;;;;;;;KAEnD;AAED,wBAAsB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAsC5F"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAmB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAOhG,wBAAsB,QAAQ,CAAC,MAAM,EAAE,aAAa;;;;;;;;;KAEnD;AAED,wBAAsB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAuC5F"}
package/dist/fetch.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,YAAY,CAAC;AAChC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAiC,eAAe,EAAsB,MAAM,YAAY,CAAC;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QAE/C,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CACtB,IAAI,CAAC,KAAK,EACV,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAC5C,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,EACjD,CAAC,CAAC,OAAO,EAAE,EACX,CAAC,CAAC,KAAK,EAAE,CACV,CAAC;QAEF,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,OAAO,GACX,SAAS,CAAC,cAAc,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAEzG,OAAO;YACL,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,GAAG,EAAE,SAAS,CAAC,IAAI;YACnB,IAAI,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAC9B,MAAM;YACN,OAAO,EAAE,OAAO;gBACd,CAAC,CAAC,UAAU,CACR,YAAY,CAAC,OAAO,EAAE;oBACpB,oBAAoB,EAAE,KAAK;iBAC5B,CAAC,EACF,MAAM,CACP;gBACH,CAAC,CAAC,SAAS;SACd,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,kBAAkB,MAAM,CAAC,GAAG,KAAK,CAAW,EAAE,CAAC,CAAC;QAC9D,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -3,91 +3,49 @@ import { run } from "./index.js";
3
3
  import { tmpdir } from "os";
4
4
  import { mkdtemp } from "fs/promises";
5
5
  import { join } from "path";
6
- // TODO: intercept network requests
7
- test("it should fetch an RSS feed without caching", async () => {
6
+ import express from "express";
7
+ const app = express();
8
+ app.use(express.static("src/testdata"));
9
+ const port = Math.floor(Math.random() * 10000) + 3000;
10
+ app.listen(port, () => {
11
+ console.log(`Test server listening at http://localhost:${port.toString()}`);
12
+ });
13
+ function createUrl(path) {
14
+ return `http://localhost:${port.toString()}/${path}`;
15
+ }
16
+ function createSources(count) {
17
+ return Array.from({ length: count }, (_, i) => ({
18
+ title: `rss ${i.toString()}`,
19
+ url: createUrl(`rss-${i.toString()}.xml`),
20
+ }));
21
+ }
22
+ test("it should fetch an RSS feed without caching", { timeout: 30000 }, async () => {
8
23
  const config = {
9
- sources: [
10
- {
11
- title: "Jerred Shepherd",
12
- url: "https://sjer.red/rss.xml",
13
- },
14
- ],
24
+ sources: createSources(19),
15
25
  number: 1,
16
26
  truncate: 300,
17
27
  };
18
28
  const result = await run(config);
19
- expect(result).toMatchSnapshot();
29
+ let string = JSON.stringify(result);
30
+ // replace the port number with a fixed value
31
+ string = string.replaceAll(port.toString(), "PORT");
32
+ expect(string).toMatchSnapshot();
20
33
  });
21
- test("it should fetch several RSS feeds", async () => {
34
+ test("it should fetch several RSS feeds", { timeout: 30000 }, async () => {
22
35
  const config = {
23
- sources: [
24
- {
25
- url: "https://drewdevault.com/blog/index.xml",
26
- title: "Drew DeVault",
27
- },
28
- {
29
- url: "https://danluu.com/atom.xml",
30
- title: "Dan Luu",
31
- },
32
- {
33
- url: "https://jakelazaroff.com/rss.xml",
34
- title: "Jake Lazaroff",
35
- },
36
- {
37
- url: "https://awesomekling.github.io/feed.xml",
38
- title: "Andreas Kling",
39
- },
40
- {
41
- url: "https://xeiaso.net/blog.rss",
42
- title: "Xe Iaso",
43
- },
44
- {
45
- url: "https://ciechanow.ski/atom.xml",
46
- title: "Bartosz Ciechanowski",
47
- },
48
- {
49
- url: "https://explained-from-first-principles.com/feed.xml",
50
- title: "Explained From First Principles",
51
- },
52
- {
53
- url: "http://www.aaronsw.com/2002/feeds/pgessays.rss",
54
- title: "Paul Graham",
55
- },
56
- {
57
- url: "https://samwho.dev/rss.xml",
58
- title: "Sam Rose",
59
- },
60
- {
61
- url: "https://rachelbythebay.com/w/atom.xml",
62
- title: "Rachel Kroll",
63
- },
64
- {
65
- url: "https://brr.fyi/feed.xml",
66
- title: "brr.fyi",
67
- },
68
- {
69
- url: "https://devblogs.microsoft.com/oldnewthing/feed",
70
- title: "The Old New Thing",
71
- },
72
- {
73
- url: "https://ludic.mataroa.blog/rss/",
74
- title: "Ludicity",
75
- },
76
- ],
77
- number: 20,
36
+ sources: createSources(19),
37
+ number: 3,
78
38
  truncate: 300,
79
39
  };
80
40
  const result = await run(config);
81
- expect(result).toMatchSnapshot();
41
+ let string = JSON.stringify(result);
42
+ // replace the port number with a fixed value
43
+ string = string.replaceAll(port.toString(), "PORT");
44
+ expect(string).toMatchSnapshot();
82
45
  });
83
- test("it should fetch an RSS feed with caching", async () => {
46
+ test("it should fetch an RSS feed with caching", { timeout: 30000 }, async () => {
84
47
  const config = {
85
- sources: [
86
- {
87
- title: "Jerred Shepherd",
88
- url: "https://sjer.red/rss.xml",
89
- },
90
- ],
48
+ sources: createSources(19),
91
49
  number: 1,
92
50
  truncate: 300,
93
51
  cache: {
@@ -96,7 +54,10 @@ test("it should fetch an RSS feed with caching", async () => {
96
54
  },
97
55
  };
98
56
  const result = await run(config);
99
- expect(result).toMatchSnapshot();
57
+ let string = JSON.stringify(result);
58
+ // replace the port number with a fixed value
59
+ string = string.replaceAll(port.toString(), "PORT");
60
+ expect(string).toMatchSnapshot();
100
61
  });
101
62
  // https://sdorra.dev/posts/2024-02-12-vitest-tmpdir
102
63
  async function createTempDir() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,MAA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AAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACpC,6CAA6C;IAC7C,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;IACpD,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;AACnC,CAAC,CAAC,CAAC;AAEH,oDAAoD;AACpD,KAAK,UAAU,aAAa;IAC1B,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACzC,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import { z } from "zod";
2
2
  export type Source = z.infer<typeof SourceSchema>;
3
+ /** An RSS source */
3
4
  declare const SourceSchema: z.ZodObject<{
5
+ /** The URL of an RSS feed */
4
6
  url: z.ZodString;
7
+ /** A title to describe the feed */
5
8
  title: z.ZodString;
6
9
  }, "strip", z.ZodTypeAny, {
7
10
  url: string;
@@ -11,8 +14,11 @@ declare const SourceSchema: z.ZodObject<{
11
14
  title: string;
12
15
  }>;
13
16
  export type CacheConfiguration = z.infer<typeof CacheConfigurationSchema>;
17
+ /** Configuration for the cache */
14
18
  declare const CacheConfigurationSchema: z.ZodObject<{
19
+ /** How long to cache a result for */
15
20
  cache_duration_minutes: z.ZodDefault<z.ZodNumber>;
21
+ /** The location of a file to use as a cache */
16
22
  cache_file: z.ZodDefault<z.ZodString>;
17
23
  }, "strip", z.ZodTypeAny, {
18
24
  cache_duration_minutes: number;
@@ -22,9 +28,13 @@ declare const CacheConfigurationSchema: z.ZodObject<{
22
28
  cache_file?: string | undefined;
23
29
  }>;
24
30
  export type Configuration = z.infer<typeof ConfigurationSchema>;
31
+ /** A configuration object with caching possibly configured */
25
32
  declare const ConfigurationSchema: z.ZodObject<{
33
+ /** A list of sources to fetch */
26
34
  sources: z.ZodArray<z.ZodObject<{
35
+ /** The URL of an RSS feed */
27
36
  url: z.ZodString;
37
+ /** A title to describe the feed */
28
38
  title: z.ZodString;
29
39
  }, "strip", z.ZodTypeAny, {
30
40
  url: string;
@@ -33,10 +43,15 @@ declare const ConfigurationSchema: z.ZodObject<{
33
43
  url: string;
34
44
  title: string;
35
45
  }>, "many">;
46
+ /** Return the n latest updates from the source list. */
36
47
  number: z.ZodDefault<z.ZodNumber>;
48
+ /** How many words the preview field should be truncated to in characters after HTML has been sanitized and parsed. */
37
49
  truncate: z.ZodDefault<z.ZodNumber>;
50
+ /** Configuration for the cache */
38
51
  cache: z.ZodOptional<z.ZodObject<{
52
+ /** How long to cache a result for */
39
53
  cache_duration_minutes: z.ZodDefault<z.ZodNumber>;
54
+ /** The location of a file to use as a cache */
40
55
  cache_file: z.ZodDefault<z.ZodString>;
41
56
  }, "strip", z.ZodTypeAny, {
42
57
  cache_duration_minutes: number;
@@ -69,9 +84,13 @@ declare const ConfigurationSchema: z.ZodObject<{
69
84
  } | undefined;
70
85
  }>;
71
86
  export type CachedConfiguration = z.infer<typeof CachedConfigurationSchema>;
87
+ /** A configuration object with caching definitely configured */
72
88
  export declare const CachedConfigurationSchema: z.ZodObject<z.objectUtil.extendShape<{
89
+ /** A list of sources to fetch */
73
90
  sources: z.ZodArray<z.ZodObject<{
91
+ /** The URL of an RSS feed */
74
92
  url: z.ZodString;
93
+ /** A title to describe the feed */
75
94
  title: z.ZodString;
76
95
  }, "strip", z.ZodTypeAny, {
77
96
  url: string;
@@ -80,10 +99,15 @@ export declare const CachedConfigurationSchema: z.ZodObject<z.objectUtil.extendS
80
99
  url: string;
81
100
  title: string;
82
101
  }>, "many">;
102
+ /** Return the n latest updates from the source list. */
83
103
  number: z.ZodDefault<z.ZodNumber>;
104
+ /** How many words the preview field should be truncated to in characters after HTML has been sanitized and parsed. */
84
105
  truncate: z.ZodDefault<z.ZodNumber>;
106
+ /** Configuration for the cache */
85
107
  cache: z.ZodOptional<z.ZodObject<{
108
+ /** How long to cache a result for */
86
109
  cache_duration_minutes: z.ZodDefault<z.ZodNumber>;
110
+ /** The location of a file to use as a cache */
87
111
  cache_file: z.ZodDefault<z.ZodString>;
88
112
  }, "strip", z.ZodTypeAny, {
89
113
  cache_duration_minutes: number;
@@ -93,8 +117,11 @@ export declare const CachedConfigurationSchema: z.ZodObject<z.objectUtil.extendS
93
117
  cache_file?: string | undefined;
94
118
  }>>;
95
119
  }, {
120
+ /** Configuration for the cache */
96
121
  cache: z.ZodObject<{
122
+ /** How long to cache a result for */
97
123
  cache_duration_minutes: z.ZodDefault<z.ZodNumber>;
124
+ /** The location of a file to use as a cache */
98
125
  cache_file: z.ZodDefault<z.ZodString>;
99
126
  }, "strip", z.ZodTypeAny, {
100
127
  cache_duration_minutes: number;
@@ -127,12 +154,19 @@ export declare const CachedConfigurationSchema: z.ZodObject<z.objectUtil.extendS
127
154
  truncate?: number | undefined;
128
155
  }>;
129
156
  export type ResultEntry = z.infer<typeof ResultEntrySchema>;
157
+ /** A single entry from an RSS feed */
130
158
  declare const ResultEntrySchema: z.ZodObject<{
159
+ /** The title of the entry */
131
160
  title: z.ZodString;
161
+ /** A direct link to the entry */
132
162
  url: z.ZodString;
163
+ /** The date of the entry */
133
164
  date: z.ZodDate;
165
+ /** The source the entry is from */
134
166
  source: z.ZodObject<{
167
+ /** The URL of an RSS feed */
135
168
  url: z.ZodString;
169
+ /** A title to describe the feed */
136
170
  title: z.ZodString;
137
171
  }, "strip", z.ZodTypeAny, {
138
172
  url: string;
@@ -141,6 +175,7 @@ declare const ResultEntrySchema: z.ZodObject<{
141
175
  url: string;
142
176
  title: string;
143
177
  }>;
178
+ /** A preview of the entry. This may contain sanitized HTML. */
144
179
  preview: z.ZodOptional<z.ZodString>;
145
180
  }, "strip", z.ZodTypeAny, {
146
181
  url: string;
@@ -162,12 +197,19 @@ declare const ResultEntrySchema: z.ZodObject<{
162
197
  preview?: string | undefined;
163
198
  }>;
164
199
  export type Result = z.infer<typeof ResultSchema>;
200
+ /** A list of results */
165
201
  declare const ResultSchema: z.ZodArray<z.ZodObject<{
202
+ /** The title of the entry */
166
203
  title: z.ZodString;
204
+ /** A direct link to the entry */
167
205
  url: z.ZodString;
206
+ /** The date of the entry */
168
207
  date: z.ZodDate;
208
+ /** The source the entry is from */
169
209
  source: z.ZodObject<{
210
+ /** The URL of an RSS feed */
170
211
  url: z.ZodString;
212
+ /** A title to describe the feed */
171
213
  title: z.ZodString;
172
214
  }, "strip", z.ZodTypeAny, {
173
215
  url: string;
@@ -176,6 +218,7 @@ declare const ResultSchema: z.ZodArray<z.ZodObject<{
176
218
  url: string;
177
219
  title: string;
178
220
  }>;
221
+ /** A preview of the entry. This may contain sanitized HTML. */
179
222
  preview: z.ZodOptional<z.ZodString>;
180
223
  }, "strip", z.ZodTypeAny, {
181
224
  url: string;
@@ -197,14 +240,23 @@ declare const ResultSchema: z.ZodArray<z.ZodObject<{
197
240
  preview?: string | undefined;
198
241
  }>, "many">;
199
242
  export type CacheEntry = z.infer<typeof CacheEntrySchema>;
243
+ /** A single cache entry */
200
244
  export declare const CacheEntrySchema: z.ZodObject<{
245
+ /** The time a source was last checked */
201
246
  timestamp: z.ZodDate;
247
+ /** The data from the source */
202
248
  data: z.ZodObject<{
249
+ /** The title of the entry */
203
250
  title: z.ZodString;
251
+ /** A direct link to the entry */
204
252
  url: z.ZodString;
253
+ /** The date of the entry */
205
254
  date: z.ZodDate;
255
+ /** The source the entry is from */
206
256
  source: z.ZodObject<{
257
+ /** The URL of an RSS feed */
207
258
  url: z.ZodString;
259
+ /** A title to describe the feed */
208
260
  title: z.ZodString;
209
261
  }, "strip", z.ZodTypeAny, {
210
262
  url: string;
@@ -213,6 +265,7 @@ export declare const CacheEntrySchema: z.ZodObject<{
213
265
  url: string;
214
266
  title: string;
215
267
  }>;
268
+ /** A preview of the entry. This may contain sanitized HTML. */
216
269
  preview: z.ZodOptional<z.ZodString>;
217
270
  }, "strip", z.ZodTypeAny, {
218
271
  url: string;
@@ -259,14 +312,23 @@ export declare const CacheEntrySchema: z.ZodObject<{
259
312
  };
260
313
  }>;
261
314
  export type Cache = z.infer<typeof CacheSchema>;
315
+ /** A mapping of source URLs to cache entries */
262
316
  export declare const CacheSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
317
+ /** The time a source was last checked */
263
318
  timestamp: z.ZodDate;
319
+ /** The data from the source */
264
320
  data: z.ZodObject<{
321
+ /** The title of the entry */
265
322
  title: z.ZodString;
323
+ /** A direct link to the entry */
266
324
  url: z.ZodString;
325
+ /** The date of the entry */
267
326
  date: z.ZodDate;
327
+ /** The source the entry is from */
268
328
  source: z.ZodObject<{
329
+ /** The URL of an RSS feed */
269
330
  url: z.ZodString;
331
+ /** A title to describe the feed */
270
332
  title: z.ZodString;
271
333
  }, "strip", z.ZodTypeAny, {
272
334
  url: string;
@@ -275,6 +337,7 @@ export declare const CacheSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
275
337
  url: string;
276
338
  title: string;
277
339
  }>;
340
+ /** A preview of the entry. This may contain sanitized HTML. */
278
341
  preview: z.ZodOptional<z.ZodString>;
279
342
  }, "strip", z.ZodTypeAny, {
280
343
  url: string;
@@ -320,6 +383,7 @@ export declare const CacheSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
320
383
  preview?: string | undefined;
321
384
  };
322
385
  }>>;
386
+ /** The expected format fetched RSS feed entries */
323
387
  export declare const FeedEntrySchema: z.ZodEffects<z.ZodObject<{
324
388
  title: z.ZodString;
325
389
  link: z.ZodString;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAClD,QAAA,MAAM,YAAY;;;;;;;;;EAKhB,CAAC;AAEH,MAAM,MAAM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