@seedprotocol/feed 0.7.0 → 0.7.2-next.593.gd5bd4ea
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/dist/getFeedItems.d.ts.map +1 -1
- package/dist/index.js +269 -322
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
package/dist/index.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import { BaseArweaveClient as e, DEFAULT_ARWEAVE_HOST as t, DEFAULT_ARWEAVE_HOST as n, SEED_RSS_IMAGE_RELATION_FIELD_KEYS as r, classifyMediaRef as i, ensureArweaveReadGatewayForFallback as a, getArweaveReadBaseUrls as o, getArweaveReadGatewayHostsForPrimary as s, getFeedItemStringField as c, isEasAttestationExplorerUrl as l, isGatewayHostCircuitOpen as u, normalizeFeedItemFields as d, recordGatewayHostFailure as f, recordGatewayHostSuccess as p, resolveArweaveHostFromEnv as m, resolveSeedRssImageRelationFromItem as h, resolveSeedRssImageRelationRef as g, resolveSeedRssImageRelationRef as _ } from "@seedprotocol/arweave";
|
|
2
|
-
import { FEED_RICH_BODY_STORAGE_SCHEMAS as v, enrichImageSeedCloneForFeed as y, feedRichBodyModelPriority as b, getArweaveUrlForTransaction as ee, getFeedFieldStorageModels as
|
|
3
|
-
import { getEasChainDeployment as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { generateAtomFeed as
|
|
7
|
-
import { create as
|
|
8
|
-
import { createHash as
|
|
9
|
-
import { promises as
|
|
10
|
-
import { join as
|
|
11
|
-
import
|
|
2
|
+
import { FEED_RICH_BODY_STORAGE_SCHEMAS as v, enrichImageSeedCloneForFeed as y, feedRichBodyModelPriority as b, getArweaveUrlForTransaction as ee, getFeedFieldStorageModels as te, getFeedListElementStorageModels as ne, isFeedRichBodyStorageSchema as x, queryBySchema as re, queryBySchemaForMonth as ie } from "@seedprotocol/query";
|
|
3
|
+
import { getEasChainDeployment as ae, getEasReadChainId as oe } from "@seedprotocol/eas";
|
|
4
|
+
import se from "rss-parser";
|
|
5
|
+
import S from "pluralize";
|
|
6
|
+
import { generateAtomFeed as ce, generateJsonFeed as le } from "feedsmith";
|
|
7
|
+
import { create as ue } from "xmlbuilder2";
|
|
8
|
+
import { createHash as de } from "crypto";
|
|
9
|
+
import { promises as C } from "fs";
|
|
10
|
+
import { join as w } from "path";
|
|
11
|
+
import fe from "image-size";
|
|
12
12
|
//#region src/bootstrap.ts
|
|
13
|
-
var
|
|
14
|
-
function
|
|
13
|
+
var T = !1;
|
|
14
|
+
function pe(e) {
|
|
15
15
|
return e ?? m() ?? n;
|
|
16
16
|
}
|
|
17
|
-
async function
|
|
18
|
-
if (
|
|
17
|
+
async function E(e) {
|
|
18
|
+
if (T) return;
|
|
19
19
|
let [{ registerNodeEasPlatform: t }, { registerNodeArweavePlatform: n }] = await Promise.all([import("@seedprotocol/eas/node"), import("@seedprotocol/arweave/node")]);
|
|
20
|
-
if (t(), n({ arweaveDomain:
|
|
20
|
+
if (t(), n({ arweaveDomain: pe(e?.arweaveDomain) }), e?.arweaveDomain) {
|
|
21
21
|
let { BaseArweaveClient: t } = await import("@seedprotocol/arweave");
|
|
22
22
|
t.setHost(e.arweaveDomain);
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
T = !0;
|
|
25
25
|
}
|
|
26
|
-
var
|
|
27
|
-
async function
|
|
28
|
-
return await
|
|
26
|
+
var me = E;
|
|
27
|
+
async function he() {
|
|
28
|
+
return await E(), { isInitialized: () => T };
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
31
|
-
|
|
30
|
+
async function ge() {
|
|
31
|
+
T = !1;
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/config.ts
|
|
35
|
-
var
|
|
35
|
+
var D = {
|
|
36
36
|
title: "Seed Protocol",
|
|
37
37
|
description: "Content published via Seed Protocol",
|
|
38
38
|
siteUrl: "https://seedprotocol.io",
|
|
@@ -45,15 +45,15 @@ var k = {
|
|
|
45
45
|
link: "https://seedprotocol.io"
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
function
|
|
48
|
+
function O(e) {
|
|
49
49
|
return {
|
|
50
50
|
...e,
|
|
51
51
|
author: e.author ? { ...e.author } : void 0
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
var
|
|
55
|
-
function
|
|
56
|
-
if (!e) return
|
|
54
|
+
var k = O(D);
|
|
55
|
+
function A(e, t = k) {
|
|
56
|
+
if (!e) return O(t);
|
|
57
57
|
let n = {
|
|
58
58
|
...t,
|
|
59
59
|
...e,
|
|
@@ -65,18 +65,18 @@ function M(e, t = j) {
|
|
|
65
65
|
name: e.author.name ?? n.author?.name ?? ""
|
|
66
66
|
}), n;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
68
|
+
function _e() {
|
|
69
|
+
return O(k);
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
return
|
|
71
|
+
function ve(e) {
|
|
72
|
+
return k = A(e, D), _e();
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
|
|
74
|
+
function ye() {
|
|
75
|
+
k = O(D);
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function j() {
|
|
78
78
|
return {
|
|
79
|
-
itemUrlBase: process.env.FEED_ITEM_URL_BASE?.trim() ||
|
|
79
|
+
itemUrlBase: process.env.FEED_ITEM_URL_BASE?.trim() || ae(oe())?.explorerUrl || "https://easscan.org",
|
|
80
80
|
itemUrlPath: process.env.FEED_ITEM_URL_PATH?.trim() || "attestation/view",
|
|
81
81
|
siteUrl: process.env.FEED_SITE_URL?.trim() || "https://seedprotocol.io",
|
|
82
82
|
expandRelations: process.env.FEED_EXPAND_RELATIONS?.toLowerCase() !== "false",
|
|
@@ -86,7 +86,7 @@ function N() {
|
|
|
86
86
|
}
|
|
87
87
|
//#endregion
|
|
88
88
|
//#region src/getFeedItems.ts
|
|
89
|
-
var
|
|
89
|
+
var M = (e) => {
|
|
90
90
|
let t = /* @__PURE__ */ new Date(e * 1e3), n = [
|
|
91
91
|
"Sun",
|
|
92
92
|
"Mon",
|
|
@@ -110,10 +110,10 @@ var P = (e) => {
|
|
|
110
110
|
"Dec"
|
|
111
111
|
], i = n[t.getUTCDay()], a = r[t.getUTCMonth()], o = t.getUTCFullYear();
|
|
112
112
|
return `${i}, ${t.getUTCDate().toString().padStart(2, "0")} ${a} ${o} ${t.getUTCHours().toString().padStart(2, "0")}:${t.getUTCMinutes().toString().padStart(2, "0")}:${t.getUTCSeconds().toString().padStart(2, "0")} GMT`;
|
|
113
|
-
},
|
|
113
|
+
}, be = (e) => e === "image" ? "images" : e === "post" ? "posts" : e.toLowerCase() + "s", N = (e, t, n, r) => {
|
|
114
114
|
let { itemUrlBase: i, itemUrlPath: a, siteUrl: o } = r;
|
|
115
115
|
!e.title && !e.Title ? (e.title = t, e.Title = t) : e.title && !e.Title ? e.Title = e.title : e.Title && !e.title && (e.title = e.Title);
|
|
116
|
-
let s = e.storage_transaction_id && typeof e.storage_transaction_id == "string" && e.storage_transaction_id.trim() !== "" && e.storage_transaction_id !== "undefined" && e.storage_transaction_id !== t ? e.storage_transaction_id.trim() : null, c = e.storageTransactionId && typeof e.storageTransactionId == "string" && e.storageTransactionId.trim() !== "" && e.storageTransactionId !== "undefined" && e.storageTransactionId !== t ? e.storageTransactionId.trim() : null, l = s || c, u =
|
|
116
|
+
let s = e.storage_transaction_id && typeof e.storage_transaction_id == "string" && e.storage_transaction_id.trim() !== "" && e.storage_transaction_id !== "undefined" && e.storage_transaction_id !== t ? e.storage_transaction_id.trim() : null, c = e.storageTransactionId && typeof e.storageTransactionId == "string" && e.storageTransactionId.trim() !== "" && e.storageTransactionId !== "undefined" && e.storageTransactionId !== t ? e.storageTransactionId.trim() : null, l = s || c, u = be(n), d = t && typeof t == "string" && t.trim() !== "" ? t : "unknown", f;
|
|
117
117
|
if (l && l !== t && l.length > 0) try {
|
|
118
118
|
f = ee(l);
|
|
119
119
|
} catch (e) {
|
|
@@ -124,13 +124,13 @@ var P = (e) => {
|
|
|
124
124
|
!p || p === "undefined" || typeof p == "string" && p.trim() === "" ? (e.link = f, e.Link = f) : ((!e.link || e.link === "undefined") && (e.link = p), (!e.Link || e.Link === "undefined") && (e.Link = p));
|
|
125
125
|
let m = e.guid || e.Guid;
|
|
126
126
|
if (!m || m === "undefined" || typeof m == "string" && m.trim() === "" ? (e.guid = e.link || f, e.Guid = e.guid) : ((!e.guid || e.guid === "undefined") && (e.guid = m), (!e.Guid || e.Guid === "undefined") && (e.Guid = m)), e.timeCreated && !e.pubDate && !e.PubDate) {
|
|
127
|
-
let t =
|
|
127
|
+
let t = M(e.timeCreated);
|
|
128
128
|
e.pubDate = t, e.PubDate = t;
|
|
129
129
|
} else e.pubDate && !e.PubDate ? e.PubDate = e.pubDate : e.PubDate && !e.pubDate && (e.pubDate = e.PubDate);
|
|
130
130
|
!e.seedUid && !e.SeedUid ? (e.seedUid = t, e.SeedUid = t) : e.seedUid && !e.SeedUid ? e.SeedUid = e.seedUid : e.SeedUid && !e.seedUid && (e.seedUid = e.SeedUid), e.attester && !e.Attester ? e.Attester = e.attester : e.Attester && !e.attester && (e.attester = e.Attester);
|
|
131
|
-
},
|
|
131
|
+
}, xe = (e, t) => {
|
|
132
132
|
if (!e.title && !e.Title ? (e.title = t, e.Title = t) : e.title && !e.Title ? e.Title = e.title : e.Title && !e.title && (e.title = e.Title), e.timeCreated && !e.pubDate && !e.PubDate) {
|
|
133
|
-
let t =
|
|
133
|
+
let t = M(e.timeCreated);
|
|
134
134
|
e.pubDate = t, e.PubDate = t;
|
|
135
135
|
} else e.pubDate && !e.PubDate ? e.PubDate = e.pubDate : e.PubDate && !e.pubDate && (e.pubDate = e.PubDate);
|
|
136
136
|
!e.seedUid && !e.SeedUid ? (e.seedUid = t, e.SeedUid = t) : e.seedUid && !e.SeedUid ? e.SeedUid = e.seedUid : e.SeedUid && !e.seedUid && (e.seedUid = e.SeedUid), e.attester && !e.Attester ? e.Attester = e.attester : e.Attester && !e.attester && (e.attester = e.Attester);
|
|
@@ -140,86 +140,81 @@ var P = (e) => {
|
|
|
140
140
|
e.link = t, e.Link = t;
|
|
141
141
|
} catch {}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function P(e) {
|
|
144
144
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
145
145
|
let t = e;
|
|
146
146
|
return typeof t.seedUid == "string" || typeof t.SeedUid == "string";
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
}
|
|
148
|
+
function F(e, t, n) {
|
|
149
|
+
let r = { ...e }, i = r.seedUid || r.SeedUid || "", a = typeof r.schemaName == "string" ? r.schemaName : t;
|
|
150
|
+
return a === "image" ? xe(r, i) : N(r, i, a, n), r;
|
|
151
|
+
}
|
|
152
|
+
function Se(e, t, n) {
|
|
153
|
+
let r = { ...e };
|
|
154
|
+
N(r, r.seedUid || r.SeedUid || "", t, n);
|
|
155
|
+
for (let e of Object.keys(r)) {
|
|
156
|
+
if (e.startsWith("_")) continue;
|
|
157
|
+
let i = r[e];
|
|
158
|
+
Array.isArray(i) ? i.some(P) && (r[e] = i.map((e) => P(e) ? F(e, t, n) : e)) : P(i) && (r[e] = F(i, t, n));
|
|
159
|
+
}
|
|
160
|
+
return r;
|
|
163
161
|
}
|
|
164
|
-
function
|
|
165
|
-
let n =
|
|
162
|
+
function Ce(e, t) {
|
|
163
|
+
let n = j(), r = {
|
|
166
164
|
itemUrlBase: n.itemUrlBase,
|
|
167
165
|
itemUrlPath: n.itemUrlPath,
|
|
168
166
|
siteUrl: n.siteUrl
|
|
169
167
|
};
|
|
170
|
-
return t.map((t) =>
|
|
171
|
-
let n = t.data;
|
|
172
|
-
return xe(n, e, r), n;
|
|
173
|
-
});
|
|
168
|
+
return t.map((t) => Se(t.data, e, r));
|
|
174
169
|
}
|
|
175
|
-
var
|
|
176
|
-
await
|
|
177
|
-
let n =
|
|
170
|
+
var we = async (e, t) => {
|
|
171
|
+
await E();
|
|
172
|
+
let n = j(), r = t?.limit ?? 100, i = t?.skip ?? 0, { items: a } = await re(e, {
|
|
178
173
|
limit: r,
|
|
179
174
|
skip: i,
|
|
180
175
|
expandRelations: n.expandRelations !== !1,
|
|
181
176
|
hydrateStorage: !0
|
|
182
177
|
});
|
|
183
|
-
return
|
|
184
|
-
},
|
|
185
|
-
await
|
|
186
|
-
let r =
|
|
187
|
-
return
|
|
178
|
+
return Ce(e, a);
|
|
179
|
+
}, Te = async (e, t, n) => {
|
|
180
|
+
await E();
|
|
181
|
+
let r = j();
|
|
182
|
+
return Ce(e, await ie(e, t, n, {
|
|
188
183
|
expandRelations: r.expandRelations !== !1,
|
|
189
184
|
hydrateStorage: !0
|
|
190
185
|
}));
|
|
191
186
|
};
|
|
192
187
|
//#endregion
|
|
193
188
|
//#region src/consume/parseRss.ts
|
|
194
|
-
function
|
|
189
|
+
function Ee(e) {
|
|
195
190
|
try {
|
|
196
191
|
return JSON.parse(JSON.stringify(e));
|
|
197
192
|
} catch {
|
|
198
193
|
return { ...e };
|
|
199
194
|
}
|
|
200
195
|
}
|
|
201
|
-
var
|
|
196
|
+
var De = new se({ customFields: { item: [
|
|
202
197
|
"featureImage",
|
|
203
198
|
"feature_image",
|
|
204
199
|
"content:encoded",
|
|
205
200
|
"seedUid",
|
|
206
201
|
"SeedUid"
|
|
207
202
|
] } });
|
|
208
|
-
async function
|
|
209
|
-
let t = await
|
|
203
|
+
async function Oe(e) {
|
|
204
|
+
let t = await De.parseString(e);
|
|
210
205
|
return {
|
|
211
206
|
title: t.title,
|
|
212
207
|
link: t.link,
|
|
213
208
|
description: t.description,
|
|
214
|
-
items: (t.items ?? []).map(
|
|
209
|
+
items: (t.items ?? []).map(Ee)
|
|
215
210
|
};
|
|
216
211
|
}
|
|
217
212
|
//#endregion
|
|
218
213
|
//#region src/rss/generateRssXml.ts
|
|
219
|
-
var I = "http://purl.org/dc/elements/1.1/", L = "http://purl.org/rss/1.0/modules/content/", R = "http://search.yahoo.com/mrss/",
|
|
214
|
+
var I = "http://purl.org/dc/elements/1.1/", L = "http://purl.org/rss/1.0/modules/content/", R = "http://search.yahoo.com/mrss/", ke = { publication: {
|
|
220
215
|
prefix: "publication",
|
|
221
216
|
uri: "https://seedprotocol.io/ns/publication/1.0"
|
|
222
|
-
} },
|
|
217
|
+
} }, Ae = "https://seedprotocol.io/ns/relations", je = /* @__PURE__ */ new Set([
|
|
223
218
|
"xml",
|
|
224
219
|
"xmlns",
|
|
225
220
|
"dc",
|
|
@@ -227,17 +222,17 @@ var I = "http://purl.org/dc/elements/1.1/", L = "http://purl.org/rss/1.0/modules
|
|
|
227
222
|
"content",
|
|
228
223
|
"atom",
|
|
229
224
|
"fh"
|
|
230
|
-
]),
|
|
225
|
+
]), Me = /* @__PURE__ */ new Set([
|
|
231
226
|
"Title",
|
|
232
227
|
"Link",
|
|
233
228
|
"Guid",
|
|
234
229
|
"PubDate",
|
|
235
230
|
"SeedUid"
|
|
236
231
|
]);
|
|
237
|
-
function
|
|
238
|
-
return
|
|
232
|
+
function Ne(e, t) {
|
|
233
|
+
return Me.has(e) ? e.charAt(0).toLowerCase() + e.slice(1) in t : !1;
|
|
239
234
|
}
|
|
240
|
-
var
|
|
235
|
+
var z = [
|
|
241
236
|
"title",
|
|
242
237
|
"link",
|
|
243
238
|
"description",
|
|
@@ -261,7 +256,7 @@ var B = [
|
|
|
261
256
|
"media:category",
|
|
262
257
|
"media:group"
|
|
263
258
|
];
|
|
264
|
-
function
|
|
259
|
+
function B(e) {
|
|
265
260
|
if (e instanceof Date) return e.toUTCString();
|
|
266
261
|
if (typeof e == "string") {
|
|
267
262
|
let t = new Date(e);
|
|
@@ -269,13 +264,13 @@ function V(e) {
|
|
|
269
264
|
}
|
|
270
265
|
return String(e);
|
|
271
266
|
}
|
|
272
|
-
function
|
|
267
|
+
function Pe(e) {
|
|
273
268
|
return /[<>&]|]]>/.test(e);
|
|
274
269
|
}
|
|
275
|
-
function
|
|
270
|
+
function V(e, t) {
|
|
276
271
|
let n = String(t);
|
|
277
272
|
if (n !== "") {
|
|
278
|
-
if (
|
|
273
|
+
if (Pe(n)) {
|
|
279
274
|
if (n.includes("]]>")) {
|
|
280
275
|
let t = n.split("]]>");
|
|
281
276
|
for (let n = 0; n < t.length; n++) e.dat(t[n]), n < t.length - 1 && e.txt("]]>");
|
|
@@ -283,11 +278,11 @@ function H(e, t) {
|
|
|
283
278
|
} else e.txt(n);
|
|
284
279
|
}
|
|
285
280
|
}
|
|
286
|
-
function
|
|
281
|
+
function H(e) {
|
|
287
282
|
return typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof Date);
|
|
288
283
|
}
|
|
289
|
-
var
|
|
290
|
-
...
|
|
284
|
+
var Fe = 4, Ie = /* @__PURE__ */ new Set([
|
|
285
|
+
...z,
|
|
291
286
|
"guid",
|
|
292
287
|
"source",
|
|
293
288
|
"dc",
|
|
@@ -295,89 +290,76 @@ var Ne = 4, Pe = /* @__PURE__ */ new Set([
|
|
|
295
290
|
"content:encoded",
|
|
296
291
|
"items"
|
|
297
292
|
]);
|
|
298
|
-
function
|
|
293
|
+
function Le(e) {
|
|
299
294
|
return e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e;
|
|
300
295
|
}
|
|
301
|
-
function
|
|
296
|
+
function Re(e) {
|
|
302
297
|
return e.trim().replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[^A-Za-z_]+/, "").replace(/^$/, "rel").toLowerCase();
|
|
303
298
|
}
|
|
304
|
-
function
|
|
305
|
-
if (!t.has(e) && !
|
|
299
|
+
function ze(e, t) {
|
|
300
|
+
if (!t.has(e) && !je.has(e)) return t.add(e), e;
|
|
306
301
|
let n = 2;
|
|
307
302
|
for (;;) {
|
|
308
303
|
let r = `${e}${n}`;
|
|
309
|
-
if (!t.has(r) && !
|
|
304
|
+
if (!t.has(r) && !je.has(r)) return t.add(r), r;
|
|
310
305
|
n += 1;
|
|
311
306
|
}
|
|
312
307
|
}
|
|
313
|
-
function
|
|
314
|
-
return Array.isArray(e) && e.length > 0 && e.every((e) =>
|
|
308
|
+
function Be(e) {
|
|
309
|
+
return Array.isArray(e) && e.length > 0 && e.every((e) => H(e));
|
|
315
310
|
}
|
|
316
|
-
function
|
|
317
|
-
let t = { ...
|
|
311
|
+
function Ve(e) {
|
|
312
|
+
let t = { ...ke }, n = new Set(Object.values(t).map((e) => e.prefix)), r = /* @__PURE__ */ new Set();
|
|
318
313
|
for (let t of e) for (let [e, n] of Object.entries(t)) {
|
|
319
|
-
let t = e === "author" &&
|
|
320
|
-
e.startsWith("_") || (!
|
|
314
|
+
let t = e === "author" && H(n) || e === "authors" && Be(n);
|
|
315
|
+
e.startsWith("_") || (!Ie.has(e) || t) && (H(n) || Be(n)) && r.add(Le(e));
|
|
321
316
|
}
|
|
322
317
|
let i = [...r].sort();
|
|
323
318
|
for (let e of i) t[e] || (t[e] = {
|
|
324
|
-
prefix:
|
|
325
|
-
uri: `${
|
|
319
|
+
prefix: ze(Re(e), n),
|
|
320
|
+
uri: `${Ae}/${e}/1.0`
|
|
326
321
|
});
|
|
327
322
|
return t;
|
|
328
323
|
}
|
|
329
|
-
function
|
|
324
|
+
function U(e, t) {
|
|
330
325
|
if (e in t) return t[e];
|
|
331
326
|
if (e.endsWith("s") && e.length > 1) {
|
|
332
327
|
let n = e.slice(0, -1);
|
|
333
328
|
if (n in t) return t[n];
|
|
334
329
|
}
|
|
335
330
|
}
|
|
336
|
-
function
|
|
331
|
+
function He(e, t) {
|
|
337
332
|
return t ? `${t.prefix}:${e}` : e;
|
|
338
333
|
}
|
|
339
|
-
function
|
|
334
|
+
function W(e, t, n, r, i = 0, a) {
|
|
340
335
|
let o = e.ele(n);
|
|
341
336
|
for (let [e, n] of Object.entries(t)) {
|
|
342
337
|
if (n == null || e.startsWith("_") || e === "items") continue;
|
|
343
|
-
let t =
|
|
344
|
-
if (i >=
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
let t = G(e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e, a);
|
|
350
|
-
for (let e of n) e != null && (U(e) ? K(o, e, t, !1, i + 1, a) : H(o.ele(t), String(e)));
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
if (U(n)) {
|
|
354
|
-
K(o, n, t, !1, i + 1, a);
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
H(o.ele(t), String(n));
|
|
338
|
+
let t = He(e, a);
|
|
339
|
+
if (i >= Fe) V(o.ele(t), typeof n == "object" ? JSON.stringify(n) : String(n));
|
|
340
|
+
else if (Array.isArray(n)) {
|
|
341
|
+
let t = He(e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e, a);
|
|
342
|
+
for (let e of n) e != null && (H(e) ? W(o, e, t, !1, i + 1, a) : V(o.ele(t), String(e)));
|
|
343
|
+
} else H(n) ? W(o, n, t, !1, i + 1, a) : V(o.ele(t), String(n));
|
|
358
344
|
}
|
|
359
345
|
if (r) {
|
|
360
346
|
let n = t.name ?? t.seedUid;
|
|
361
347
|
n && e.ele(I, "creator").txt(String(n));
|
|
362
348
|
}
|
|
363
349
|
}
|
|
364
|
-
function
|
|
350
|
+
function Ue(e, t, n, r, i) {
|
|
365
351
|
if (!(n == null || t.startsWith("_")) && t !== "items") {
|
|
366
352
|
if (t === "guid") {
|
|
367
353
|
let t = n, r = t?.value ?? String(n);
|
|
368
354
|
if (!r) return;
|
|
369
355
|
let i = {};
|
|
370
|
-
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"),
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
if (t === "source" && typeof n == "object" && n) {
|
|
356
|
+
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"), V(e.ele("guid", i), r);
|
|
357
|
+
} else if (t === "source" && typeof n == "object" && n) {
|
|
374
358
|
let t = n, r = t.title ?? String(n);
|
|
375
359
|
if (!r) return;
|
|
376
360
|
let i = t.url ? { url: t.url } : {};
|
|
377
361
|
e.ele("source", i).txt(r);
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
if (t === "enclosures" && Array.isArray(n)) {
|
|
362
|
+
} else if (t === "enclosures" && Array.isArray(n)) {
|
|
381
363
|
for (let t of n) if (t && typeof t == "object" && "url" in t) {
|
|
382
364
|
let n = {
|
|
383
365
|
url: String(t.url),
|
|
@@ -385,32 +367,22 @@ function Be(e, t, n, r, i) {
|
|
|
385
367
|
};
|
|
386
368
|
t.length != null && (n.length = String(t.length)), e.ele("enclosure", n);
|
|
387
369
|
}
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
if (t === "dc" && typeof n == "object" && n) {
|
|
370
|
+
} else if (t === "dc" && typeof n == "object" && n) {
|
|
391
371
|
let t = n;
|
|
392
372
|
for (let [n, r] of Object.entries(t)) if (r != null) {
|
|
393
373
|
if (Array.isArray(r)) {
|
|
394
374
|
for (let t of r) if (t != null) {
|
|
395
375
|
let r = e.ele(I, n);
|
|
396
|
-
t instanceof Date ? r.txt(t.toISOString()) :
|
|
376
|
+
t instanceof Date ? r.txt(t.toISOString()) : V(r, String(t));
|
|
397
377
|
}
|
|
398
378
|
} else {
|
|
399
379
|
let t = e.ele(I, n);
|
|
400
|
-
r instanceof Date ? t.txt(r.toISOString()) :
|
|
380
|
+
r instanceof Date ? t.txt(r.toISOString()) : V(t, String(r));
|
|
401
381
|
}
|
|
402
382
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (t
|
|
406
|
-
H(e.ele(L, "encoded"), String(n));
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
if (t === "content" && typeof n == "string" && !("content:encoded" in r)) {
|
|
410
|
-
H(e.ele(L, "encoded"), String(n));
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
if (t !== "content") {
|
|
383
|
+
} else if (t === "content:encoded") V(e.ele(L, "encoded"), String(n));
|
|
384
|
+
else if (t === "content" && typeof n == "string" && !("content:encoded" in r)) V(e.ele(L, "encoded"), String(n));
|
|
385
|
+
else if (t !== "content") {
|
|
414
386
|
if (t === "media:group" && Array.isArray(n)) {
|
|
415
387
|
for (let t of n) if (t && typeof t == "object") {
|
|
416
388
|
let n = e.ele(R, "group");
|
|
@@ -419,87 +391,62 @@ function Be(e, t, n, r, i) {
|
|
|
419
391
|
if (Array.isArray(r)) {
|
|
420
392
|
for (let e of r) if (e && typeof e == "object") {
|
|
421
393
|
let r = n.ele(R, t);
|
|
422
|
-
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ?
|
|
394
|
+
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ? V(r, String(n)) : r.att(t, String(n)));
|
|
423
395
|
}
|
|
424
|
-
} else typeof r == "string" &&
|
|
396
|
+
} else typeof r == "string" && V(n.ele(R, t), r);
|
|
425
397
|
}
|
|
426
398
|
}
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
if (t.startsWith("media:") && Array.isArray(n)) {
|
|
399
|
+
} else if (t.startsWith("media:") && Array.isArray(n)) {
|
|
430
400
|
let r = t.slice(6);
|
|
431
401
|
for (let t of n) {
|
|
432
402
|
if (typeof t != "object" || !t) continue;
|
|
433
403
|
let n = {}, i = null;
|
|
434
404
|
for (let [e, r] of Object.entries(t)) r != null && (e === "value" ? i = String(r) : n[e] = String(r));
|
|
435
405
|
let a = e.ele(R, r, n);
|
|
436
|
-
i !== null &&
|
|
406
|
+
i !== null && V(a, i);
|
|
437
407
|
}
|
|
438
|
-
|
|
439
|
-
}
|
|
440
|
-
if (t.startsWith("media:") && typeof n == "string") {
|
|
408
|
+
} else if (t.startsWith("media:") && typeof n == "string") {
|
|
441
409
|
let r = t.slice(6);
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
if (
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
}
|
|
449
|
-
if (t === "author" && U(n)) {
|
|
450
|
-
K(e, n, "author", !0, 0, W(t, i));
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
if (t === "authors" && Array.isArray(n)) {
|
|
454
|
-
let r = W(t, i);
|
|
455
|
-
for (let t of n) if (t && U(t)) K(e, t, "author", !0, 0, r);
|
|
410
|
+
V(e.ele(R, r), n);
|
|
411
|
+
} else if (n instanceof Date) e.ele(t).txt(B(n));
|
|
412
|
+
else if (t === "author" && H(n)) W(e, n, "author", !0, 0, U(t, i));
|
|
413
|
+
else if (t === "authors" && Array.isArray(n)) {
|
|
414
|
+
let r = U(t, i);
|
|
415
|
+
for (let t of n) if (t && H(t)) W(e, t, "author", !0, 0, r);
|
|
456
416
|
else {
|
|
457
417
|
let n = typeof t == "string" ? t : t && typeof t == "object" && "name" in t ? `${t.email ?? ""} (${t.name ?? ""})`.trim() || t.name : String(t);
|
|
458
418
|
n && e.ele("author").txt(n);
|
|
459
419
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
if (n) {
|
|
466
|
-
let r = t && typeof t == "object" && "domain" in t && t.domain ? { domain: t.domain } : {};
|
|
467
|
-
e.ele("category", r).txt(n);
|
|
468
|
-
}
|
|
420
|
+
} else if (t === "categories" && Array.isArray(n)) for (let t of n) {
|
|
421
|
+
let n = t && typeof t == "object" && "name" in t ? t.name : String(t);
|
|
422
|
+
if (n) {
|
|
423
|
+
let r = t && typeof t == "object" && "domain" in t && t.domain ? { domain: t.domain } : {};
|
|
424
|
+
e.ele("category", r).txt(n);
|
|
469
425
|
}
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
472
|
-
if (Array.isArray(n) && n.length > 0 && n.every((e) => U(e))) {
|
|
473
|
-
let r = t.endsWith("s") ? t.slice(0, -1) : t, a = W(t, i);
|
|
474
|
-
for (let t of n) t && K(e, t, r, !1, 0, a);
|
|
475
|
-
return;
|
|
476
426
|
}
|
|
477
|
-
if (Array.isArray(n) && n.every((e) =>
|
|
427
|
+
else if (Array.isArray(n) && n.length > 0 && n.every((e) => H(e))) {
|
|
428
|
+
let r = t.endsWith("s") ? t.slice(0, -1) : t, a = U(t, i);
|
|
429
|
+
for (let t of n) t && W(e, t, r, !1, 0, a);
|
|
430
|
+
} else if (Array.isArray(n) && n.every((e) => typeof e == "string")) {
|
|
478
431
|
let r = t.endsWith("s") ? t.slice(0, -1) : t;
|
|
479
|
-
for (let t of n) t &&
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
if (U(n)) {
|
|
483
|
-
K(e, n, t, !1, 0, W(t, i));
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
H(e.ele(t), String(n));
|
|
432
|
+
for (let t of n) t && V(e.ele(r), t);
|
|
433
|
+
} else H(n) ? W(e, n, t, !1, 0, U(t, i)) : V(e.ele(t), String(n));
|
|
487
434
|
}
|
|
488
435
|
}
|
|
489
436
|
}
|
|
490
|
-
var
|
|
491
|
-
function
|
|
492
|
-
let t =
|
|
437
|
+
var We = "http://www.w3.org/2005/Atom", Ge = "http://purl.org/syndication/history/1.0";
|
|
438
|
+
function Ke(e) {
|
|
439
|
+
let t = ue({
|
|
493
440
|
version: "1.0",
|
|
494
441
|
encoding: "UTF-8"
|
|
495
|
-
}), n =
|
|
442
|
+
}), n = Ve(e.items), r = {
|
|
496
443
|
"xmlns:dc": I,
|
|
497
444
|
"xmlns:content": L,
|
|
498
445
|
"xmlns:media": R,
|
|
499
|
-
"xmlns:atom":
|
|
446
|
+
"xmlns:atom": We,
|
|
500
447
|
...Object.values(n).reduce((e, t) => (e[`xmlns:${t.prefix}`] = t.uri, e), {})
|
|
501
448
|
};
|
|
502
|
-
e.isArchive && (r["xmlns:fh"] =
|
|
449
|
+
e.isArchive && (r["xmlns:fh"] = Ge);
|
|
503
450
|
let i = t.ele("rss", {
|
|
504
451
|
version: "2.0",
|
|
505
452
|
...r
|
|
@@ -508,50 +455,50 @@ function Ue(e) {
|
|
|
508
455
|
"xmlns:content": L,
|
|
509
456
|
"xmlns:media": R
|
|
510
457
|
});
|
|
511
|
-
if (i.ele("title").txt(e.title), e.link && i.ele("link").txt(e.link), i.ele("description").txt(e.description), e.language && i.ele("language").txt(e.language), e.copyright && i.ele("copyright").txt(e.copyright), e.webMaster && i.ele("webMaster").txt(e.webMaster), e.pubDate && i.ele("pubDate").txt(
|
|
458
|
+
if (i.ele("title").txt(e.title), e.link && i.ele("link").txt(e.link), i.ele("description").txt(e.description), e.language && i.ele("language").txt(e.language), e.copyright && i.ele("copyright").txt(e.copyright), e.webMaster && i.ele("webMaster").txt(e.webMaster), e.pubDate && i.ele("pubDate").txt(B(e.pubDate)), e.lastBuildDate && i.ele("lastBuildDate").txt(B(e.lastBuildDate)), e.links?.length) for (let t of e.links) {
|
|
512
459
|
let e = {
|
|
513
460
|
rel: t.rel,
|
|
514
461
|
href: t.href
|
|
515
462
|
};
|
|
516
|
-
t.type && (e.type = t.type), i.ele(
|
|
463
|
+
t.type && (e.type = t.type), i.ele(We, "link", e);
|
|
517
464
|
}
|
|
518
|
-
e.isArchive && i.ele(
|
|
519
|
-
let a = new Set(
|
|
465
|
+
e.isArchive && i.ele(Ge, "archive");
|
|
466
|
+
let a = new Set(z);
|
|
520
467
|
for (let t of e.items) {
|
|
521
468
|
let e = i.ele("item"), r = /* @__PURE__ */ new Set();
|
|
522
|
-
for (let i of
|
|
523
|
-
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !
|
|
524
|
-
for (let r of o)
|
|
469
|
+
for (let i of z) i in t && (Ue(e, i, t[i], t, n), r.add(i));
|
|
470
|
+
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !Ne(e, t)).sort();
|
|
471
|
+
for (let r of o) Ue(e, r, t[r], t, n);
|
|
525
472
|
}
|
|
526
473
|
return t.end({ prettyPrint: !0 });
|
|
527
474
|
}
|
|
528
475
|
//#endregion
|
|
529
476
|
//#region src/cache/types.ts
|
|
530
|
-
function
|
|
477
|
+
function G(e, t, n) {
|
|
531
478
|
return n?.archive ? `${e}:${t}:archive-${n.archive.year}-${n.archive.month}` : n?.page != null && n.page > 1 ? `${e}:${t}:page-${n.page}` : `${e}:${t}`;
|
|
532
479
|
}
|
|
533
480
|
//#endregion
|
|
534
481
|
//#region src/utils/etag.ts
|
|
535
|
-
function
|
|
536
|
-
return `"${
|
|
482
|
+
function qe(e) {
|
|
483
|
+
return `"${de("md5").update(e).digest("hex").substring(0, 16)}"`;
|
|
537
484
|
}
|
|
538
|
-
function
|
|
539
|
-
return
|
|
485
|
+
function Je(e, t, n, r) {
|
|
486
|
+
return qe(`${e}-${t}-${n}-${r}`);
|
|
540
487
|
}
|
|
541
|
-
function
|
|
488
|
+
function Ye(e, t) {
|
|
542
489
|
let n = (e) => e.replace(/^"|"$/g, "");
|
|
543
490
|
return n(e) === n(t);
|
|
544
491
|
}
|
|
545
|
-
function
|
|
492
|
+
function Xe(e) {
|
|
546
493
|
return e ? e.split(",").map((e) => e.trim()).filter((e) => e.length > 0) : [];
|
|
547
494
|
}
|
|
548
|
-
function
|
|
549
|
-
let n =
|
|
550
|
-
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) =>
|
|
495
|
+
function Ze(e, t) {
|
|
496
|
+
let n = Xe(e);
|
|
497
|
+
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) => Ye(e, t));
|
|
551
498
|
}
|
|
552
499
|
//#endregion
|
|
553
500
|
//#region src/cache/MemoryCache.ts
|
|
554
|
-
var
|
|
501
|
+
var Qe = class {
|
|
555
502
|
feedContentCache = /* @__PURE__ */ new Map();
|
|
556
503
|
imageMetadataCache = /* @__PURE__ */ new Map();
|
|
557
504
|
config;
|
|
@@ -559,14 +506,14 @@ var Ye = class {
|
|
|
559
506
|
this.config = e;
|
|
560
507
|
}
|
|
561
508
|
getFeedContent(e, t, n) {
|
|
562
|
-
let r =
|
|
509
|
+
let r = G(e, t, n), i = this.feedContentCache.get(r);
|
|
563
510
|
return i ? Math.floor(Date.now() / 1e3) > i.expiresAt ? (this.feedContentCache.delete(r), null) : i : null;
|
|
564
511
|
}
|
|
565
512
|
setFeedContent(e, t, n, r, i, a) {
|
|
566
|
-
let o =
|
|
513
|
+
let o = G(e, t, i), s = Math.floor(Date.now() / 1e3), c = s + (a ?? this.config.ttl), l = {
|
|
567
514
|
content: n,
|
|
568
515
|
contentType: r,
|
|
569
|
-
etag:
|
|
516
|
+
etag: Je(e, t, s, n.length),
|
|
570
517
|
lastModified: s,
|
|
571
518
|
expiresAt: c
|
|
572
519
|
};
|
|
@@ -604,7 +551,7 @@ var Ye = class {
|
|
|
604
551
|
imageMetadataCount: this.imageMetadataCache.size
|
|
605
552
|
};
|
|
606
553
|
}
|
|
607
|
-
},
|
|
554
|
+
}, $e = class {
|
|
608
555
|
cacheDir;
|
|
609
556
|
config;
|
|
610
557
|
constructor(e) {
|
|
@@ -614,30 +561,30 @@ var Ye = class {
|
|
|
614
561
|
}
|
|
615
562
|
async ensureCacheDir() {
|
|
616
563
|
try {
|
|
617
|
-
await
|
|
564
|
+
await C.mkdir(this.cacheDir, { recursive: !0 });
|
|
618
565
|
} catch (e) {
|
|
619
566
|
if (e.code !== "EEXIST") throw e;
|
|
620
567
|
}
|
|
621
568
|
}
|
|
622
569
|
getFeedContentPath(e, t, n) {
|
|
623
|
-
let r =
|
|
624
|
-
return
|
|
570
|
+
let r = G(e, t, n).replace(/:/g, "-");
|
|
571
|
+
return w(this.cacheDir, `${r}.json`);
|
|
625
572
|
}
|
|
626
573
|
getImageMetadataPath(e) {
|
|
627
|
-
let t =
|
|
628
|
-
return
|
|
574
|
+
let t = w(this.cacheDir, "image-metadata");
|
|
575
|
+
return w(t, `${e}.json`);
|
|
629
576
|
}
|
|
630
577
|
async ensureImageMetadataDir() {
|
|
631
578
|
try {
|
|
632
|
-
let e =
|
|
633
|
-
await
|
|
579
|
+
let e = w(this.cacheDir, "image-metadata");
|
|
580
|
+
await C.mkdir(e, { recursive: !0 });
|
|
634
581
|
} catch (e) {
|
|
635
582
|
if (e.code !== "EEXIST") throw e;
|
|
636
583
|
}
|
|
637
584
|
}
|
|
638
585
|
async getFeedContent(e, t, n) {
|
|
639
586
|
try {
|
|
640
|
-
let r = this.getFeedContentPath(e, t, n), i = await
|
|
587
|
+
let r = this.getFeedContentPath(e, t, n), i = await C.readFile(r, "utf-8"), a = JSON.parse(i);
|
|
641
588
|
return Math.floor(Date.now() / 1e3) > a.expiresAt ? (await this.clearFeedContent(e, t, n), null) : a;
|
|
642
589
|
} catch (n) {
|
|
643
590
|
return n.code === "ENOENT" || console.error(`Error reading feed content cache for ${e}:${t}:`, n), null;
|
|
@@ -647,7 +594,7 @@ var Ye = class {
|
|
|
647
594
|
try {
|
|
648
595
|
await this.ensureCacheDir();
|
|
649
596
|
let i = this.getFeedContentPath(e, t, r);
|
|
650
|
-
await
|
|
597
|
+
await C.writeFile(i, JSON.stringify(n, null, 2), "utf-8");
|
|
651
598
|
} catch (n) {
|
|
652
599
|
console.error(`Error writing feed content cache for ${e}:${t}:`, n);
|
|
653
600
|
}
|
|
@@ -655,22 +602,22 @@ var Ye = class {
|
|
|
655
602
|
async clearFeedContent(e, t, n) {
|
|
656
603
|
try {
|
|
657
604
|
let r = this.getFeedContentPath(e, t, n);
|
|
658
|
-
await
|
|
605
|
+
await C.unlink(r);
|
|
659
606
|
} catch (n) {
|
|
660
607
|
n.code !== "ENOENT" && console.error(`Error clearing feed content cache for ${e}:${t}:`, n);
|
|
661
608
|
}
|
|
662
609
|
}
|
|
663
610
|
async clearAllContentCache(e) {
|
|
664
611
|
try {
|
|
665
|
-
let t = await
|
|
666
|
-
for (let r of t) r.startsWith(n) && r.endsWith(".json") && r !== `${e}.json` && await
|
|
612
|
+
let t = await C.readdir(this.cacheDir), n = `${e}-`;
|
|
613
|
+
for (let r of t) r.startsWith(n) && r.endsWith(".json") && r !== `${e}.json` && await C.unlink(w(this.cacheDir, r));
|
|
667
614
|
} catch (t) {
|
|
668
615
|
console.error(`Error clearing all content cache for ${e}:`, t);
|
|
669
616
|
}
|
|
670
617
|
}
|
|
671
618
|
async getImageMetadata(e) {
|
|
672
619
|
try {
|
|
673
|
-
let t = this.getImageMetadataPath(e), n = await
|
|
620
|
+
let t = this.getImageMetadataPath(e), n = await C.readFile(t, "utf-8"), r = JSON.parse(n);
|
|
674
621
|
return Math.floor(Date.now() / 1e3) > r.expiresAt ? (await this.clearImageMetadata(e), null) : r.metadata;
|
|
675
622
|
} catch (t) {
|
|
676
623
|
return t.code === "ENOENT" || console.error(`Error reading image metadata cache for ${e}:`, t), null;
|
|
@@ -684,7 +631,7 @@ var Ye = class {
|
|
|
684
631
|
cachedAt: r,
|
|
685
632
|
expiresAt: r + (this.config.imageMetadata?.ttl || 604800)
|
|
686
633
|
};
|
|
687
|
-
await
|
|
634
|
+
await C.writeFile(n, JSON.stringify(i, null, 2), "utf-8");
|
|
688
635
|
} catch (t) {
|
|
689
636
|
console.error(`Error writing image metadata cache for ${e}:`, t);
|
|
690
637
|
}
|
|
@@ -692,25 +639,25 @@ var Ye = class {
|
|
|
692
639
|
async clearImageMetadata(e) {
|
|
693
640
|
try {
|
|
694
641
|
let t = this.getImageMetadataPath(e);
|
|
695
|
-
await
|
|
642
|
+
await C.unlink(t);
|
|
696
643
|
} catch (t) {
|
|
697
644
|
t.code !== "ENOENT" && console.error(`Error clearing image metadata cache for ${e}:`, t);
|
|
698
645
|
}
|
|
699
646
|
}
|
|
700
647
|
async clearAll() {
|
|
701
648
|
try {
|
|
702
|
-
let e = await
|
|
703
|
-
for (let t of e) t.endsWith(".json") && t.includes("-") && await
|
|
704
|
-
let t =
|
|
649
|
+
let e = await C.readdir(this.cacheDir);
|
|
650
|
+
for (let t of e) t.endsWith(".json") && t.includes("-") && await C.unlink(w(this.cacheDir, t));
|
|
651
|
+
let t = w(this.cacheDir, "image-metadata");
|
|
705
652
|
try {
|
|
706
|
-
let e = await
|
|
707
|
-
for (let n of e) n.endsWith(".json") && await
|
|
653
|
+
let e = await C.readdir(t);
|
|
654
|
+
for (let n of e) n.endsWith(".json") && await C.unlink(w(t, n));
|
|
708
655
|
} catch {}
|
|
709
656
|
} catch (e) {
|
|
710
657
|
console.error("Error clearing all caches:", e);
|
|
711
658
|
}
|
|
712
659
|
}
|
|
713
|
-
},
|
|
660
|
+
}, et = class {
|
|
714
661
|
memoryCache;
|
|
715
662
|
fileCache;
|
|
716
663
|
config;
|
|
@@ -721,7 +668,7 @@ var Ye = class {
|
|
|
721
668
|
errors: 0
|
|
722
669
|
};
|
|
723
670
|
constructor(e) {
|
|
724
|
-
this.config = e, this.memoryCache = new
|
|
671
|
+
this.config = e, this.memoryCache = new Qe(e), this.fileCache = new $e(e);
|
|
725
672
|
}
|
|
726
673
|
async getFeedContent(e, t, n) {
|
|
727
674
|
if (!this.config.enabled) return null;
|
|
@@ -787,7 +734,7 @@ var Ye = class {
|
|
|
787
734
|
};
|
|
788
735
|
//#endregion
|
|
789
736
|
//#region src/cache/config.ts
|
|
790
|
-
function
|
|
737
|
+
function K() {
|
|
791
738
|
let t = parseInt(process.env.CACHE_TTL || "3600", 10), n = process.env.CACHE_DIR || "./cache", r = process.env.CACHE_ENABLED === "false" || process.env.CACHE_ENABLED === "0" || process.env.CACHE_ENABLED === "no" || process.env.CACHE_ENABLED === "off", i = process.env.CACHE_ENABLED === "true" || process.env.CACHE_ENABLED === "1" || process.env.CACHE_ENABLED === "yes", a = process.env.NODE_ENV === "development", o;
|
|
792
739
|
o = r ? !1 : i ? !0 : !a;
|
|
793
740
|
let c = process.env.CACHE_BACKGROUND_REFRESH === "true", l = parseInt(process.env.CACHE_REFRESH_INTERVAL || "300", 10);
|
|
@@ -811,7 +758,7 @@ function J() {
|
|
|
811
758
|
}
|
|
812
759
|
//#endregion
|
|
813
760
|
//#region src/services/arweaveImageService.ts
|
|
814
|
-
var
|
|
761
|
+
var tt = class {
|
|
815
762
|
config;
|
|
816
763
|
constructor(e) {
|
|
817
764
|
this.config = e;
|
|
@@ -901,7 +848,7 @@ var Qe = class {
|
|
|
901
848
|
}
|
|
902
849
|
extractImageDimensions(e, t) {
|
|
903
850
|
try {
|
|
904
|
-
let t =
|
|
851
|
+
let t = fe(e);
|
|
905
852
|
if (t.width && t.height) return {
|
|
906
853
|
width: t.width,
|
|
907
854
|
height: t.height
|
|
@@ -923,7 +870,7 @@ var Qe = class {
|
|
|
923
870
|
}
|
|
924
871
|
}
|
|
925
872
|
try {
|
|
926
|
-
let e =
|
|
873
|
+
let e = fe(t);
|
|
927
874
|
if (e.type) return e.type.toLowerCase();
|
|
928
875
|
} catch {}
|
|
929
876
|
}
|
|
@@ -942,28 +889,28 @@ var Qe = class {
|
|
|
942
889
|
};
|
|
943
890
|
//#endregion
|
|
944
891
|
//#region src/pickFeedItemRichText.ts
|
|
945
|
-
function
|
|
892
|
+
function q(e, t) {
|
|
946
893
|
for (let n of t) {
|
|
947
894
|
let t = e[n];
|
|
948
895
|
if (typeof t == "string" && t.trim() !== "") return t;
|
|
949
896
|
}
|
|
950
897
|
return "";
|
|
951
898
|
}
|
|
952
|
-
var
|
|
899
|
+
var nt = [
|
|
953
900
|
"summary",
|
|
954
901
|
"Summary",
|
|
955
902
|
"description",
|
|
956
903
|
"Description",
|
|
957
904
|
"text",
|
|
958
905
|
"Text"
|
|
959
|
-
],
|
|
906
|
+
], rt = [
|
|
960
907
|
"html",
|
|
961
908
|
"Html",
|
|
962
909
|
"body",
|
|
963
910
|
"Body",
|
|
964
911
|
"content",
|
|
965
912
|
"Content"
|
|
966
|
-
],
|
|
913
|
+
], it = [
|
|
967
914
|
"summary",
|
|
968
915
|
"Summary",
|
|
969
916
|
"description",
|
|
@@ -971,16 +918,16 @@ var $e = [
|
|
|
971
918
|
"text",
|
|
972
919
|
"Text"
|
|
973
920
|
];
|
|
974
|
-
function
|
|
921
|
+
function at(e, t) {
|
|
975
922
|
let n = b(e.model) - b(t.model);
|
|
976
923
|
if (n !== 0) return n;
|
|
977
924
|
let r = e.key.localeCompare(t.key);
|
|
978
925
|
return r === 0 ? e.index - t.index : r;
|
|
979
926
|
}
|
|
980
|
-
function
|
|
981
|
-
let t =
|
|
927
|
+
function ot(e) {
|
|
928
|
+
let t = te(e), n = ne(e), r = null;
|
|
982
929
|
if (t) for (let [n, i] of Object.entries(t)) {
|
|
983
|
-
if (!
|
|
930
|
+
if (!x(i)) continue;
|
|
984
931
|
let t = e[n];
|
|
985
932
|
if (typeof t != "string" || t.trim() === "") continue;
|
|
986
933
|
let a = {
|
|
@@ -989,7 +936,7 @@ function rt(e) {
|
|
|
989
936
|
index: 0,
|
|
990
937
|
value: t
|
|
991
938
|
};
|
|
992
|
-
(!r ||
|
|
939
|
+
(!r || at(a, r) < 0) && (r = a);
|
|
993
940
|
}
|
|
994
941
|
if (n) for (let [t, i] of Object.entries(n)) {
|
|
995
942
|
let n = e[t];
|
|
@@ -997,7 +944,7 @@ function rt(e) {
|
|
|
997
944
|
let a = Math.min(i.length, n.length);
|
|
998
945
|
for (let e = 0; e < a; e++) {
|
|
999
946
|
let a = i[e];
|
|
1000
|
-
if (!
|
|
947
|
+
if (!x(a)) continue;
|
|
1001
948
|
let o = n[e];
|
|
1002
949
|
if (typeof o != "string" || o.trim() === "") continue;
|
|
1003
950
|
let s = {
|
|
@@ -1006,83 +953,83 @@ function rt(e) {
|
|
|
1006
953
|
index: e,
|
|
1007
954
|
value: o
|
|
1008
955
|
};
|
|
1009
|
-
(!r ||
|
|
956
|
+
(!r || at(s, r) < 0) && (r = s);
|
|
1010
957
|
}
|
|
1011
958
|
}
|
|
1012
959
|
return r?.value ?? "";
|
|
1013
960
|
}
|
|
1014
|
-
function
|
|
1015
|
-
return
|
|
961
|
+
function st(e) {
|
|
962
|
+
return q(e, nt);
|
|
1016
963
|
}
|
|
1017
|
-
function
|
|
1018
|
-
let t =
|
|
964
|
+
function ct(e) {
|
|
965
|
+
let t = ot(e);
|
|
1019
966
|
if (t !== "") return t;
|
|
1020
|
-
let n =
|
|
1021
|
-
return n === "" ?
|
|
967
|
+
let n = q(e, rt);
|
|
968
|
+
return n === "" ? q(e, it) : n;
|
|
1022
969
|
}
|
|
1023
|
-
function
|
|
970
|
+
function J(e) {
|
|
1024
971
|
return typeof e == "string" && e.includes("data:image/") && e.includes(";base64,");
|
|
1025
972
|
}
|
|
1026
|
-
function
|
|
1027
|
-
let t =
|
|
973
|
+
function lt(e) {
|
|
974
|
+
let t = te(e);
|
|
1028
975
|
if (t) {
|
|
1029
|
-
for (let [n, r] of Object.entries(t)) if (
|
|
976
|
+
for (let [n, r] of Object.entries(t)) if (x(r) && J(e[n])) return !0;
|
|
1030
977
|
}
|
|
1031
|
-
let n =
|
|
978
|
+
let n = ne(e);
|
|
1032
979
|
if (n) for (let [t, r] of Object.entries(n)) {
|
|
1033
980
|
let n = e[t];
|
|
1034
981
|
if (!Array.isArray(n)) continue;
|
|
1035
982
|
let i = Math.min(r.length, n.length);
|
|
1036
|
-
for (let e = 0; e < i; e++) if (
|
|
983
|
+
for (let e = 0; e < i; e++) if (x(r[e]) && J(n[e])) return !0;
|
|
1037
984
|
}
|
|
1038
985
|
return !1;
|
|
1039
986
|
}
|
|
1040
|
-
function
|
|
1041
|
-
if (
|
|
1042
|
-
for (let t of
|
|
1043
|
-
for (let t of
|
|
987
|
+
function ut(e) {
|
|
988
|
+
if (lt(e)) return !0;
|
|
989
|
+
for (let t of rt) if (J(e[t])) return !0;
|
|
990
|
+
for (let t of nt) if (J(e[t])) return !0;
|
|
1044
991
|
return !1;
|
|
1045
992
|
}
|
|
1046
|
-
function
|
|
1047
|
-
return t === "include_items" ? [...e] : e.filter((e) => !
|
|
993
|
+
function dt(e, t = "omit_items") {
|
|
994
|
+
return t === "include_items" ? [...e] : e.filter((e) => !ut(e));
|
|
1048
995
|
}
|
|
1049
996
|
//#endregion
|
|
1050
997
|
//#region src/index.ts
|
|
1051
|
-
function
|
|
998
|
+
function ft(e) {
|
|
1052
999
|
return _(e)?.mediaUrl;
|
|
1053
1000
|
}
|
|
1054
|
-
function
|
|
1001
|
+
function Y(e) {
|
|
1055
1002
|
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e;
|
|
1056
1003
|
if (typeof e == "string") {
|
|
1057
1004
|
let t = Number(e);
|
|
1058
1005
|
if (Number.isFinite(t) && t > 0) return t;
|
|
1059
1006
|
}
|
|
1060
1007
|
}
|
|
1061
|
-
function
|
|
1008
|
+
function pt(e) {
|
|
1062
1009
|
if (Array.isArray(e)) {
|
|
1063
1010
|
for (let t of e) {
|
|
1064
|
-
let e =
|
|
1011
|
+
let e = pt(t);
|
|
1065
1012
|
if (e) return e;
|
|
1066
1013
|
}
|
|
1067
1014
|
return;
|
|
1068
1015
|
}
|
|
1069
|
-
let t =
|
|
1016
|
+
let t = ft(e);
|
|
1070
1017
|
if (t) {
|
|
1071
1018
|
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
1072
1019
|
let n = e;
|
|
1073
1020
|
return {
|
|
1074
1021
|
url: t,
|
|
1075
1022
|
mimeType: typeof n.mimeType == "string" && n.mimeType || typeof n.type == "string" && n.type || typeof n.contentType == "string" && n.contentType || void 0,
|
|
1076
|
-
width:
|
|
1077
|
-
height:
|
|
1078
|
-
size:
|
|
1023
|
+
width: Y(n.width),
|
|
1024
|
+
height: Y(n.height),
|
|
1025
|
+
size: Y(n.size ?? n.fileSize),
|
|
1079
1026
|
format: typeof n.format == "string" ? n.format : void 0
|
|
1080
1027
|
};
|
|
1081
1028
|
}
|
|
1082
1029
|
return { url: t };
|
|
1083
1030
|
}
|
|
1084
1031
|
}
|
|
1085
|
-
function
|
|
1032
|
+
function mt(e) {
|
|
1086
1033
|
if (e._hasImage && e._imageMetadata && typeof e._imageMetadata == "object") {
|
|
1087
1034
|
let t = e._imageMetadata;
|
|
1088
1035
|
if (t.url) return {
|
|
@@ -1106,11 +1053,11 @@ function dt(e) {
|
|
|
1106
1053
|
"thumbnailImage"
|
|
1107
1054
|
]) {
|
|
1108
1055
|
if (!(t in e)) continue;
|
|
1109
|
-
let n =
|
|
1056
|
+
let n = pt(e[t]);
|
|
1110
1057
|
if (n) return n;
|
|
1111
1058
|
}
|
|
1112
1059
|
}
|
|
1113
|
-
function
|
|
1060
|
+
function ht(e, t, n, r, i, a) {
|
|
1114
1061
|
let o = n.mimeType || "image/jpeg";
|
|
1115
1062
|
e.enclosures = [{
|
|
1116
1063
|
url: n.url,
|
|
@@ -1146,14 +1093,14 @@ function ft(e, t, n, r, i, a) {
|
|
|
1146
1093
|
"media:description": l
|
|
1147
1094
|
}], n.url && typeof t.content == "string" && t.content.trim() !== "" && !t.content.includes(n.url) && (e["content:encoded"] = `${`<img src="${n.url}" alt="${t.title || ""}"${n.width ? ` width="${n.width}"` : ""}${n.height ? ` height="${n.height}"` : ""} />`}\n${t.content}`);
|
|
1148
1095
|
}
|
|
1149
|
-
var
|
|
1150
|
-
function
|
|
1151
|
-
return
|
|
1096
|
+
var X = null;
|
|
1097
|
+
function gt() {
|
|
1098
|
+
return X ||= new et(K()), X;
|
|
1152
1099
|
}
|
|
1153
|
-
function
|
|
1154
|
-
|
|
1100
|
+
function _t() {
|
|
1101
|
+
X = null;
|
|
1155
1102
|
}
|
|
1156
|
-
async function
|
|
1103
|
+
async function vt(e, t, n) {
|
|
1157
1104
|
let r = e.filter((e) => e.storageTransactionId || e.storage_transaction_id);
|
|
1158
1105
|
if (r.length === 0) return e;
|
|
1159
1106
|
console.log(`Enriching ${r.length} items with image metadata`);
|
|
@@ -1175,10 +1122,10 @@ async function ht(e, t, n) {
|
|
|
1175
1122
|
return o.get(t) || e;
|
|
1176
1123
|
});
|
|
1177
1124
|
}
|
|
1178
|
-
function
|
|
1125
|
+
function yt(e, t) {
|
|
1179
1126
|
let { schemaName: n, siteUrl: r, itemUrlBase: i, itemUrlPath: a, richTextDataUriImages: o = "omit_items" } = t;
|
|
1180
|
-
return
|
|
1181
|
-
let t = e.id || e.seedUid || e.SeedUid || e.storageTransactionId || e.storage_transaction_id, o = i == null ? `${r}/${
|
|
1127
|
+
return dt(e, o).map((e) => {
|
|
1128
|
+
let t = e.id || e.seedUid || e.SeedUid || e.storageTransactionId || e.storage_transaction_id, o = i == null ? `${r}/${S(n)}/${t}` : `${i.replace(/\/$/, "")}/${(a ?? "attestation/view").replace(/^\//, "")}/${t}`, s = e.link || e.Link || e.import_url || e.importUrl || o, c;
|
|
1182
1129
|
if (e.pubDate || e.PubDate) {
|
|
1183
1130
|
let t = e.pubDate || e.PubDate;
|
|
1184
1131
|
c = new Date(t);
|
|
@@ -1187,7 +1134,7 @@ function gt(e, t) {
|
|
|
1187
1134
|
let t = e.publishedAt || e.createdAt || e.updatedAt;
|
|
1188
1135
|
c = t && typeof t == "object" && t.constructor === Date ? t : new Date(t);
|
|
1189
1136
|
} else c = /* @__PURE__ */ new Date();
|
|
1190
|
-
let l =
|
|
1137
|
+
let l = st(e), u = ct(e), d = {
|
|
1191
1138
|
...e,
|
|
1192
1139
|
id: t,
|
|
1193
1140
|
title: e.title || e.Title || "Untitled",
|
|
@@ -1207,8 +1154,8 @@ function gt(e, t) {
|
|
|
1207
1154
|
}), d;
|
|
1208
1155
|
});
|
|
1209
1156
|
}
|
|
1210
|
-
var
|
|
1211
|
-
let l =
|
|
1157
|
+
var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
1158
|
+
let l = A(c), u = S(t), d = `${l.feedUrl}/${u}/${n}`, f = r ? `${d}?v=${r}` : d, p = `${l.title} - ${bt(u)}`, m = /* @__PURE__ */ new Date(), h = j(), g = [];
|
|
1212
1159
|
if (i) {
|
|
1213
1160
|
let e = i.baseUrl.replace(/\?.*$/, ""), t = e.includes("?") ? "&" : "?";
|
|
1214
1161
|
i.hasNext && g.push({
|
|
@@ -1226,7 +1173,7 @@ var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1226
1173
|
rel: e.rel,
|
|
1227
1174
|
href: e.href
|
|
1228
1175
|
});
|
|
1229
|
-
let _ =
|
|
1176
|
+
let _ = yt(e, {
|
|
1230
1177
|
schemaName: t,
|
|
1231
1178
|
siteUrl: l.siteUrl,
|
|
1232
1179
|
itemUrlBase: h.itemUrlBase,
|
|
@@ -1282,7 +1229,7 @@ var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1282
1229
|
return t;
|
|
1283
1230
|
})
|
|
1284
1231
|
};
|
|
1285
|
-
return Promise.resolve(
|
|
1232
|
+
return Promise.resolve(ce(t));
|
|
1286
1233
|
}
|
|
1287
1234
|
case "json": {
|
|
1288
1235
|
let e = i?.hasNext ? `${i.baseUrl.replace(/\?.*$/, "")}?page=${i.page + 1}` : void 0, t = {
|
|
@@ -1311,7 +1258,7 @@ var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1311
1258
|
}
|
|
1312
1259
|
return t;
|
|
1313
1260
|
})
|
|
1314
|
-
}, n =
|
|
1261
|
+
}, n = le(t);
|
|
1315
1262
|
return Promise.resolve(typeof n == "string" ? n : JSON.stringify(n));
|
|
1316
1263
|
}
|
|
1317
1264
|
default: {
|
|
@@ -1339,26 +1286,26 @@ var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1339
1286
|
value: e.id,
|
|
1340
1287
|
isPermaLink: typeof e.id == "string" && (e.id.startsWith("http://") || e.id.startsWith("https://"))
|
|
1341
1288
|
});
|
|
1342
|
-
let r =
|
|
1343
|
-
if (r &&
|
|
1289
|
+
let r = mt(e);
|
|
1290
|
+
if (r && ht(n, e, r, t, l.author, l.copyright), typeof e.content == "string" && e.content.trim() !== "" && n["content:encoded"] === void 0 && (n["content:encoded"] = e.content), n.dc = {}, (e.date || e.pubDate) && (n.dc.date = e.date || e.pubDate), e.timeCreated) {
|
|
1344
1291
|
let t = /* @__PURE__ */ new Date(e.timeCreated * 1e3);
|
|
1345
1292
|
n.dc.dates || (n.dc.dates = []), n.dc.dates.push(t);
|
|
1346
1293
|
}
|
|
1347
1294
|
return (e.seedUid || e.SeedUid) && (n.dc.identifier || (n.dc.identifier = []), n.dc.identifier.push(e.seedUid || e.SeedUid)), (e.storageTransactionId || e.storage_transaction_id) && (n.dc.identifier || (n.dc.identifier = []), n.dc.identifier.push(e.storageTransactionId || e.storage_transaction_id)), (e.import_url || e.importUrl) && (n.dc.source = e.import_url || e.importUrl), (e.seedUid || e.SeedUid) && (n.seedUid = e.seedUid || e.SeedUid), (e.storageTransactionId || e.storage_transaction_id) && (n.storageTransactionId = e.storageTransactionId || e.storage_transaction_id), e.timeCreated && (n.timeCreated = e.timeCreated), n;
|
|
1348
1295
|
})
|
|
1349
1296
|
};
|
|
1350
|
-
return Promise.resolve(
|
|
1297
|
+
return Promise.resolve(Ke(e));
|
|
1351
1298
|
}
|
|
1352
1299
|
}
|
|
1353
1300
|
};
|
|
1354
|
-
function
|
|
1301
|
+
function Q(e) {
|
|
1355
1302
|
switch (e) {
|
|
1356
1303
|
case "atom": return "application/atom+xml; charset=utf-8";
|
|
1357
1304
|
case "json": return "application/feed+json; charset=utf-8";
|
|
1358
1305
|
default: return "application/rss+xml; charset=utf-8";
|
|
1359
1306
|
}
|
|
1360
1307
|
}
|
|
1361
|
-
function
|
|
1308
|
+
function $(e) {
|
|
1362
1309
|
let t = e.toLowerCase();
|
|
1363
1310
|
return [
|
|
1364
1311
|
"rss",
|
|
@@ -1366,22 +1313,22 @@ function vt(e) {
|
|
|
1366
1313
|
"json"
|
|
1367
1314
|
].includes(t) ? t : null;
|
|
1368
1315
|
}
|
|
1369
|
-
function
|
|
1316
|
+
function bt(e) {
|
|
1370
1317
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1371
1318
|
}
|
|
1372
|
-
async function
|
|
1373
|
-
let o =
|
|
1319
|
+
async function xt(e, t, n, r, i, a) {
|
|
1320
|
+
let o = $(t);
|
|
1374
1321
|
if (!o) return new Response(JSON.stringify({ error: `Invalid feed format: ${t}` }), {
|
|
1375
1322
|
status: 400,
|
|
1376
1323
|
headers: { "Content-Type": "application/json" }
|
|
1377
1324
|
});
|
|
1378
|
-
let s =
|
|
1325
|
+
let s = S.singular(e.toLowerCase()), c = S(s), l = A(a), u = j(), d = Math.max(1, i ?? 1), f = u.pageSize, p = (d - 1) * f, m = d > 1 ? { page: d } : void 0;
|
|
1379
1326
|
console.log(`Schema name: ${s}`), console.log(`Collection name: ${c}`);
|
|
1380
|
-
let h =
|
|
1327
|
+
let h = gt(), g = K();
|
|
1381
1328
|
try {
|
|
1382
1329
|
if (g.enabled) {
|
|
1383
1330
|
let e = await h.getFeedContent(s, o, m);
|
|
1384
|
-
if (e) return n &&
|
|
1331
|
+
if (e) return n && Ze(n, e.etag) ? (console.log(`Cache hit with ETag match for ${s}:${o} - returning 304`), new Response(null, {
|
|
1385
1332
|
status: 304,
|
|
1386
1333
|
headers: {
|
|
1387
1334
|
ETag: e.etag,
|
|
@@ -1403,11 +1350,11 @@ async function bt(e, t, n, r, i, a) {
|
|
|
1403
1350
|
}
|
|
1404
1351
|
console.log(`Cache miss for ${s}:${o} - fetching items`);
|
|
1405
1352
|
let e = await (async () => {
|
|
1406
|
-
let e = await
|
|
1353
|
+
let e = await we(s, {
|
|
1407
1354
|
limit: f,
|
|
1408
1355
|
skip: p
|
|
1409
1356
|
});
|
|
1410
|
-
return console.log(`Found ${e.length} feed items for schema ${s}`), g.imageMetadata?.enabled ?
|
|
1357
|
+
return console.log(`Found ${e.length} feed items for schema ${s}`), g.imageMetadata?.enabled ? vt(e, new tt({
|
|
1411
1358
|
gateways: g.imageMetadata.gateways,
|
|
1412
1359
|
timeout: g.imageMetadata.timeout
|
|
1413
1360
|
}), h) : e;
|
|
@@ -1419,12 +1366,12 @@ async function bt(e, t, n, r, i, a) {
|
|
|
1419
1366
|
href: `${l.feedUrl}/${c}/archive/${t.getFullYear()}/${t.getMonth() + 1}/${o}`
|
|
1420
1367
|
});
|
|
1421
1368
|
}
|
|
1422
|
-
let _ = await
|
|
1369
|
+
let _ = await Z(e, s, o, r, {
|
|
1423
1370
|
page: d,
|
|
1424
1371
|
pageSize: f,
|
|
1425
1372
|
hasNext: i,
|
|
1426
1373
|
baseUrl: t
|
|
1427
|
-
}, u.length ? u : void 0, !1, void 0, a), v =
|
|
1374
|
+
}, u.length ? u : void 0, !1, void 0, a), v = Q(o);
|
|
1428
1375
|
if (g.enabled) {
|
|
1429
1376
|
await h.setFeedContent(s, o, _, v, m);
|
|
1430
1377
|
let e = await h.getFeedContent(s, o, m), t = e?.etag || "", n = e?.lastModified || Math.floor(Date.now() / 1e3);
|
|
@@ -1475,7 +1422,7 @@ async function bt(e, t, n, r, i, a) {
|
|
|
1475
1422
|
});
|
|
1476
1423
|
}
|
|
1477
1424
|
}
|
|
1478
|
-
async function
|
|
1425
|
+
async function St(e, t, n, r, i, a, o) {
|
|
1479
1426
|
if (t < 1970 || t > 2100) return new Response(JSON.stringify({ error: `Invalid year: ${t}` }), {
|
|
1480
1427
|
status: 400,
|
|
1481
1428
|
headers: { "Content-Type": "application/json" }
|
|
@@ -1484,19 +1431,19 @@ async function xt(e, t, n, r, i, a, o) {
|
|
|
1484
1431
|
status: 400,
|
|
1485
1432
|
headers: { "Content-Type": "application/json" }
|
|
1486
1433
|
});
|
|
1487
|
-
let s =
|
|
1434
|
+
let s = $(r);
|
|
1488
1435
|
if (!s) return new Response(JSON.stringify({ error: `Invalid feed format: ${r}` }), {
|
|
1489
1436
|
status: 400,
|
|
1490
1437
|
headers: { "Content-Type": "application/json" }
|
|
1491
1438
|
});
|
|
1492
|
-
let c =
|
|
1439
|
+
let c = S.singular(e.toLowerCase()), l = S(c), u = A(o), d = { archive: {
|
|
1493
1440
|
year: t,
|
|
1494
1441
|
month: n
|
|
1495
|
-
} }, f =
|
|
1442
|
+
} }, f = gt(), p = K();
|
|
1496
1443
|
try {
|
|
1497
1444
|
if (p.enabled) {
|
|
1498
1445
|
let e = await f.getFeedContent(c, s, d);
|
|
1499
|
-
if (e) return i &&
|
|
1446
|
+
if (e) return i && Ze(i, e.etag) ? new Response(null, {
|
|
1500
1447
|
status: 304,
|
|
1501
1448
|
headers: {
|
|
1502
1449
|
ETag: e.etag,
|
|
@@ -1516,7 +1463,7 @@ async function xt(e, t, n, r, i, a, o) {
|
|
|
1516
1463
|
}
|
|
1517
1464
|
});
|
|
1518
1465
|
}
|
|
1519
|
-
let e = await
|
|
1466
|
+
let e = await Te(c, t, n), r = `${u.feedUrl}/${l}/${s}`, m = `${u.feedUrl}/${l}/archive`, h = [{
|
|
1520
1467
|
rel: "prev-archive",
|
|
1521
1468
|
href: `${m}/${n === 1 ? t - 1 : t}/${n === 1 ? 12 : n - 1}/${s}`
|
|
1522
1469
|
}, {
|
|
@@ -1527,7 +1474,7 @@ async function xt(e, t, n, r, i, a, o) {
|
|
|
1527
1474
|
rel: "next-archive",
|
|
1528
1475
|
href: `${m}/${g}/${_}/${s}`
|
|
1529
1476
|
});
|
|
1530
|
-
let y = await
|
|
1477
|
+
let y = await Z(e, c, s, a, void 0, h, !0, void 0, o), b = Q(s);
|
|
1531
1478
|
if (p.enabled) {
|
|
1532
1479
|
await f.setFeedContent(c, s, y, b, d);
|
|
1533
1480
|
let e = await f.getFeedContent(c, s, d), t = e?.etag || "", n = e?.lastModified || Math.floor(Date.now() / 1e3);
|
|
@@ -1564,6 +1511,6 @@ async function xt(e, t, n, r, i, a, o) {
|
|
|
1564
1511
|
}
|
|
1565
1512
|
}
|
|
1566
1513
|
//#endregion
|
|
1567
|
-
export { t as DEFAULT_ARWEAVE_HOST,
|
|
1514
|
+
export { t as DEFAULT_ARWEAVE_HOST, D as DEFAULT_SITE_CONFIG, v as FEED_RICH_BODY_STORAGE_SCHEMAS, r as SEED_RSS_IMAGE_RELATION_FIELD_KEYS, i as classifyMediaRef, Z as createFeed, y as enrichImageSeedCloneForFeed, ut as feedItemRichTextContainsDataUriImage, dt as filterItemsByRichTextDataUriImagePolicy, he as getClient, c as getFeedItemStringField, we as getFeedItemsBySchemaName, Te as getFeedItemsBySchemaNameForMonth, _e as getSiteConfig, St as handleArchiveFeedRequest, xt as handleFeedRequest, E as initializeFeedPlatform, me as initializeSeedClient, l as isEasAttestationExplorerUrl, x as isFeedRichBodyStorageSchema, j as loadFeedConfig, d as normalizeFeedItemFields, Oe as parseRssString, ct as pickFeedItemContent, st as pickFeedItemDescription, _t as resetCacheManager, ye as resetSiteConfig, h as resolveSeedRssImageRelationFromItem, g as resolveSeedRssImageRelationRef, A as resolveSiteConfig, ve as setSiteConfig, ge as teardownSeedClient };
|
|
1568
1515
|
|
|
1569
1516
|
//# sourceMappingURL=index.js.map
|