@rmdes/indiekit-endpoint-syndicate 1.0.0-beta.41 → 1.0.0-beta.43
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 +4 -12
- package/lib/utils.js +10 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
# @rmdes/indiekit-endpoint-syndicate
|
|
2
2
|
|
|
3
|
-
Syndication endpoint for Indiekit. Fork of @indiekit/endpoint-syndicate with batch syndication support
|
|
3
|
+
Syndication endpoint for Indiekit. Fork of @indiekit/endpoint-syndicate with batch syndication support.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Single Post Syndication** - Syndicate a specific post to configured targets
|
|
8
8
|
- **Batch Syndication** - Process all pending posts at once (useful for cron jobs)
|
|
9
9
|
- **Webhook Support** - Netlify webhook signature verification
|
|
10
|
-
- **Partial Syndication** - Correctly handles posts partially syndicated (fixed upstream bug)
|
|
11
10
|
- **Failed Target Retry** - Automatically retries failed syndication targets
|
|
12
11
|
- **Rate Limiting** - 2-second delay between posts in batch mode
|
|
13
12
|
- **Detailed Results** - Per-post success/failure tracking in batch mode
|
|
14
13
|
|
|
15
|
-
##
|
|
14
|
+
## Differences from upstream
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
1. **Array.isArray Bug** - Fixed function reference bug that prevented correct array detection
|
|
20
|
-
2. **Partial Syndication** - Removed filter that prevented retry of partially syndicated posts
|
|
21
|
-
3. **Enhanced Error Handling** - Per-post error tracking instead of failing entire batch
|
|
22
|
-
|
|
23
|
-
### New Features
|
|
16
|
+
The `Array.isArray` and partial-syndication fixes this fork once carried are in upstream since 1.0.0-beta.29; the fork tracks upstream for them. What remains fork-only:
|
|
24
17
|
|
|
25
18
|
- Batch mode for processing all pending posts
|
|
26
|
-
- Detailed results array with success/failure per post
|
|
27
|
-
- Better console logging for debugging
|
|
19
|
+
- Detailed results array with success/failure per post, instead of failing the whole batch on one error
|
|
28
20
|
|
|
29
21
|
## Installation
|
|
30
22
|
|
package/lib/utils.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Get post data for a single post
|
|
3
3
|
* @param {object} postsCollection - Posts database collection
|
|
4
4
|
* @param {string} url - URL of existing post (optional)
|
|
5
|
-
* @returns {Promise<object>} Post data for given URL else
|
|
5
|
+
* @returns {Promise<object>} Post data for given URL else oldest post awaiting syndication
|
|
6
6
|
*/
|
|
7
7
|
export const getPostData = async (postsCollection, url) => {
|
|
8
8
|
if (url) {
|
|
@@ -15,7 +15,8 @@ export const getPostData = async (postsCollection, url) => {
|
|
|
15
15
|
// deleted once every target has returned a URL, and replaced with the
|
|
16
16
|
// targets that failed otherwise. Posts already syndicated to some of their
|
|
17
17
|
// targets are therefore still awaiting the rest, and `syndicateToTargets`
|
|
18
|
-
// skips the ones already done.
|
|
18
|
+
// skips the ones already done. Oldest first, so a backlog is syndicated in
|
|
19
|
+
// the order it was published.
|
|
19
20
|
const items = await postsCollection
|
|
20
21
|
.find({
|
|
21
22
|
"properties.mp-syndicate-to": {
|
|
@@ -25,7 +26,7 @@ export const getPostData = async (postsCollection, url) => {
|
|
|
25
26
|
$ne: "draft",
|
|
26
27
|
},
|
|
27
28
|
})
|
|
28
|
-
.sort({ "properties.published":
|
|
29
|
+
.sort({ "properties.published": 1 })
|
|
29
30
|
.limit(1)
|
|
30
31
|
.toArray();
|
|
31
32
|
|
|
@@ -63,12 +64,13 @@ export const getAllPostData = async (postsCollection) => {
|
|
|
63
64
|
*/
|
|
64
65
|
export const hasSyndicationUrl = (syndicatedUrls, syndicateTo) => {
|
|
65
66
|
return syndicatedUrls.some((url) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return syndicateTo.includes(origin);
|
|
69
|
-
} catch {
|
|
67
|
+
// `syndication` is stored as given, so may hold values that aren’t URLs
|
|
68
|
+
if (!URL.canParse(url)) {
|
|
70
69
|
return false;
|
|
71
70
|
}
|
|
71
|
+
|
|
72
|
+
const { origin } = new URL(url);
|
|
73
|
+
return syndicateTo.includes(origin);
|
|
72
74
|
});
|
|
73
75
|
};
|
|
74
76
|
|
|
@@ -208,7 +210,7 @@ export const syndicateToTargets = async (
|
|
|
208
210
|
} catch (error) {
|
|
209
211
|
// Add failed syndication target to list of failed targets
|
|
210
212
|
failedTargets.push(target.info.uid);
|
|
211
|
-
console.error(error
|
|
213
|
+
console.error(error);
|
|
212
214
|
}
|
|
213
215
|
}
|
|
214
216
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-syndicate",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.43",
|
|
4
4
|
"description": "Syndication endpoint for Indiekit. Fork of @indiekit/endpoint-syndicate with batch syndication support and bug fixes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"indiekit",
|