feedsmith 2.9.2 → 3.0.0-beta.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/README.md +3 -9
- package/dist/common/config.cjs +2 -1
- package/dist/common/config.js +2 -1
- package/dist/common/errors.cjs +30 -0
- package/dist/common/errors.d.cts +15 -0
- package/dist/common/errors.d.ts +15 -0
- package/dist/common/errors.js +27 -0
- package/dist/common/parse.cjs +2 -1
- package/dist/common/parse.d.cts +10 -11
- package/dist/common/parse.d.ts +10 -11
- package/dist/common/parse.js +2 -1
- package/dist/common/types.d.cts +24 -12
- package/dist/common/types.d.ts +24 -12
- package/dist/common/utils.cjs +6 -14
- package/dist/common/utils.js +7 -13
- package/dist/feeds/atom/common/types.d.cts +65 -52
- package/dist/feeds/atom/common/types.d.ts +65 -52
- package/dist/feeds/atom/generate/index.cjs +2 -1
- package/dist/feeds/atom/generate/index.d.cts +2 -2
- package/dist/feeds/atom/generate/index.d.ts +2 -2
- package/dist/feeds/atom/generate/index.js +2 -1
- package/dist/feeds/atom/generate/utils.cjs +23 -6
- package/dist/feeds/atom/generate/utils.js +20 -3
- package/dist/feeds/atom/parse/index.cjs +10 -3
- package/dist/feeds/atom/parse/index.d.cts +2 -2
- package/dist/feeds/atom/parse/index.d.ts +2 -2
- package/dist/feeds/atom/parse/index.js +10 -3
- package/dist/feeds/atom/parse/utils.cjs +61 -31
- package/dist/feeds/atom/parse/utils.js +59 -29
- package/dist/feeds/json/common/types.d.cts +19 -19
- package/dist/feeds/json/common/types.d.ts +19 -19
- package/dist/feeds/json/generate/index.cjs +5 -1
- package/dist/feeds/json/generate/index.d.cts +2 -2
- package/dist/feeds/json/generate/index.d.ts +2 -2
- package/dist/feeds/json/generate/index.js +5 -1
- package/dist/feeds/json/generate/utils.cjs +7 -2
- package/dist/feeds/json/generate/utils.js +8 -3
- package/dist/feeds/json/parse/index.cjs +3 -2
- package/dist/feeds/json/parse/index.d.cts +2 -2
- package/dist/feeds/json/parse/index.d.ts +2 -2
- package/dist/feeds/json/parse/index.js +3 -2
- package/dist/feeds/json/parse/utils.cjs +4 -4
- package/dist/feeds/json/parse/utils.js +4 -4
- package/dist/feeds/rdf/common/types.d.cts +31 -28
- package/dist/feeds/rdf/common/types.d.ts +31 -28
- package/dist/feeds/rdf/parse/index.cjs +10 -3
- package/dist/feeds/rdf/parse/index.d.cts +2 -2
- package/dist/feeds/rdf/parse/index.d.ts +2 -2
- package/dist/feeds/rdf/parse/index.js +10 -3
- package/dist/feeds/rdf/parse/utils.cjs +23 -20
- package/dist/feeds/rdf/parse/utils.js +15 -12
- package/dist/feeds/rss/common/types.d.cts +76 -74
- package/dist/feeds/rss/common/types.d.ts +76 -74
- package/dist/feeds/rss/generate/index.cjs +2 -1
- package/dist/feeds/rss/generate/index.d.cts +2 -2
- package/dist/feeds/rss/generate/index.d.ts +2 -2
- package/dist/feeds/rss/generate/index.js +2 -1
- package/dist/feeds/rss/generate/utils.cjs +36 -36
- package/dist/feeds/rss/generate/utils.js +10 -10
- package/dist/feeds/rss/parse/index.cjs +10 -3
- package/dist/feeds/rss/parse/index.d.cts +2 -2
- package/dist/feeds/rss/parse/index.d.ts +2 -2
- package/dist/feeds/rss/parse/index.js +10 -3
- package/dist/feeds/rss/parse/utils.cjs +138 -38
- package/dist/feeds/rss/parse/utils.js +119 -19
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +37 -16
- package/dist/index.d.ts +37 -16
- package/dist/index.js +2 -1
- package/dist/namespaces/app/common/types.d.cts +1 -3
- package/dist/namespaces/app/common/types.d.ts +1 -3
- package/dist/namespaces/app/parse/utils.cjs +2 -2
- package/dist/namespaces/app/parse/utils.js +2 -2
- package/dist/namespaces/atom/common/types.d.cts +3 -3
- package/dist/namespaces/atom/common/types.d.ts +3 -3
- package/dist/namespaces/atom/parse/utils.cjs +4 -2
- package/dist/namespaces/atom/parse/utils.js +4 -2
- package/dist/namespaces/dc/common/types.d.cts +4 -19
- package/dist/namespaces/dc/common/types.d.ts +4 -19
- package/dist/namespaces/dc/generate/utils.cjs +15 -15
- package/dist/namespaces/dc/generate/utils.js +16 -16
- package/dist/namespaces/dc/parse/utils.cjs +4 -17
- package/dist/namespaces/dc/parse/utils.js +5 -18
- package/dist/namespaces/dcterms/common/types.d.cts +23 -59
- package/dist/namespaces/dcterms/common/types.d.ts +23 -59
- package/dist/namespaces/dcterms/generate/utils.cjs +55 -55
- package/dist/namespaces/dcterms/generate/utils.js +56 -56
- package/dist/namespaces/dcterms/parse/utils.cjs +23 -57
- package/dist/namespaces/dcterms/parse/utils.js +24 -58
- package/dist/namespaces/georss/common/types.d.cts +21 -19
- package/dist/namespaces/georss/common/types.d.ts +21 -19
- package/dist/namespaces/georss/generate/utils.cjs +2 -2
- package/dist/namespaces/georss/generate/utils.js +2 -2
- package/dist/namespaces/googleplay/common/types.d.cts +9 -7
- package/dist/namespaces/googleplay/common/types.d.ts +9 -7
- package/dist/namespaces/itunes/common/types.d.cts +9 -5
- package/dist/namespaces/itunes/common/types.d.ts +9 -5
- package/dist/namespaces/media/common/types.d.cts +85 -84
- package/dist/namespaces/media/common/types.d.ts +85 -84
- package/dist/namespaces/media/generate/utils.cjs +1 -1
- package/dist/namespaces/media/generate/utils.js +2 -2
- package/dist/namespaces/media/parse/utils.cjs +1 -2
- package/dist/namespaces/media/parse/utils.js +1 -2
- package/dist/namespaces/opensearch/common/types.d.cts +7 -5
- package/dist/namespaces/opensearch/common/types.d.ts +7 -5
- package/dist/namespaces/podcast/common/types.d.cts +136 -142
- package/dist/namespaces/podcast/common/types.d.ts +136 -142
- package/dist/namespaces/podcast/generate/utils.cjs +6 -6
- package/dist/namespaces/podcast/generate/utils.js +7 -7
- package/dist/namespaces/podcast/parse/utils.cjs +13 -19
- package/dist/namespaces/podcast/parse/utils.js +13 -19
- package/dist/namespaces/prism/common/types.d.cts +2 -4
- package/dist/namespaces/prism/common/types.d.ts +2 -4
- package/dist/namespaces/prism/parse/utils.cjs +19 -19
- package/dist/namespaces/prism/parse/utils.js +19 -19
- package/dist/namespaces/psc/common/types.d.cts +8 -6
- package/dist/namespaces/psc/common/types.d.ts +8 -6
- package/dist/namespaces/rawvoice/common/types.d.cts +24 -24
- package/dist/namespaces/rawvoice/common/types.d.ts +24 -24
- package/dist/namespaces/rawvoice/parse/utils.cjs +7 -7
- package/dist/namespaces/rawvoice/parse/utils.js +7 -7
- package/dist/namespaces/source/common/types.d.cts +20 -18
- package/dist/namespaces/source/common/types.d.ts +20 -18
- package/dist/namespaces/spotify/common/types.d.cts +22 -20
- package/dist/namespaces/spotify/common/types.d.ts +22 -20
- package/dist/namespaces/sy/common/types.d.cts +1 -3
- package/dist/namespaces/sy/common/types.d.ts +1 -3
- package/dist/namespaces/sy/parse/utils.cjs +2 -2
- package/dist/namespaces/sy/parse/utils.js +2 -2
- package/dist/namespaces/thr/common/types.d.cts +7 -7
- package/dist/namespaces/thr/common/types.d.ts +7 -7
- package/dist/namespaces/thr/parse/utils.cjs +2 -2
- package/dist/namespaces/thr/parse/utils.js +2 -2
- package/dist/namespaces/xml/common/types.d.cts +11 -0
- package/dist/namespaces/xml/common/types.d.ts +11 -0
- package/dist/namespaces/xml/generate/utils.cjs +13 -0
- package/dist/namespaces/xml/generate/utils.js +13 -0
- package/dist/namespaces/xml/parse/utils.cjs +13 -0
- package/dist/namespaces/xml/parse/utils.js +13 -0
- package/dist/opml/common/types.d.cts +18 -13
- package/dist/opml/common/types.d.ts +18 -13
- package/dist/opml/generate/index.cjs +2 -1
- package/dist/opml/generate/index.d.cts +3 -3
- package/dist/opml/generate/index.d.ts +3 -3
- package/dist/opml/generate/index.js +2 -1
- package/dist/opml/parse/index.cjs +9 -2
- package/dist/opml/parse/index.d.cts +2 -3
- package/dist/opml/parse/index.d.ts +2 -3
- package/dist/opml/parse/index.js +9 -2
- package/dist/opml/parse/utils.cjs +5 -5
- package/dist/opml/parse/utils.js +5 -5
- package/package.json +2 -19
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +0 -7
- package/dist/types.d.ts +0 -7
- package/dist/types.js +0 -1
package/README.md
CHANGED
|
@@ -18,13 +18,6 @@ Feedsmith offers universal and format‑specific parsers that maintain the origi
|
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
> [!IMPORTANT]
|
|
22
|
-
> **Feedsmith 3.x is in final stages of development.** Check out the [v3.x guide](https://v3.feedsmith.dev/migration/v2-to-v3) to explore new features and learn how to upgrade. Install it with:
|
|
23
|
-
>
|
|
24
|
-
> `npm install feedsmith@next`
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
21
|
## Features
|
|
29
22
|
|
|
30
23
|
### Core
|
|
@@ -53,7 +46,7 @@ Feedsmith offers universal and format‑specific parsers that maintain the origi
|
|
|
53
46
|
|
|
54
47
|
## Supported Formats
|
|
55
48
|
|
|
56
|
-
Feedsmith aims to fully support all major feed formats and namespaces in complete alignment with their
|
|
49
|
+
Feedsmith aims to fully support all major feed formats and namespaces in complete alignment with their specs.
|
|
57
50
|
|
|
58
51
|
✅ Available
|
|
59
52
|
·
|
|
@@ -112,6 +105,7 @@ Feedsmith aims to fully support all major feed formats and namespaces in complet
|
|
|
112
105
|
| [W3C Basic Geo](https://feedsmith.dev/reference/namespaces/geo) | `<geo:*>` | RSS, Atom | ✅ | ✅ |
|
|
113
106
|
| [GeoRSS Simple](https://feedsmith.dev/reference/namespaces/georss) | `<georss:*>` | RSS, Atom, RDF | ✅ | ✅ |
|
|
114
107
|
| [RDF](https://feedsmith.dev/reference/namespaces/rdf) | `<rdf:*>` | RDF | ✅ | ✅ |
|
|
108
|
+
| [XML](https://feedsmith.dev/reference/namespaces/xml) | `<xml:*>` | RSS, Atom, RDF | ✅ | ✅ |
|
|
115
109
|
|
|
116
110
|
## Quick Start
|
|
117
111
|
|
|
@@ -231,7 +225,7 @@ try {
|
|
|
231
225
|
Feedsmith provides comprehensive TypeScript types for all feed formats:
|
|
232
226
|
|
|
233
227
|
```typescript
|
|
234
|
-
import type { Rss, Atom, Json, Opml } from 'feedsmith
|
|
228
|
+
import type { Rss, Atom, Json, Opml } from 'feedsmith'
|
|
235
229
|
|
|
236
230
|
// Access all types for a format
|
|
237
231
|
type Feed = Rss.Feed
|
package/dist/common/config.cjs
CHANGED
|
@@ -62,7 +62,8 @@ const locales = {
|
|
|
62
62
|
invalidOpmlFormat: "Invalid OPML format",
|
|
63
63
|
invalidInputOpml: "Invalid input OPML",
|
|
64
64
|
invalidInputAtom: "Invalid input Atom",
|
|
65
|
-
invalidInputRss: "Invalid input RSS"
|
|
65
|
+
invalidInputRss: "Invalid input RSS",
|
|
66
|
+
invalidInputJson: "Invalid input JSON"
|
|
66
67
|
};
|
|
67
68
|
const namespaceUris = {
|
|
68
69
|
admin: require_config$1.uris,
|
package/dist/common/config.js
CHANGED
|
@@ -62,7 +62,8 @@ const locales = {
|
|
|
62
62
|
invalidOpmlFormat: "Invalid OPML format",
|
|
63
63
|
invalidInputOpml: "Invalid input OPML",
|
|
64
64
|
invalidInputAtom: "Invalid input Atom",
|
|
65
|
-
invalidInputRss: "Invalid input RSS"
|
|
65
|
+
invalidInputRss: "Invalid input RSS",
|
|
66
|
+
invalidInputJson: "Invalid input JSON"
|
|
66
67
|
};
|
|
67
68
|
const namespaceUris = {
|
|
68
69
|
admin: uris$1,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/common/errors.ts
|
|
2
|
+
var DetectError = class extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "DetectError";
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
var GenerateError = class extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "GenerateError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var MalformedError = class extends Error {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = "MalformedError";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var ParseError = class extends Error {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = "ParseError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.DetectError = DetectError;
|
|
28
|
+
exports.GenerateError = GenerateError;
|
|
29
|
+
exports.MalformedError = MalformedError;
|
|
30
|
+
exports.ParseError = ParseError;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/common/errors.d.ts
|
|
2
|
+
declare class DetectError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
declare class GenerateError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
declare class MalformedError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
declare class ParseError extends Error {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DetectError, GenerateError, MalformedError, ParseError };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/common/errors.d.ts
|
|
2
|
+
declare class DetectError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
declare class GenerateError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
declare class MalformedError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
declare class ParseError extends Error {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DetectError, GenerateError, MalformedError, ParseError };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/common/errors.ts
|
|
2
|
+
var DetectError = class extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "DetectError";
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
var GenerateError = class extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "GenerateError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var MalformedError = class extends Error {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = "MalformedError";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var ParseError = class extends Error {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = "ParseError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { DetectError, GenerateError, MalformedError, ParseError };
|
package/dist/common/parse.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_errors = require("./errors.cjs");
|
|
1
2
|
const require_config = require("./config.cjs");
|
|
2
3
|
const require_utils = require("./utils.cjs");
|
|
3
4
|
const require_index = require("../feeds/atom/detect/index.cjs");
|
|
@@ -27,7 +28,7 @@ const parse = (value, options) => {
|
|
|
27
28
|
format: "json",
|
|
28
29
|
feed: require_index$3.parse(json, options)
|
|
29
30
|
};
|
|
30
|
-
throw new
|
|
31
|
+
throw new require_errors.DetectError(require_config.locales.unrecognizedFeedFormat);
|
|
31
32
|
};
|
|
32
33
|
//#endregion
|
|
33
34
|
exports.parse = parse;
|
package/dist/common/parse.d.cts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ParseMainOptions } from "./types.cjs";
|
|
2
2
|
import { Atom } from "../feeds/atom/common/types.cjs";
|
|
3
3
|
import { Json } from "../feeds/json/common/types.cjs";
|
|
4
4
|
import { Rdf } from "../feeds/rdf/common/types.cjs";
|
|
5
5
|
import { Rss } from "../feeds/rss/common/types.cjs";
|
|
6
6
|
|
|
7
7
|
//#region src/common/parse.d.ts
|
|
8
|
-
|
|
9
|
-
format:
|
|
10
|
-
feed:
|
|
8
|
+
declare const parse: <TDate = string>(value: unknown, options?: ParseMainOptions<TDate>) => {
|
|
9
|
+
format: "rss";
|
|
10
|
+
feed: Rss.Feed<TDate>;
|
|
11
11
|
} | {
|
|
12
|
-
format:
|
|
13
|
-
feed:
|
|
12
|
+
format: "atom";
|
|
13
|
+
feed: Atom.Feed<TDate>;
|
|
14
14
|
} | {
|
|
15
|
-
format:
|
|
16
|
-
feed:
|
|
15
|
+
format: "rdf";
|
|
16
|
+
feed: Rdf.Feed<TDate>;
|
|
17
17
|
} | {
|
|
18
|
-
format:
|
|
19
|
-
feed:
|
|
18
|
+
format: "json";
|
|
19
|
+
feed: Json.Feed<TDate>;
|
|
20
20
|
};
|
|
21
|
-
declare const parse: Parse;
|
|
22
21
|
//#endregion
|
|
23
22
|
export { parse };
|
package/dist/common/parse.d.ts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ParseMainOptions } from "./types.js";
|
|
2
2
|
import { Atom } from "../feeds/atom/common/types.js";
|
|
3
3
|
import { Json } from "../feeds/json/common/types.js";
|
|
4
4
|
import { Rdf } from "../feeds/rdf/common/types.js";
|
|
5
5
|
import { Rss } from "../feeds/rss/common/types.js";
|
|
6
6
|
|
|
7
7
|
//#region src/common/parse.d.ts
|
|
8
|
-
|
|
9
|
-
format:
|
|
10
|
-
feed:
|
|
8
|
+
declare const parse: <TDate = string>(value: unknown, options?: ParseMainOptions<TDate>) => {
|
|
9
|
+
format: "rss";
|
|
10
|
+
feed: Rss.Feed<TDate>;
|
|
11
11
|
} | {
|
|
12
|
-
format:
|
|
13
|
-
feed:
|
|
12
|
+
format: "atom";
|
|
13
|
+
feed: Atom.Feed<TDate>;
|
|
14
14
|
} | {
|
|
15
|
-
format:
|
|
16
|
-
feed:
|
|
15
|
+
format: "rdf";
|
|
16
|
+
feed: Rdf.Feed<TDate>;
|
|
17
17
|
} | {
|
|
18
|
-
format:
|
|
19
|
-
feed:
|
|
18
|
+
format: "json";
|
|
19
|
+
feed: Json.Feed<TDate>;
|
|
20
20
|
};
|
|
21
|
-
declare const parse: Parse;
|
|
22
21
|
//#endregion
|
|
23
22
|
export { parse };
|
package/dist/common/parse.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DetectError } from "./errors.js";
|
|
1
2
|
import { locales } from "./config.js";
|
|
2
3
|
import { parseJsonObject } from "./utils.js";
|
|
3
4
|
import { detect } from "../feeds/atom/detect/index.js";
|
|
@@ -27,7 +28,7 @@ const parse = (value, options) => {
|
|
|
27
28
|
format: "json",
|
|
28
29
|
feed: parse$2(json, options)
|
|
29
30
|
};
|
|
30
|
-
throw new
|
|
31
|
+
throw new DetectError(locales.unrecognizedFeedFormat);
|
|
31
32
|
};
|
|
32
33
|
//#endregion
|
|
33
34
|
export { parse };
|
package/dist/common/types.d.cts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
//#region src/common/types.d.ts
|
|
2
|
-
type
|
|
3
|
-
type
|
|
2
|
+
type Simplify<T> = { [K in keyof T]: T[K] };
|
|
3
|
+
type Unwrap<T> = T extends {
|
|
4
|
+
__requirable: infer U;
|
|
5
|
+
} ? U : T;
|
|
6
|
+
type HasMarker<T> = [Extract<T, {
|
|
7
|
+
__requirable: unknown;
|
|
8
|
+
}>] extends [never] ? false : true;
|
|
9
|
+
type Optional<T> = { [K in keyof T]-?: object extends Pick<T, K> ? K : never }[keyof T];
|
|
10
|
+
type Marked<T> = { [K in keyof T]-?: HasMarker<T[K]> extends true ? K : never }[keyof T];
|
|
11
|
+
type Strict<T, S extends boolean> = Simplify<S extends true ? { [K in Exclude<keyof T, Optional<T>>]-?: Unwrap<T[K]> } & { [K in Optional<T>]?: Unwrap<T[K]> } : { [K in Exclude<keyof T, Optional<T> | Marked<T>>]-?: Unwrap<T[K]> } & { [K in Optional<T> | Marked<T>]?: Unwrap<T[K]> }>;
|
|
4
12
|
type IsPlainObject<T> = T extends Array<unknown> ? false : T extends ((...args: Array<unknown>) => unknown) ? false : T extends Date ? false : T extends object ? T extends null ? false : true : false;
|
|
5
|
-
type RemoveUndefined<T> = T extends undefined ? never : T;
|
|
6
|
-
type DeepPartial<T> = IsPlainObject<T> extends true ? { [P in keyof T]?: DeepPartial<RemoveUndefined<T[P]>> } : T extends Array<infer U> ? Array<DeepPartial<U>> : T;
|
|
7
13
|
type DeepOmit<T, K extends string> = T extends Array<infer U> ? Array<DeepOmit<U, K>> : IsPlainObject<T> extends true ? Pick<{ [P in keyof T]: DeepOmit<T[P], K> }, Exclude<keyof T, K>> : T;
|
|
8
|
-
type
|
|
14
|
+
type Requirable<T> = T | {
|
|
15
|
+
__requirable: T;
|
|
16
|
+
};
|
|
17
|
+
type DateLike = Date | string;
|
|
18
|
+
type ExtraFields<F extends ReadonlyArray<string>, V = unknown> = { [K in F[number]]?: V };
|
|
19
|
+
type ParseMainOptions<TDate> = {
|
|
9
20
|
maxItems?: number;
|
|
21
|
+
parseDateFn?: (raw: string) => TDate;
|
|
10
22
|
};
|
|
11
23
|
type XmlStylesheet = {
|
|
12
24
|
type: string;
|
|
@@ -16,14 +28,14 @@ type XmlStylesheet = {
|
|
|
16
28
|
charset?: string;
|
|
17
29
|
alternate?: boolean;
|
|
18
30
|
};
|
|
19
|
-
type
|
|
20
|
-
|
|
31
|
+
type GenerateMainXmlOptions<O, S extends boolean> = O & {
|
|
32
|
+
strict?: S;
|
|
21
33
|
stylesheets?: Array<XmlStylesheet>;
|
|
22
34
|
};
|
|
23
|
-
type
|
|
24
|
-
|
|
35
|
+
type GenerateMainXml<LV, SV, O = Record<string, unknown>> = <S extends boolean = false>(value: S extends true ? SV : LV, options?: GenerateMainXmlOptions<O, S>) => string;
|
|
36
|
+
type GenerateMainJsonOptions<O, S extends boolean> = O & {
|
|
37
|
+
strict?: S;
|
|
25
38
|
};
|
|
26
|
-
type
|
|
27
|
-
type JsonGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: JsonGenerateOptions<O, F>) => unknown;
|
|
39
|
+
type GenerateMainJson<LV, SV, O = Record<string, unknown>> = <S extends boolean = false>(value: S extends true ? SV : LV, options?: GenerateMainJsonOptions<O, S>) => unknown;
|
|
28
40
|
//#endregion
|
|
29
|
-
export { DateLike, DeepOmit,
|
|
41
|
+
export { DateLike, DeepOmit, ExtraFields, GenerateMainJson, GenerateMainXml, GenerateMainXmlOptions, ParseMainOptions, Requirable, Strict, XmlStylesheet };
|
package/dist/common/types.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
//#region src/common/types.d.ts
|
|
2
|
-
type
|
|
3
|
-
type
|
|
2
|
+
type Simplify<T> = { [K in keyof T]: T[K] };
|
|
3
|
+
type Unwrap<T> = T extends {
|
|
4
|
+
__requirable: infer U;
|
|
5
|
+
} ? U : T;
|
|
6
|
+
type HasMarker<T> = [Extract<T, {
|
|
7
|
+
__requirable: unknown;
|
|
8
|
+
}>] extends [never] ? false : true;
|
|
9
|
+
type Optional<T> = { [K in keyof T]-?: object extends Pick<T, K> ? K : never }[keyof T];
|
|
10
|
+
type Marked<T> = { [K in keyof T]-?: HasMarker<T[K]> extends true ? K : never }[keyof T];
|
|
11
|
+
type Strict<T, S extends boolean> = Simplify<S extends true ? { [K in Exclude<keyof T, Optional<T>>]-?: Unwrap<T[K]> } & { [K in Optional<T>]?: Unwrap<T[K]> } : { [K in Exclude<keyof T, Optional<T> | Marked<T>>]-?: Unwrap<T[K]> } & { [K in Optional<T> | Marked<T>]?: Unwrap<T[K]> }>;
|
|
4
12
|
type IsPlainObject<T> = T extends Array<unknown> ? false : T extends ((...args: Array<unknown>) => unknown) ? false : T extends Date ? false : T extends object ? T extends null ? false : true : false;
|
|
5
|
-
type RemoveUndefined<T> = T extends undefined ? never : T;
|
|
6
|
-
type DeepPartial<T> = IsPlainObject<T> extends true ? { [P in keyof T]?: DeepPartial<RemoveUndefined<T[P]>> } : T extends Array<infer U> ? Array<DeepPartial<U>> : T;
|
|
7
13
|
type DeepOmit<T, K extends string> = T extends Array<infer U> ? Array<DeepOmit<U, K>> : IsPlainObject<T> extends true ? Pick<{ [P in keyof T]: DeepOmit<T[P], K> }, Exclude<keyof T, K>> : T;
|
|
8
|
-
type
|
|
14
|
+
type Requirable<T> = T | {
|
|
15
|
+
__requirable: T;
|
|
16
|
+
};
|
|
17
|
+
type DateLike = Date | string;
|
|
18
|
+
type ExtraFields<F extends ReadonlyArray<string>, V = unknown> = { [K in F[number]]?: V };
|
|
19
|
+
type ParseMainOptions<TDate> = {
|
|
9
20
|
maxItems?: number;
|
|
21
|
+
parseDateFn?: (raw: string) => TDate;
|
|
10
22
|
};
|
|
11
23
|
type XmlStylesheet = {
|
|
12
24
|
type: string;
|
|
@@ -16,14 +28,14 @@ type XmlStylesheet = {
|
|
|
16
28
|
charset?: string;
|
|
17
29
|
alternate?: boolean;
|
|
18
30
|
};
|
|
19
|
-
type
|
|
20
|
-
|
|
31
|
+
type GenerateMainXmlOptions<O, S extends boolean> = O & {
|
|
32
|
+
strict?: S;
|
|
21
33
|
stylesheets?: Array<XmlStylesheet>;
|
|
22
34
|
};
|
|
23
|
-
type
|
|
24
|
-
|
|
35
|
+
type GenerateMainXml<LV, SV, O = Record<string, unknown>> = <S extends boolean = false>(value: S extends true ? SV : LV, options?: GenerateMainXmlOptions<O, S>) => string;
|
|
36
|
+
type GenerateMainJsonOptions<O, S extends boolean> = O & {
|
|
37
|
+
strict?: S;
|
|
25
38
|
};
|
|
26
|
-
type
|
|
27
|
-
type JsonGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: JsonGenerateOptions<O, F>) => unknown;
|
|
39
|
+
type GenerateMainJson<LV, SV, O = Record<string, unknown>> = <S extends boolean = false>(value: S extends true ? SV : LV, options?: GenerateMainJsonOptions<O, S>) => unknown;
|
|
28
40
|
//#endregion
|
|
29
|
-
export { DateLike, DeepOmit,
|
|
41
|
+
export { DateLike, DeepOmit, ExtraFields, GenerateMainJson, GenerateMainXml, GenerateMainXmlOptions, ParseMainOptions, Requirable, Strict, XmlStylesheet };
|
package/dist/common/utils.cjs
CHANGED
|
@@ -59,18 +59,10 @@ const trimArray = (value, parse) => {
|
|
|
59
59
|
}
|
|
60
60
|
return result.length > 0 ? result : void 0;
|
|
61
61
|
};
|
|
62
|
-
const generateArrayOrSingular = (pluralValues, singularValue, generator) => {
|
|
63
|
-
if (isPresent(pluralValues)) return trimArray(pluralValues.map(generator));
|
|
64
|
-
if (isPresent(singularValue)) return generator(singularValue);
|
|
65
|
-
};
|
|
66
|
-
const generateSingularOrArray = (singularValue, pluralValues, generator) => {
|
|
67
|
-
if (isPresent(singularValue)) return generator(singularValue);
|
|
68
|
-
if (isPresent(pluralValues)) return trimArray(pluralValues.map(generator));
|
|
69
|
-
};
|
|
70
|
-
const commentStartTag = "<!--";
|
|
71
|
-
const commentEndTag = "-->";
|
|
72
62
|
const cdataStartTag = "<![CDATA[";
|
|
73
63
|
const cdataEndTag = "]]>";
|
|
64
|
+
const commentStartTag = "<!--";
|
|
65
|
+
const commentEndTag = "-->";
|
|
74
66
|
const hasEntities = (text) => {
|
|
75
67
|
const ampIndex = text.indexOf("&");
|
|
76
68
|
return ampIndex !== -1 && text.indexOf(";", ampIndex) !== -1;
|
|
@@ -137,8 +129,10 @@ const parseYesNoBoolean = (value) => {
|
|
|
137
129
|
if (boolean !== void 0) return boolean;
|
|
138
130
|
if (isNonEmptyString(value)) return yesRegex.test(value);
|
|
139
131
|
};
|
|
140
|
-
const parseDate = (value) => {
|
|
141
|
-
|
|
132
|
+
const parseDate = (value, parseDateFn) => {
|
|
133
|
+
const raw = parseString(value);
|
|
134
|
+
if (raw === void 0) return;
|
|
135
|
+
return parseDateFn ? parseDateFn(raw) : raw;
|
|
142
136
|
};
|
|
143
137
|
const parseArray = (value) => {
|
|
144
138
|
if (Array.isArray(value)) return value;
|
|
@@ -439,7 +433,6 @@ const expandStopNodes = (stopNodes, feedContainerPaths) => {
|
|
|
439
433
|
exports.createNamespaceNormalizator = createNamespaceNormalizator;
|
|
440
434
|
exports.detectNamespaces = detectNamespaces;
|
|
441
435
|
exports.expandStopNodes = expandStopNodes;
|
|
442
|
-
exports.generateArrayOrSingular = generateArrayOrSingular;
|
|
443
436
|
exports.generateBoolean = generateBoolean;
|
|
444
437
|
exports.generateCdataString = generateCdataString;
|
|
445
438
|
exports.generateCsvOf = generateCsvOf;
|
|
@@ -449,7 +442,6 @@ exports.generatePlainString = generatePlainString;
|
|
|
449
442
|
exports.generateRdfResource = generateRdfResource;
|
|
450
443
|
exports.generateRfc3339Date = generateRfc3339Date;
|
|
451
444
|
exports.generateRfc822Date = generateRfc822Date;
|
|
452
|
-
exports.generateSingularOrArray = generateSingularOrArray;
|
|
453
445
|
exports.generateTextOrCdataString = generateTextOrCdataString;
|
|
454
446
|
exports.generateXml = generateXml;
|
|
455
447
|
exports.generateYesNoBoolean = generateYesNoBoolean;
|
package/dist/common/utils.js
CHANGED
|
@@ -59,18 +59,10 @@ const trimArray = (value, parse) => {
|
|
|
59
59
|
}
|
|
60
60
|
return result.length > 0 ? result : void 0;
|
|
61
61
|
};
|
|
62
|
-
const generateArrayOrSingular = (pluralValues, singularValue, generator) => {
|
|
63
|
-
if (isPresent(pluralValues)) return trimArray(pluralValues.map(generator));
|
|
64
|
-
if (isPresent(singularValue)) return generator(singularValue);
|
|
65
|
-
};
|
|
66
|
-
const generateSingularOrArray = (singularValue, pluralValues, generator) => {
|
|
67
|
-
if (isPresent(singularValue)) return generator(singularValue);
|
|
68
|
-
if (isPresent(pluralValues)) return trimArray(pluralValues.map(generator));
|
|
69
|
-
};
|
|
70
|
-
const commentStartTag = "<!--";
|
|
71
|
-
const commentEndTag = "-->";
|
|
72
62
|
const cdataStartTag = "<![CDATA[";
|
|
73
63
|
const cdataEndTag = "]]>";
|
|
64
|
+
const commentStartTag = "<!--";
|
|
65
|
+
const commentEndTag = "-->";
|
|
74
66
|
const hasEntities = (text) => {
|
|
75
67
|
const ampIndex = text.indexOf("&");
|
|
76
68
|
return ampIndex !== -1 && text.indexOf(";", ampIndex) !== -1;
|
|
@@ -137,8 +129,10 @@ const parseYesNoBoolean = (value) => {
|
|
|
137
129
|
if (boolean !== void 0) return boolean;
|
|
138
130
|
if (isNonEmptyString(value)) return yesRegex.test(value);
|
|
139
131
|
};
|
|
140
|
-
const parseDate = (value) => {
|
|
141
|
-
|
|
132
|
+
const parseDate = (value, parseDateFn) => {
|
|
133
|
+
const raw = parseString(value);
|
|
134
|
+
if (raw === void 0) return;
|
|
135
|
+
return parseDateFn ? parseDateFn(raw) : raw;
|
|
142
136
|
};
|
|
143
137
|
const parseArray = (value) => {
|
|
144
138
|
if (Array.isArray(value)) return value;
|
|
@@ -436,4 +430,4 @@ const expandStopNodes = (stopNodes, feedContainerPaths) => {
|
|
|
436
430
|
return [...set];
|
|
437
431
|
};
|
|
438
432
|
//#endregion
|
|
439
|
-
export { createNamespaceNormalizator, detectNamespaces, expandStopNodes,
|
|
433
|
+
export { createNamespaceNormalizator, detectNamespaces, expandStopNodes, generateBoolean, generateCdataString, generateCsvOf, generateNamespaceAttrs, generateNumber, generatePlainString, generateRdfResource, generateRfc3339Date, generateRfc822Date, generateTextOrCdataString, generateXml, generateYesNoBoolean, isNonEmptyString, isNonEmptyStringOrNumber, isObject, isPresent, parseArrayOf, parseBoolean, parseCsvOf, parseDate, parseJsonObject, parseNumber, parseSingular, parseSingularOf, parseString, parseYesNoBoolean, retrieveRdfResourceOrText, retrieveText, trimArray, trimObject };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Requirable, Strict } from "../../../common/types.cjs";
|
|
2
2
|
import { AdminNs } from "../../../namespaces/admin/common/types.cjs";
|
|
3
3
|
import { AppNs } from "../../../namespaces/app/common/types.cjs";
|
|
4
4
|
import { ArxivNs } from "../../../namespaces/arxiv/common/types.cjs";
|
|
@@ -19,111 +19,124 @@ import { SyNs } from "../../../namespaces/sy/common/types.cjs";
|
|
|
19
19
|
import { ThrNs } from "../../../namespaces/thr/common/types.cjs";
|
|
20
20
|
import { TrackbackNs } from "../../../namespaces/trackback/common/types.cjs";
|
|
21
21
|
import { WfwNs } from "../../../namespaces/wfw/common/types.cjs";
|
|
22
|
+
import { XmlNs } from "../../../namespaces/xml/common/types.cjs";
|
|
22
23
|
import { YtNs } from "../../../namespaces/yt/common/types.cjs";
|
|
23
24
|
|
|
24
25
|
//#region src/feeds/atom/common/types.d.ts
|
|
25
26
|
declare namespace Atom {
|
|
26
|
-
type Text =
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
type Text = {
|
|
28
|
+
value: string;
|
|
29
|
+
type?: string;
|
|
30
|
+
xml?: XmlNs.ItemOrFeed;
|
|
31
|
+
};
|
|
32
|
+
type Content = {
|
|
33
|
+
value?: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
src?: string;
|
|
36
|
+
xml?: XmlNs.ItemOrFeed;
|
|
37
|
+
};
|
|
38
|
+
type Link<TDate, TStrict extends boolean = false> = Strict<{
|
|
39
|
+
href: Requirable<string>;
|
|
29
40
|
rel?: string;
|
|
30
41
|
type?: string;
|
|
31
42
|
hreflang?: string;
|
|
32
43
|
title?: string;
|
|
33
44
|
length?: number;
|
|
34
45
|
thr?: ThrNs.Link<TDate>;
|
|
35
|
-
}
|
|
36
|
-
type Person = {
|
|
37
|
-
name: string
|
|
46
|
+
}, TStrict>;
|
|
47
|
+
type Person<TStrict extends boolean = false> = Strict<{
|
|
48
|
+
name: Requirable<string>;
|
|
38
49
|
uri?: string;
|
|
39
50
|
email?: string;
|
|
40
51
|
arxiv?: ArxivNs.Author;
|
|
41
|
-
}
|
|
42
|
-
type Category = {
|
|
43
|
-
term: string
|
|
52
|
+
}, TStrict>;
|
|
53
|
+
type Category<TStrict extends boolean = false> = Strict<{
|
|
54
|
+
term: Requirable<string>;
|
|
44
55
|
scheme?: string;
|
|
45
56
|
label?: string;
|
|
46
|
-
}
|
|
47
|
-
type Generator = {
|
|
48
|
-
text: string
|
|
57
|
+
}, TStrict>;
|
|
58
|
+
type Generator<TStrict extends boolean = false> = Strict<{
|
|
59
|
+
text: Requirable<string>;
|
|
49
60
|
uri?: string;
|
|
50
61
|
version?: string;
|
|
51
|
-
}
|
|
52
|
-
type Source<TDate extends
|
|
53
|
-
authors?: Array<Person
|
|
54
|
-
categories?: Array<Category
|
|
55
|
-
contributors?: Array<Person
|
|
56
|
-
generator?: Generator
|
|
62
|
+
}, TStrict>;
|
|
63
|
+
type Source<TDate, TStrict extends boolean = false> = {
|
|
64
|
+
authors?: Array<Person<TStrict>>;
|
|
65
|
+
categories?: Array<Category<TStrict>>;
|
|
66
|
+
contributors?: Array<Person<TStrict>>;
|
|
67
|
+
generator?: Generator<TStrict>;
|
|
57
68
|
icon?: string;
|
|
58
69
|
id?: string;
|
|
59
|
-
links?: Array<Link<TDate>>;
|
|
70
|
+
links?: Array<Link<TDate, TStrict>>;
|
|
60
71
|
logo?: string;
|
|
61
72
|
rights?: Text;
|
|
62
73
|
subtitle?: Text;
|
|
63
74
|
title?: Text;
|
|
64
75
|
updated?: TDate;
|
|
65
76
|
};
|
|
66
|
-
type Entry<TDate extends
|
|
67
|
-
authors?: Array<Person
|
|
68
|
-
categories?: Array<Category
|
|
69
|
-
content?:
|
|
70
|
-
contributors?: Array<Person
|
|
71
|
-
id: string
|
|
72
|
-
links?: Array<Link<TDate>>;
|
|
77
|
+
type Entry<TDate, TStrict extends boolean = false> = Strict<{
|
|
78
|
+
authors?: Array<Person<TStrict>>;
|
|
79
|
+
categories?: Array<Category<TStrict>>;
|
|
80
|
+
content?: Content;
|
|
81
|
+
contributors?: Array<Person<TStrict>>;
|
|
82
|
+
id: Requirable<string>;
|
|
83
|
+
links?: Array<Link<TDate, TStrict>>;
|
|
73
84
|
published?: TDate;
|
|
74
85
|
rights?: Text;
|
|
75
|
-
source?: Source<TDate>;
|
|
86
|
+
source?: Source<TDate, TStrict>;
|
|
76
87
|
summary?: Text;
|
|
77
|
-
title: Text
|
|
78
|
-
updated: TDate
|
|
88
|
+
title: Requirable<Text>;
|
|
89
|
+
updated: Requirable<TDate>;
|
|
79
90
|
app?: AppNs.Entry<TDate>;
|
|
80
91
|
arxiv?: ArxivNs.Entry;
|
|
81
92
|
cc?: CcNs.ItemOrFeed;
|
|
82
93
|
dc?: DcNs.ItemOrFeed<TDate>;
|
|
83
94
|
slash?: SlashNs.Item;
|
|
84
95
|
itunes?: ItunesNs.Item;
|
|
85
|
-
googleplay?: GooglePlayNs.Item
|
|
86
|
-
psc?: PscNs.Item
|
|
87
|
-
media?: MediaNs.ItemOrFeed
|
|
88
|
-
georss?: GeoRssNs.ItemOrFeed
|
|
96
|
+
googleplay?: GooglePlayNs.Item<TStrict>;
|
|
97
|
+
psc?: PscNs.Item<TStrict>;
|
|
98
|
+
media?: MediaNs.ItemOrFeed<TStrict>;
|
|
99
|
+
georss?: GeoRssNs.ItemOrFeed<TStrict>;
|
|
89
100
|
geo?: GeoNs.ItemOrFeed;
|
|
90
|
-
thr?: ThrNs.Item
|
|
101
|
+
thr?: ThrNs.Item<TStrict>;
|
|
91
102
|
dcterms?: DcTermsNs.ItemOrFeed<TDate>;
|
|
92
103
|
creativeCommons?: CreativeCommonsNs.ItemOrFeed;
|
|
93
104
|
wfw?: WfwNs.Item;
|
|
94
105
|
yt?: YtNs.Item;
|
|
95
106
|
pingback?: PingbackNs.Item;
|
|
96
107
|
trackback?: TrackbackNs.Item;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
xml?: XmlNs.ItemOrFeed;
|
|
109
|
+
}, TStrict>;
|
|
110
|
+
type Feed<TDate, TStrict extends boolean = false> = Strict<{
|
|
111
|
+
authors?: Array<Person<TStrict>>;
|
|
112
|
+
categories?: Array<Category<TStrict>>;
|
|
113
|
+
contributors?: Array<Person<TStrict>>;
|
|
114
|
+
generator?: Generator<TStrict>;
|
|
103
115
|
icon?: string;
|
|
104
|
-
id: string
|
|
105
|
-
links?: Array<Link<TDate>>;
|
|
116
|
+
id: Requirable<string>;
|
|
117
|
+
links?: Array<Link<TDate, TStrict>>;
|
|
106
118
|
logo?: string;
|
|
107
119
|
rights?: Text;
|
|
108
120
|
subtitle?: Text;
|
|
109
|
-
title: Text
|
|
110
|
-
updated: TDate
|
|
111
|
-
entries?: Array<Entry<TDate>>;
|
|
121
|
+
title: Requirable<Text>;
|
|
122
|
+
updated: Requirable<TDate>;
|
|
123
|
+
entries?: Array<Entry<TDate, TStrict>>;
|
|
112
124
|
cc?: CcNs.ItemOrFeed;
|
|
113
125
|
dc?: DcNs.ItemOrFeed<TDate>;
|
|
114
126
|
sy?: SyNs.Feed<TDate>;
|
|
115
|
-
itunes?: ItunesNs.Feed
|
|
116
|
-
googleplay?: GooglePlayNs.Feed
|
|
117
|
-
media?: MediaNs.ItemOrFeed
|
|
118
|
-
georss?: GeoRssNs.ItemOrFeed
|
|
127
|
+
itunes?: ItunesNs.Feed<TStrict>;
|
|
128
|
+
googleplay?: GooglePlayNs.Feed<TStrict>;
|
|
129
|
+
media?: MediaNs.ItemOrFeed<TStrict>;
|
|
130
|
+
georss?: GeoRssNs.ItemOrFeed<TStrict>;
|
|
119
131
|
geo?: GeoNs.ItemOrFeed;
|
|
120
132
|
dcterms?: DcTermsNs.ItemOrFeed<TDate>;
|
|
121
133
|
creativeCommons?: CreativeCommonsNs.ItemOrFeed;
|
|
122
|
-
opensearch?: OpenSearchNs.Feed
|
|
134
|
+
opensearch?: OpenSearchNs.Feed<TStrict>;
|
|
123
135
|
yt?: YtNs.Feed;
|
|
124
136
|
admin?: AdminNs.Feed;
|
|
125
137
|
pingback?: PingbackNs.Feed;
|
|
126
|
-
|
|
138
|
+
xml?: XmlNs.ItemOrFeed;
|
|
139
|
+
}, TStrict>;
|
|
127
140
|
}
|
|
128
141
|
//#endregion
|
|
129
142
|
export { Atom };
|