substack-feed-api 1.1.2 → 2.0.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 +233 -55
- package/dist/substackFeedApi.js +10051 -3372
- package/dist/substackFeedApi.umd.cjs +8 -11
- package/index.d.ts +55 -95
- package/package.json +12 -10
package/index.d.ts
CHANGED
|
@@ -1,79 +1,17 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
[key: string]: unknown;
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export interface RawFeedChannel {
|
|
9
|
-
title: string[];
|
|
10
|
-
description: string[];
|
|
11
|
-
link: string[];
|
|
12
|
-
image: RawImage[];
|
|
13
|
-
generator: string[];
|
|
14
|
-
lastBuildDate: string[];
|
|
15
|
-
"atom:link": AtomLink[];
|
|
16
|
-
copyright: string[];
|
|
17
|
-
language: string[];
|
|
18
|
-
webMaster: string[];
|
|
19
|
-
"itunes:owner": ItunesOwner[];
|
|
20
|
-
"itunes:author": string[];
|
|
21
|
-
"googleplay:owner": string[];
|
|
22
|
-
"googleplay:email": string[];
|
|
23
|
-
"googleplay:author": string[];
|
|
24
|
-
item: RawItem[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface RawImage {
|
|
28
|
-
url: string[];
|
|
29
|
-
title: string[];
|
|
30
|
-
link: string[];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface AtomLink {
|
|
34
|
-
$: GeneratedType;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface GeneratedType {
|
|
38
|
-
href: string;
|
|
39
|
-
rel: string;
|
|
40
|
-
type: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface ItunesOwner {
|
|
44
|
-
"itunes:email": string[];
|
|
45
|
-
"itunes:name": string[];
|
|
46
|
-
}
|
|
1
|
+
export type SelectorMap<TRaw extends Record<string, string>> = Partial<
|
|
2
|
+
Record<keyof TRaw, string>
|
|
3
|
+
>;
|
|
47
4
|
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"dc:creator": string[];
|
|
54
|
-
pubDate: string[];
|
|
55
|
-
enclosure: Enclosure[];
|
|
56
|
-
"content:encoded": string[];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface Guid {
|
|
60
|
-
_: string;
|
|
61
|
-
$: GeneratedType2;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface GeneratedType2 {
|
|
65
|
-
isPermaLink: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface Enclosure {
|
|
69
|
-
$: GeneratedType3;
|
|
70
|
-
}
|
|
5
|
+
export type ParseRssOptions<TRaw extends Record<string, string>> = {
|
|
6
|
+
itemSelector?: string;
|
|
7
|
+
selectors?: SelectorMap<TRaw>;
|
|
8
|
+
fallback?: TRaw[];
|
|
9
|
+
};
|
|
71
10
|
|
|
72
|
-
export
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
11
|
+
export function parseRssItems<TRaw extends Record<string, string>>(
|
|
12
|
+
xml: string,
|
|
13
|
+
options?: ParseRssOptions<TRaw>,
|
|
14
|
+
): TRaw[];
|
|
77
15
|
|
|
78
16
|
export type SubstackItem = {
|
|
79
17
|
title: string;
|
|
@@ -83,29 +21,51 @@ export type SubstackItem = {
|
|
|
83
21
|
content: string;
|
|
84
22
|
};
|
|
85
23
|
|
|
86
|
-
export function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
export function getPosts(channels: RawFeedChannel[]): SubstackItem[];
|
|
24
|
+
export function parseSubstackRss(
|
|
25
|
+
xml: string,
|
|
26
|
+
options?: Omit<ParseRssOptions<SubstackItem>, "selectors"> & {
|
|
27
|
+
selectors?: SelectorMap<SubstackItem>;
|
|
28
|
+
},
|
|
29
|
+
): SubstackItem[];
|
|
93
30
|
|
|
94
|
-
|
|
31
|
+
export type BookAuthor = {
|
|
32
|
+
name: string;
|
|
33
|
+
};
|
|
95
34
|
|
|
96
|
-
|
|
97
|
-
export type GoodreadsItem = {
|
|
35
|
+
export type GoodreadsBook = {
|
|
98
36
|
title: string;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
37
|
+
description: string;
|
|
38
|
+
cover: string;
|
|
39
|
+
authors?: BookAuthor[];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type GoodreadsReadingStatus =
|
|
43
|
+
| "IS_READING"
|
|
44
|
+
| "FINISHED"
|
|
45
|
+
| "WANTS_TO_READ";
|
|
46
|
+
|
|
47
|
+
export const READING_STATES: readonly [
|
|
48
|
+
"IS_READING",
|
|
49
|
+
"FINISHED",
|
|
50
|
+
"WANTS_TO_READ",
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
export type GoodreadsReadingState = {
|
|
54
|
+
book: GoodreadsBook;
|
|
55
|
+
status: GoodreadsReadingStatus;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type GoodreadsRaw = {
|
|
59
|
+
title: string;
|
|
60
|
+
description: string;
|
|
61
|
+
cover: string;
|
|
62
|
+
author: string;
|
|
63
|
+
shelves: string;
|
|
104
64
|
};
|
|
105
65
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
66
|
+
export function parseGoodreadsRss(
|
|
67
|
+
xml: string,
|
|
68
|
+
options?: Omit<ParseRssOptions<GoodreadsRaw>, "selectors"> & {
|
|
69
|
+
selectors?: SelectorMap<GoodreadsRaw>;
|
|
70
|
+
},
|
|
71
|
+
): GoodreadsReadingState[];
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "substack-feed-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"index.d.ts"
|
|
8
8
|
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"url": "https://github.com/rohit1901/substack-feed-api"
|
|
11
|
+
},
|
|
9
12
|
"main": "./dist/substackFeedApi.umd.cjs",
|
|
10
13
|
"module": "./dist/substackFeedApi.js",
|
|
11
14
|
"types": "./index.d.ts",
|
|
@@ -26,22 +29,21 @@
|
|
|
26
29
|
"version:major": "npm version major"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
|
-
"@eslint/js": "^9.
|
|
30
|
-
"@types/eslint__js": "^8.42.3",
|
|
32
|
+
"@eslint/js": "^9.27.0",
|
|
31
33
|
"@types/jest": "^29.5.14",
|
|
32
34
|
"@types/xml2js": "^0.4.14",
|
|
33
|
-
"eslint": "^
|
|
35
|
+
"eslint": "^9.27.0",
|
|
34
36
|
"events": "^3.3.0",
|
|
35
|
-
"fetch-mock-jest": "^1.5.1",
|
|
36
37
|
"jest": "^29.7.0",
|
|
37
|
-
"prettier": "3.3
|
|
38
|
-
"ts-jest": "^29.
|
|
39
|
-
"typescript": "^5.
|
|
40
|
-
"typescript-eslint": "^
|
|
41
|
-
"vite": "6.
|
|
38
|
+
"prettier": "^3.5.3",
|
|
39
|
+
"ts-jest": "^29.3.4",
|
|
40
|
+
"typescript": "^5.8.3",
|
|
41
|
+
"typescript-eslint": "^8.32.1",
|
|
42
|
+
"vite": "^6.3.5",
|
|
42
43
|
"xml2js": "^0.6.2"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
46
|
+
"cheerio": "^1.2.0",
|
|
45
47
|
"node-fetch": "^3.3.2",
|
|
46
48
|
"ts-node": "^10.9.2",
|
|
47
49
|
"tsconfig-paths": "^4.2.0"
|