@seedprotocol/feed 0.6.6 → 0.6.7
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/index.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
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, ensureReadGatewaySelected as a, getArweaveReadGatewayHostsForPrimary as o, getDefaultArweaveReadGatewayHostsOrdered as s, getFeedItemStringField as c, getReadGatewayHostsForConfig as l, getResolvedSeedGatewayEndpoints as u, isEasAttestationExplorerUrl as d,
|
|
2
|
-
import { FEED_RICH_BODY_STORAGE_SCHEMAS as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { generateAtomFeed as
|
|
6
|
-
import { create as
|
|
7
|
-
import { createHash as
|
|
8
|
-
import { promises as
|
|
9
|
-
import { join as
|
|
10
|
-
import
|
|
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, ensureReadGatewaySelected as a, getArweaveReadGatewayHostsForPrimary as o, getDefaultArweaveReadGatewayHostsOrdered as s, getFeedItemStringField as c, getReadGatewayHostsForConfig as l, getResolvedSeedGatewayEndpoints as u, isEasAttestationExplorerUrl as d, isGatewayHostCircuitOpen as f, normalizeFeedItemFields as p, recordGatewayHostFailure as m, recordGatewayHostSuccess as h, resolveArweaveHostFromEnv as g, resolveSeedRssImageRelationFromItem as _, resolveSeedRssImageRelationRef as v, resolveSeedRssImageRelationRef as y } from "@seedprotocol/arweave";
|
|
2
|
+
import { FEED_RICH_BODY_STORAGE_SCHEMAS as b, enrichImageSeedCloneForFeed as ee, feedRichBodyModelPriority as x, getArweaveUrlForTransaction as S, getFeedFieldStorageModels as te, getFeedListElementStorageModels as C, isFeedRichBodyStorageSchema as w, queryBySchema as ne, queryBySchemaForMonth as re } from "@seedprotocol/query";
|
|
3
|
+
import ie from "rss-parser";
|
|
4
|
+
import T from "pluralize";
|
|
5
|
+
import { generateAtomFeed as ae, generateJsonFeed as oe } from "feedsmith";
|
|
6
|
+
import { create as se } from "xmlbuilder2";
|
|
7
|
+
import { createHash as ce } from "crypto";
|
|
8
|
+
import { promises as E } from "fs";
|
|
9
|
+
import { join as D } from "path";
|
|
10
|
+
import le from "image-size";
|
|
11
11
|
//#region src/bootstrap.ts
|
|
12
|
-
var
|
|
13
|
-
function
|
|
14
|
-
return e ??
|
|
12
|
+
var O = !1;
|
|
13
|
+
function ue(e) {
|
|
14
|
+
return e ?? g() ?? n;
|
|
15
15
|
}
|
|
16
|
-
async function
|
|
17
|
-
if (
|
|
16
|
+
async function k(e) {
|
|
17
|
+
if (O) return;
|
|
18
18
|
let [{ registerNodeEasPlatform: t }, { registerNodeArweavePlatform: n }] = await Promise.all([import("@seedprotocol/eas/node"), import("@seedprotocol/arweave/node")]);
|
|
19
|
-
if (t(), n({ arweaveDomain:
|
|
19
|
+
if (t(), n({ arweaveDomain: ue(e?.arweaveDomain) }), e?.arweaveDomain) {
|
|
20
20
|
let { BaseArweaveClient: t } = await import("@seedprotocol/arweave");
|
|
21
21
|
t.setHost(e.arweaveDomain);
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
var ue = D;
|
|
26
|
-
async function de() {
|
|
27
|
-
return await D(), { isInitialized: () => E };
|
|
23
|
+
O = !0;
|
|
28
24
|
}
|
|
25
|
+
var de = k;
|
|
29
26
|
async function fe() {
|
|
30
|
-
|
|
27
|
+
return await k(), { isInitialized: () => O };
|
|
28
|
+
}
|
|
29
|
+
async function pe() {
|
|
30
|
+
O = !1;
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/config.ts
|
|
34
|
-
var
|
|
34
|
+
var A = {
|
|
35
35
|
title: "Seed Protocol",
|
|
36
36
|
description: "Content published via Seed Protocol",
|
|
37
37
|
siteUrl: "https://seedprotocol.io",
|
|
@@ -44,15 +44,15 @@ var O = {
|
|
|
44
44
|
link: "https://seedprotocol.io"
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
function
|
|
47
|
+
function j(e) {
|
|
48
48
|
return {
|
|
49
49
|
...e,
|
|
50
50
|
author: e.author ? { ...e.author } : void 0
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
var
|
|
54
|
-
function
|
|
55
|
-
if (!e) return
|
|
53
|
+
var M = j(A);
|
|
54
|
+
function N(e, t = M) {
|
|
55
|
+
if (!e) return j(t);
|
|
56
56
|
let n = {
|
|
57
57
|
...t,
|
|
58
58
|
...e,
|
|
@@ -64,16 +64,16 @@ function j(e, t = A) {
|
|
|
64
64
|
name: e.author.name ?? n.author?.name ?? ""
|
|
65
65
|
}), n;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
return
|
|
67
|
+
function me() {
|
|
68
|
+
return j(M);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
return
|
|
70
|
+
function he(e) {
|
|
71
|
+
return M = N(e, A), me();
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
73
|
+
function ge() {
|
|
74
|
+
M = j(A);
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function P() {
|
|
77
77
|
return {
|
|
78
78
|
itemUrlBase: process.env.FEED_ITEM_URL_BASE?.trim() || "https://optimism-sepolia.easscan.org",
|
|
79
79
|
itemUrlPath: process.env.FEED_ITEM_URL_PATH?.trim() || "attestation/view",
|
|
@@ -85,7 +85,7 @@ function M() {
|
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|
|
87
87
|
//#region src/getFeedItems.ts
|
|
88
|
-
var
|
|
88
|
+
var F = (e) => {
|
|
89
89
|
let t = /* @__PURE__ */ new Date(e * 1e3), n = [
|
|
90
90
|
"Sun",
|
|
91
91
|
"Mon",
|
|
@@ -109,12 +109,12 @@ var ge = (e) => {
|
|
|
109
109
|
"Dec"
|
|
110
110
|
], i = n[t.getUTCDay()], a = r[t.getUTCMonth()], o = t.getUTCFullYear();
|
|
111
111
|
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`;
|
|
112
|
-
}, _e = (e) => e === "image" ? "images" : e === "post" ? "posts" : e.toLowerCase() + "s",
|
|
112
|
+
}, _e = (e) => e === "image" ? "images" : e === "post" ? "posts" : e.toLowerCase() + "s", I = (e, t, n, r) => {
|
|
113
113
|
let { itemUrlBase: i, itemUrlPath: a, siteUrl: o } = r;
|
|
114
114
|
!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);
|
|
115
115
|
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 = _e(n), d = t && typeof t == "string" && t.trim() !== "" ? t : "unknown", f;
|
|
116
116
|
if (l && l !== t && l.length > 0) try {
|
|
117
|
-
f =
|
|
117
|
+
f = S(l);
|
|
118
118
|
} catch (e) {
|
|
119
119
|
console.error("[feed] [setFeedItemDefaults] Error generating Arweave URL:", e), f = i == null ? `${o.replace(/\/$/, "")}/${u}/${d}` : `${i.replace(/\/$/, "")}/${(a ?? "attestation/view").replace(/^\//, "")}/${d}`;
|
|
120
120
|
}
|
|
@@ -123,102 +123,102 @@ var ge = (e) => {
|
|
|
123
123
|
!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));
|
|
124
124
|
let m = e.guid || e.Guid;
|
|
125
125
|
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) {
|
|
126
|
-
let t =
|
|
126
|
+
let t = F(e.timeCreated);
|
|
127
127
|
e.pubDate = t, e.PubDate = t;
|
|
128
128
|
} else e.pubDate && !e.PubDate ? e.PubDate = e.pubDate : e.PubDate && !e.pubDate && (e.pubDate = e.PubDate);
|
|
129
129
|
!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);
|
|
130
|
-
},
|
|
130
|
+
}, ve = (e, t) => {
|
|
131
131
|
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) {
|
|
132
|
-
let t =
|
|
132
|
+
let t = F(e.timeCreated);
|
|
133
133
|
e.pubDate = t, e.PubDate = t;
|
|
134
134
|
} else e.pubDate && !e.PubDate ? e.PubDate = e.pubDate : e.PubDate && !e.pubDate && (e.pubDate = e.PubDate);
|
|
135
135
|
!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);
|
|
136
136
|
let n = 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, r = e.storageTransactionId && typeof e.storageTransactionId == "string" && e.storageTransactionId.trim() !== "" && e.storageTransactionId !== "undefined" && e.storageTransactionId !== t ? e.storageTransactionId.trim() : null, i = n || r;
|
|
137
137
|
if (delete e.link, delete e.Link, delete e.guid, delete e.Guid, i && i.length > 0) try {
|
|
138
|
-
let t =
|
|
138
|
+
let t = S(i);
|
|
139
139
|
e.link = t, e.Link = t;
|
|
140
140
|
} catch {}
|
|
141
141
|
};
|
|
142
|
-
function
|
|
142
|
+
function ye(e) {
|
|
143
143
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
144
144
|
let t = e;
|
|
145
145
|
return typeof t.seedUid == "string" || typeof t.SeedUid == "string";
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
|
|
147
|
+
function be(e, t, n) {
|
|
148
|
+
I(e, e.seedUid || e.SeedUid || "", t, n);
|
|
149
149
|
for (let r of Object.keys(e)) {
|
|
150
150
|
if (r.startsWith("_")) continue;
|
|
151
151
|
let i = e[r];
|
|
152
152
|
if (Array.isArray(i)) {
|
|
153
|
-
for (let e of i) if (
|
|
153
|
+
for (let e of i) if (ye(e)) {
|
|
154
154
|
let r = e.seedUid || e.SeedUid || "", i = typeof e.schemaName == "string" ? e.schemaName : t;
|
|
155
|
-
i === "image" ?
|
|
155
|
+
i === "image" ? ve(e, r) : I(e, r, i, n);
|
|
156
156
|
}
|
|
157
|
-
} else if (
|
|
157
|
+
} else if (ye(i)) {
|
|
158
158
|
let e = i.seedUid || i.SeedUid || "", r = typeof i.schemaName == "string" ? i.schemaName : t;
|
|
159
|
-
r === "image" ?
|
|
159
|
+
r === "image" ? ve(i, e) : I(i, e, r, n);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
function
|
|
164
|
-
let n =
|
|
163
|
+
function xe(e, t) {
|
|
164
|
+
let n = P(), r = {
|
|
165
165
|
itemUrlBase: n.itemUrlBase,
|
|
166
166
|
itemUrlPath: n.itemUrlPath,
|
|
167
167
|
siteUrl: n.siteUrl
|
|
168
168
|
};
|
|
169
169
|
return t.map((t) => {
|
|
170
170
|
let n = t.data;
|
|
171
|
-
return
|
|
171
|
+
return be(n, e, r), n;
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
-
var
|
|
175
|
-
await
|
|
176
|
-
let n =
|
|
174
|
+
var Se = async (e, t) => {
|
|
175
|
+
await k();
|
|
176
|
+
let n = P(), r = t?.limit ?? 100, i = t?.skip ?? 0, { items: a } = await ne(e, {
|
|
177
177
|
limit: r,
|
|
178
178
|
skip: i,
|
|
179
179
|
expandRelations: n.expandRelations !== !1,
|
|
180
180
|
hydrateStorage: !0
|
|
181
181
|
});
|
|
182
|
-
return
|
|
183
|
-
},
|
|
184
|
-
await
|
|
185
|
-
let r =
|
|
186
|
-
return
|
|
182
|
+
return xe(e, a);
|
|
183
|
+
}, Ce = async (e, t, n) => {
|
|
184
|
+
await k();
|
|
185
|
+
let r = P();
|
|
186
|
+
return xe(e, await re(e, t, n, {
|
|
187
187
|
expandRelations: r.expandRelations !== !1,
|
|
188
188
|
hydrateStorage: !0
|
|
189
189
|
}));
|
|
190
190
|
};
|
|
191
191
|
//#endregion
|
|
192
192
|
//#region src/consume/parseRss.ts
|
|
193
|
-
function
|
|
193
|
+
function we(e) {
|
|
194
194
|
try {
|
|
195
195
|
return JSON.parse(JSON.stringify(e));
|
|
196
196
|
} catch {
|
|
197
197
|
return { ...e };
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
var
|
|
200
|
+
var Te = new ie({ customFields: { item: [
|
|
201
201
|
"featureImage",
|
|
202
202
|
"feature_image",
|
|
203
203
|
"content:encoded",
|
|
204
204
|
"seedUid",
|
|
205
205
|
"SeedUid"
|
|
206
206
|
] } });
|
|
207
|
-
async function
|
|
208
|
-
let t = await
|
|
207
|
+
async function Ee(e) {
|
|
208
|
+
let t = await Te.parseString(e);
|
|
209
209
|
return {
|
|
210
210
|
title: t.title,
|
|
211
211
|
link: t.link,
|
|
212
212
|
description: t.description,
|
|
213
|
-
items: (t.items ?? []).map(
|
|
213
|
+
items: (t.items ?? []).map(we)
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
216
|
//#endregion
|
|
217
217
|
//#region src/rss/generateRssXml.ts
|
|
218
|
-
var L = "http://purl.org/dc/elements/1.1/", R = "http://purl.org/rss/1.0/modules/content/", z = "http://search.yahoo.com/mrss/",
|
|
218
|
+
var L = "http://purl.org/dc/elements/1.1/", R = "http://purl.org/rss/1.0/modules/content/", z = "http://search.yahoo.com/mrss/", De = { publication: {
|
|
219
219
|
prefix: "publication",
|
|
220
220
|
uri: "https://seedprotocol.io/ns/publication/1.0"
|
|
221
|
-
} },
|
|
221
|
+
} }, Oe = "https://seedprotocol.io/ns/relations", B = /* @__PURE__ */ new Set([
|
|
222
222
|
"xml",
|
|
223
223
|
"xmlns",
|
|
224
224
|
"dc",
|
|
@@ -226,17 +226,17 @@ var L = "http://purl.org/dc/elements/1.1/", R = "http://purl.org/rss/1.0/modules
|
|
|
226
226
|
"content",
|
|
227
227
|
"atom",
|
|
228
228
|
"fh"
|
|
229
|
-
]),
|
|
229
|
+
]), ke = /* @__PURE__ */ new Set([
|
|
230
230
|
"Title",
|
|
231
231
|
"Link",
|
|
232
232
|
"Guid",
|
|
233
233
|
"PubDate",
|
|
234
234
|
"SeedUid"
|
|
235
235
|
]);
|
|
236
|
-
function
|
|
237
|
-
return
|
|
236
|
+
function Ae(e, t) {
|
|
237
|
+
return ke.has(e) ? e.charAt(0).toLowerCase() + e.slice(1) in t : !1;
|
|
238
238
|
}
|
|
239
|
-
var
|
|
239
|
+
var V = [
|
|
240
240
|
"title",
|
|
241
241
|
"link",
|
|
242
242
|
"description",
|
|
@@ -260,7 +260,7 @@ var B = [
|
|
|
260
260
|
"media:category",
|
|
261
261
|
"media:group"
|
|
262
262
|
];
|
|
263
|
-
function
|
|
263
|
+
function H(e) {
|
|
264
264
|
if (e instanceof Date) return e.toUTCString();
|
|
265
265
|
if (typeof e == "string") {
|
|
266
266
|
let t = new Date(e);
|
|
@@ -268,13 +268,13 @@ function V(e) {
|
|
|
268
268
|
}
|
|
269
269
|
return String(e);
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function je(e) {
|
|
272
272
|
return /[<>&]|]]>/.test(e);
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function U(e, t) {
|
|
275
275
|
let n = String(t);
|
|
276
276
|
if (n !== "") {
|
|
277
|
-
if (
|
|
277
|
+
if (je(n)) {
|
|
278
278
|
if (n.includes("]]>")) {
|
|
279
279
|
let t = n.split("]]>");
|
|
280
280
|
for (let n = 0; n < t.length; n++) e.dat(t[n]), n < t.length - 1 && e.txt("]]>");
|
|
@@ -282,11 +282,11 @@ function H(e, t) {
|
|
|
282
282
|
} else e.txt(n);
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
-
function
|
|
285
|
+
function W(e) {
|
|
286
286
|
return typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof Date);
|
|
287
287
|
}
|
|
288
|
-
var
|
|
289
|
-
...
|
|
288
|
+
var Me = 4, Ne = /* @__PURE__ */ new Set([
|
|
289
|
+
...V,
|
|
290
290
|
"guid",
|
|
291
291
|
"source",
|
|
292
292
|
"dc",
|
|
@@ -294,79 +294,79 @@ var Ae = 4, je = /* @__PURE__ */ new Set([
|
|
|
294
294
|
"content:encoded",
|
|
295
295
|
"items"
|
|
296
296
|
]);
|
|
297
|
-
function
|
|
297
|
+
function Pe(e) {
|
|
298
298
|
return e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e;
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function Fe(e) {
|
|
301
301
|
return e.trim().replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[^A-Za-z_]+/, "").replace(/^$/, "rel").toLowerCase();
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
if (!t.has(e) && !
|
|
303
|
+
function Ie(e, t) {
|
|
304
|
+
if (!t.has(e) && !B.has(e)) return t.add(e), e;
|
|
305
305
|
let n = 2;
|
|
306
306
|
for (;;) {
|
|
307
307
|
let r = `${e}${n}`;
|
|
308
|
-
if (!t.has(r) && !
|
|
308
|
+
if (!t.has(r) && !B.has(r)) return t.add(r), r;
|
|
309
309
|
n += 1;
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
function
|
|
313
|
-
return Array.isArray(e) && e.length > 0 && e.every((e) =>
|
|
312
|
+
function Le(e) {
|
|
313
|
+
return Array.isArray(e) && e.length > 0 && e.every((e) => W(e));
|
|
314
314
|
}
|
|
315
|
-
function
|
|
316
|
-
let t = { ...
|
|
315
|
+
function Re(e) {
|
|
316
|
+
let t = { ...De }, n = new Set(Object.values(t).map((e) => e.prefix)), r = /* @__PURE__ */ new Set();
|
|
317
317
|
for (let t of e) for (let [e, n] of Object.entries(t)) {
|
|
318
|
-
let t = e === "author" &&
|
|
319
|
-
e.startsWith("_") || (!
|
|
318
|
+
let t = e === "author" && W(n) || e === "authors" && Le(n);
|
|
319
|
+
e.startsWith("_") || (!Ne.has(e) || t) && (W(n) || Le(n)) && r.add(Pe(e));
|
|
320
320
|
}
|
|
321
321
|
let i = [...r].sort();
|
|
322
322
|
for (let e of i) t[e] || (t[e] = {
|
|
323
|
-
prefix:
|
|
324
|
-
uri: `${
|
|
323
|
+
prefix: Ie(Fe(e), n),
|
|
324
|
+
uri: `${Oe}/${e}/1.0`
|
|
325
325
|
});
|
|
326
326
|
return t;
|
|
327
327
|
}
|
|
328
|
-
function
|
|
328
|
+
function G(e, t) {
|
|
329
329
|
if (e in t) return t[e];
|
|
330
330
|
if (e.endsWith("s") && e.length > 1) {
|
|
331
331
|
let n = e.slice(0, -1);
|
|
332
332
|
if (n in t) return t[n];
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function ze(e, t) {
|
|
336
336
|
return t ? `${t.prefix}:${e}` : e;
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function K(e, t, n, r, i = 0, a) {
|
|
339
339
|
let o = e.ele(n);
|
|
340
340
|
for (let [e, n] of Object.entries(t)) {
|
|
341
341
|
if (n == null || e.startsWith("_") || e === "items") continue;
|
|
342
|
-
let t =
|
|
343
|
-
if (i >=
|
|
344
|
-
|
|
342
|
+
let t = ze(e, a);
|
|
343
|
+
if (i >= Me) {
|
|
344
|
+
U(o.ele(t), typeof n == "object" ? JSON.stringify(n) : String(n));
|
|
345
345
|
continue;
|
|
346
346
|
}
|
|
347
347
|
if (Array.isArray(n)) {
|
|
348
|
-
let t =
|
|
349
|
-
for (let e of n) e != null && (
|
|
348
|
+
let t = ze(e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e, a);
|
|
349
|
+
for (let e of n) e != null && (W(e) ? K(o, e, t, !1, i + 1, a) : U(o.ele(t), String(e)));
|
|
350
350
|
continue;
|
|
351
351
|
}
|
|
352
|
-
if (
|
|
353
|
-
|
|
352
|
+
if (W(n)) {
|
|
353
|
+
K(o, n, t, !1, i + 1, a);
|
|
354
354
|
continue;
|
|
355
355
|
}
|
|
356
|
-
|
|
356
|
+
U(o.ele(t), String(n));
|
|
357
357
|
}
|
|
358
358
|
if (r) {
|
|
359
359
|
let n = t.name ?? t.seedUid;
|
|
360
360
|
n && e.ele(L, "creator").txt(String(n));
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function Be(e, t, n, r, i) {
|
|
364
364
|
if (!(n == null || t.startsWith("_")) && t !== "items") {
|
|
365
365
|
if (t === "guid") {
|
|
366
366
|
let t = n, r = t?.value ?? String(n);
|
|
367
367
|
if (!r) return;
|
|
368
368
|
let i = {};
|
|
369
|
-
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"),
|
|
369
|
+
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"), U(e.ele("guid", i), r);
|
|
370
370
|
return;
|
|
371
371
|
}
|
|
372
372
|
if (t === "source" && typeof n == "object" && n) {
|
|
@@ -392,21 +392,21 @@ function Re(e, t, n, r, i) {
|
|
|
392
392
|
if (Array.isArray(r)) {
|
|
393
393
|
for (let t of r) if (t != null) {
|
|
394
394
|
let r = e.ele(L, n);
|
|
395
|
-
t instanceof Date ? r.txt(t.toISOString()) :
|
|
395
|
+
t instanceof Date ? r.txt(t.toISOString()) : U(r, String(t));
|
|
396
396
|
}
|
|
397
397
|
} else {
|
|
398
398
|
let t = e.ele(L, n);
|
|
399
|
-
r instanceof Date ? t.txt(r.toISOString()) :
|
|
399
|
+
r instanceof Date ? t.txt(r.toISOString()) : U(t, String(r));
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
return;
|
|
403
403
|
}
|
|
404
404
|
if (t === "content:encoded") {
|
|
405
|
-
|
|
405
|
+
U(e.ele(R, "encoded"), String(n));
|
|
406
406
|
return;
|
|
407
407
|
}
|
|
408
408
|
if (t === "content" && typeof n == "string" && !("content:encoded" in r)) {
|
|
409
|
-
|
|
409
|
+
U(e.ele(R, "encoded"), String(n));
|
|
410
410
|
return;
|
|
411
411
|
}
|
|
412
412
|
if (t !== "content") {
|
|
@@ -418,9 +418,9 @@ function Re(e, t, n, r, i) {
|
|
|
418
418
|
if (Array.isArray(r)) {
|
|
419
419
|
for (let e of r) if (e && typeof e == "object") {
|
|
420
420
|
let r = n.ele(z, t);
|
|
421
|
-
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ?
|
|
421
|
+
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ? U(r, String(n)) : r.att(t, String(n)));
|
|
422
422
|
}
|
|
423
|
-
} else typeof r == "string" &&
|
|
423
|
+
} else typeof r == "string" && U(n.ele(z, t), r);
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
426
|
return;
|
|
@@ -432,26 +432,26 @@ function Re(e, t, n, r, i) {
|
|
|
432
432
|
let n = {}, i = null;
|
|
433
433
|
for (let [e, r] of Object.entries(t)) r != null && (e === "value" ? i = String(r) : n[e] = String(r));
|
|
434
434
|
let a = e.ele(z, r, n);
|
|
435
|
-
i !== null &&
|
|
435
|
+
i !== null && U(a, i);
|
|
436
436
|
}
|
|
437
437
|
return;
|
|
438
438
|
}
|
|
439
439
|
if (t.startsWith("media:") && typeof n == "string") {
|
|
440
440
|
let r = t.slice(6);
|
|
441
|
-
|
|
441
|
+
U(e.ele(z, r), n);
|
|
442
442
|
return;
|
|
443
443
|
}
|
|
444
444
|
if (n instanceof Date) {
|
|
445
|
-
e.ele(t).txt(
|
|
445
|
+
e.ele(t).txt(H(n));
|
|
446
446
|
return;
|
|
447
447
|
}
|
|
448
|
-
if (t === "author" &&
|
|
449
|
-
|
|
448
|
+
if (t === "author" && W(n)) {
|
|
449
|
+
K(e, n, "author", !0, 0, G(t, i));
|
|
450
450
|
return;
|
|
451
451
|
}
|
|
452
452
|
if (t === "authors" && Array.isArray(n)) {
|
|
453
|
-
let r =
|
|
454
|
-
for (let t of n) if (t &&
|
|
453
|
+
let r = G(t, i);
|
|
454
|
+
for (let t of n) if (t && W(t)) K(e, t, "author", !0, 0, r);
|
|
455
455
|
else {
|
|
456
456
|
let n = typeof t == "string" ? t : t && typeof t == "object" && "name" in t ? `${t.email ?? ""} (${t.name ?? ""})`.trim() || t.name : String(t);
|
|
457
457
|
n && e.ele("author").txt(n);
|
|
@@ -468,37 +468,37 @@ function Re(e, t, n, r, i) {
|
|
|
468
468
|
}
|
|
469
469
|
return;
|
|
470
470
|
}
|
|
471
|
-
if (Array.isArray(n) && n.length > 0 && n.every((e) =>
|
|
472
|
-
let r = t.endsWith("s") ? t.slice(0, -1) : t, a =
|
|
473
|
-
for (let t of n) t &&
|
|
471
|
+
if (Array.isArray(n) && n.length > 0 && n.every((e) => W(e))) {
|
|
472
|
+
let r = t.endsWith("s") ? t.slice(0, -1) : t, a = G(t, i);
|
|
473
|
+
for (let t of n) t && K(e, t, r, !1, 0, a);
|
|
474
474
|
return;
|
|
475
475
|
}
|
|
476
476
|
if (Array.isArray(n) && n.every((e) => typeof e == "string")) {
|
|
477
477
|
let r = t.endsWith("s") ? t.slice(0, -1) : t;
|
|
478
|
-
for (let t of n) t &&
|
|
478
|
+
for (let t of n) t && U(e.ele(r), t);
|
|
479
479
|
return;
|
|
480
480
|
}
|
|
481
|
-
if (
|
|
482
|
-
|
|
481
|
+
if (W(n)) {
|
|
482
|
+
K(e, n, t, !1, 0, G(t, i));
|
|
483
483
|
return;
|
|
484
484
|
}
|
|
485
|
-
|
|
485
|
+
U(e.ele(t), String(n));
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
|
-
var
|
|
490
|
-
function
|
|
491
|
-
let t =
|
|
489
|
+
var Ve = "http://www.w3.org/2005/Atom", He = "http://purl.org/syndication/history/1.0";
|
|
490
|
+
function Ue(e) {
|
|
491
|
+
let t = se({
|
|
492
492
|
version: "1.0",
|
|
493
493
|
encoding: "UTF-8"
|
|
494
|
-
}), n =
|
|
494
|
+
}), n = Re(e.items), r = {
|
|
495
495
|
"xmlns:dc": L,
|
|
496
496
|
"xmlns:content": R,
|
|
497
497
|
"xmlns:media": z,
|
|
498
|
-
"xmlns:atom":
|
|
498
|
+
"xmlns:atom": Ve,
|
|
499
499
|
...Object.values(n).reduce((e, t) => (e[`xmlns:${t.prefix}`] = t.uri, e), {})
|
|
500
500
|
};
|
|
501
|
-
e.isArchive && (r["xmlns:fh"] =
|
|
501
|
+
e.isArchive && (r["xmlns:fh"] = He);
|
|
502
502
|
let i = t.ele("rss", {
|
|
503
503
|
version: "2.0",
|
|
504
504
|
...r
|
|
@@ -507,50 +507,50 @@ function Ve(e) {
|
|
|
507
507
|
"xmlns:content": R,
|
|
508
508
|
"xmlns:media": z
|
|
509
509
|
});
|
|
510
|
-
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(
|
|
510
|
+
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(H(e.pubDate)), e.lastBuildDate && i.ele("lastBuildDate").txt(H(e.lastBuildDate)), e.links?.length) for (let t of e.links) {
|
|
511
511
|
let e = {
|
|
512
512
|
rel: t.rel,
|
|
513
513
|
href: t.href
|
|
514
514
|
};
|
|
515
|
-
t.type && (e.type = t.type), i.ele(
|
|
515
|
+
t.type && (e.type = t.type), i.ele(Ve, "link", e);
|
|
516
516
|
}
|
|
517
|
-
e.isArchive && i.ele(
|
|
518
|
-
let a = new Set(
|
|
517
|
+
e.isArchive && i.ele(He, "archive");
|
|
518
|
+
let a = new Set(V);
|
|
519
519
|
for (let t of e.items) {
|
|
520
520
|
let e = i.ele("item"), r = /* @__PURE__ */ new Set();
|
|
521
|
-
for (let i of
|
|
522
|
-
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !
|
|
523
|
-
for (let r of o)
|
|
521
|
+
for (let i of V) i in t && (Be(e, i, t[i], t, n), r.add(i));
|
|
522
|
+
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !Ae(e, t)).sort();
|
|
523
|
+
for (let r of o) Be(e, r, t[r], t, n);
|
|
524
524
|
}
|
|
525
525
|
return t.end({ prettyPrint: !0 });
|
|
526
526
|
}
|
|
527
527
|
//#endregion
|
|
528
528
|
//#region src/cache/types.ts
|
|
529
|
-
function
|
|
529
|
+
function q(e, t, n) {
|
|
530
530
|
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}`;
|
|
531
531
|
}
|
|
532
532
|
//#endregion
|
|
533
533
|
//#region src/utils/etag.ts
|
|
534
|
-
function
|
|
535
|
-
return `"${
|
|
534
|
+
function We(e) {
|
|
535
|
+
return `"${ce("md5").update(e).digest("hex").substring(0, 16)}"`;
|
|
536
536
|
}
|
|
537
|
-
function
|
|
538
|
-
return
|
|
537
|
+
function Ge(e, t, n, r) {
|
|
538
|
+
return We(`${e}-${t}-${n}-${r}`);
|
|
539
539
|
}
|
|
540
|
-
function
|
|
540
|
+
function Ke(e, t) {
|
|
541
541
|
let n = (e) => e.replace(/^"|"$/g, "");
|
|
542
542
|
return n(e) === n(t);
|
|
543
543
|
}
|
|
544
|
-
function
|
|
544
|
+
function qe(e) {
|
|
545
545
|
return e ? e.split(",").map((e) => e.trim()).filter((e) => e.length > 0) : [];
|
|
546
546
|
}
|
|
547
|
-
function
|
|
548
|
-
let n =
|
|
549
|
-
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) =>
|
|
547
|
+
function Je(e, t) {
|
|
548
|
+
let n = qe(e);
|
|
549
|
+
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) => Ke(e, t));
|
|
550
550
|
}
|
|
551
551
|
//#endregion
|
|
552
552
|
//#region src/cache/MemoryCache.ts
|
|
553
|
-
var
|
|
553
|
+
var Ye = class {
|
|
554
554
|
feedContentCache = /* @__PURE__ */ new Map();
|
|
555
555
|
imageMetadataCache = /* @__PURE__ */ new Map();
|
|
556
556
|
config;
|
|
@@ -558,14 +558,14 @@ var qe = class {
|
|
|
558
558
|
this.config = e;
|
|
559
559
|
}
|
|
560
560
|
getFeedContent(e, t, n) {
|
|
561
|
-
let r =
|
|
561
|
+
let r = q(e, t, n), i = this.feedContentCache.get(r);
|
|
562
562
|
return i ? Math.floor(Date.now() / 1e3) > i.expiresAt ? (this.feedContentCache.delete(r), null) : i : null;
|
|
563
563
|
}
|
|
564
564
|
setFeedContent(e, t, n, r, i, a) {
|
|
565
|
-
let o =
|
|
565
|
+
let o = q(e, t, i), s = Math.floor(Date.now() / 1e3), c = s + (a ?? this.config.ttl), l = {
|
|
566
566
|
content: n,
|
|
567
567
|
contentType: r,
|
|
568
|
-
etag:
|
|
568
|
+
etag: Ge(e, t, s, n.length),
|
|
569
569
|
lastModified: s,
|
|
570
570
|
expiresAt: c
|
|
571
571
|
};
|
|
@@ -603,7 +603,7 @@ var qe = class {
|
|
|
603
603
|
imageMetadataCount: this.imageMetadataCache.size
|
|
604
604
|
};
|
|
605
605
|
}
|
|
606
|
-
},
|
|
606
|
+
}, Xe = class {
|
|
607
607
|
cacheDir;
|
|
608
608
|
config;
|
|
609
609
|
constructor(e) {
|
|
@@ -613,30 +613,30 @@ var qe = class {
|
|
|
613
613
|
}
|
|
614
614
|
async ensureCacheDir() {
|
|
615
615
|
try {
|
|
616
|
-
await
|
|
616
|
+
await E.mkdir(this.cacheDir, { recursive: !0 });
|
|
617
617
|
} catch (e) {
|
|
618
618
|
if (e.code !== "EEXIST") throw e;
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
621
|
getFeedContentPath(e, t, n) {
|
|
622
|
-
let r =
|
|
623
|
-
return
|
|
622
|
+
let r = q(e, t, n).replace(/:/g, "-");
|
|
623
|
+
return D(this.cacheDir, `${r}.json`);
|
|
624
624
|
}
|
|
625
625
|
getImageMetadataPath(e) {
|
|
626
|
-
let t =
|
|
627
|
-
return
|
|
626
|
+
let t = D(this.cacheDir, "image-metadata");
|
|
627
|
+
return D(t, `${e}.json`);
|
|
628
628
|
}
|
|
629
629
|
async ensureImageMetadataDir() {
|
|
630
630
|
try {
|
|
631
|
-
let e =
|
|
632
|
-
await
|
|
631
|
+
let e = D(this.cacheDir, "image-metadata");
|
|
632
|
+
await E.mkdir(e, { recursive: !0 });
|
|
633
633
|
} catch (e) {
|
|
634
634
|
if (e.code !== "EEXIST") throw e;
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
637
|
async getFeedContent(e, t, n) {
|
|
638
638
|
try {
|
|
639
|
-
let r = this.getFeedContentPath(e, t, n), i = await
|
|
639
|
+
let r = this.getFeedContentPath(e, t, n), i = await E.readFile(r, "utf-8"), a = JSON.parse(i);
|
|
640
640
|
return Math.floor(Date.now() / 1e3) > a.expiresAt ? (await this.clearFeedContent(e, t, n), null) : a;
|
|
641
641
|
} catch (n) {
|
|
642
642
|
return n.code === "ENOENT" || console.error(`Error reading feed content cache for ${e}:${t}:`, n), null;
|
|
@@ -646,7 +646,7 @@ var qe = class {
|
|
|
646
646
|
try {
|
|
647
647
|
await this.ensureCacheDir();
|
|
648
648
|
let i = this.getFeedContentPath(e, t, r);
|
|
649
|
-
await
|
|
649
|
+
await E.writeFile(i, JSON.stringify(n, null, 2), "utf-8");
|
|
650
650
|
} catch (n) {
|
|
651
651
|
console.error(`Error writing feed content cache for ${e}:${t}:`, n);
|
|
652
652
|
}
|
|
@@ -654,22 +654,22 @@ var qe = class {
|
|
|
654
654
|
async clearFeedContent(e, t, n) {
|
|
655
655
|
try {
|
|
656
656
|
let r = this.getFeedContentPath(e, t, n);
|
|
657
|
-
await
|
|
657
|
+
await E.unlink(r);
|
|
658
658
|
} catch (n) {
|
|
659
659
|
n.code !== "ENOENT" && console.error(`Error clearing feed content cache for ${e}:${t}:`, n);
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
662
|
async clearAllContentCache(e) {
|
|
663
663
|
try {
|
|
664
|
-
let t = await
|
|
665
|
-
for (let r of t) r.startsWith(n) && r.endsWith(".json") && r !== `${e}.json` && await
|
|
664
|
+
let t = await E.readdir(this.cacheDir), n = `${e}-`;
|
|
665
|
+
for (let r of t) r.startsWith(n) && r.endsWith(".json") && r !== `${e}.json` && await E.unlink(D(this.cacheDir, r));
|
|
666
666
|
} catch (t) {
|
|
667
667
|
console.error(`Error clearing all content cache for ${e}:`, t);
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
670
|
async getImageMetadata(e) {
|
|
671
671
|
try {
|
|
672
|
-
let t = this.getImageMetadataPath(e), n = await
|
|
672
|
+
let t = this.getImageMetadataPath(e), n = await E.readFile(t, "utf-8"), r = JSON.parse(n);
|
|
673
673
|
return Math.floor(Date.now() / 1e3) > r.expiresAt ? (await this.clearImageMetadata(e), null) : r.metadata;
|
|
674
674
|
} catch (t) {
|
|
675
675
|
return t.code === "ENOENT" || console.error(`Error reading image metadata cache for ${e}:`, t), null;
|
|
@@ -683,7 +683,7 @@ var qe = class {
|
|
|
683
683
|
cachedAt: r,
|
|
684
684
|
expiresAt: r + (this.config.imageMetadata?.ttl || 604800)
|
|
685
685
|
};
|
|
686
|
-
await
|
|
686
|
+
await E.writeFile(n, JSON.stringify(i, null, 2), "utf-8");
|
|
687
687
|
} catch (t) {
|
|
688
688
|
console.error(`Error writing image metadata cache for ${e}:`, t);
|
|
689
689
|
}
|
|
@@ -691,25 +691,25 @@ var qe = class {
|
|
|
691
691
|
async clearImageMetadata(e) {
|
|
692
692
|
try {
|
|
693
693
|
let t = this.getImageMetadataPath(e);
|
|
694
|
-
await
|
|
694
|
+
await E.unlink(t);
|
|
695
695
|
} catch (t) {
|
|
696
696
|
t.code !== "ENOENT" && console.error(`Error clearing image metadata cache for ${e}:`, t);
|
|
697
697
|
}
|
|
698
698
|
}
|
|
699
699
|
async clearAll() {
|
|
700
700
|
try {
|
|
701
|
-
let e = await
|
|
702
|
-
for (let t of e) t.endsWith(".json") && t.includes("-") && await
|
|
703
|
-
let t =
|
|
701
|
+
let e = await E.readdir(this.cacheDir);
|
|
702
|
+
for (let t of e) t.endsWith(".json") && t.includes("-") && await E.unlink(D(this.cacheDir, t));
|
|
703
|
+
let t = D(this.cacheDir, "image-metadata");
|
|
704
704
|
try {
|
|
705
|
-
let e = await
|
|
706
|
-
for (let n of e) n.endsWith(".json") && await
|
|
705
|
+
let e = await E.readdir(t);
|
|
706
|
+
for (let n of e) n.endsWith(".json") && await E.unlink(D(t, n));
|
|
707
707
|
} catch {}
|
|
708
708
|
} catch (e) {
|
|
709
709
|
console.error("Error clearing all caches:", e);
|
|
710
710
|
}
|
|
711
711
|
}
|
|
712
|
-
},
|
|
712
|
+
}, Ze = class {
|
|
713
713
|
memoryCache;
|
|
714
714
|
fileCache;
|
|
715
715
|
config;
|
|
@@ -720,7 +720,7 @@ var qe = class {
|
|
|
720
720
|
errors: 0
|
|
721
721
|
};
|
|
722
722
|
constructor(e) {
|
|
723
|
-
this.config = e, this.memoryCache = new
|
|
723
|
+
this.config = e, this.memoryCache = new Ye(e), this.fileCache = new Xe(e);
|
|
724
724
|
}
|
|
725
725
|
async getFeedContent(e, t, n) {
|
|
726
726
|
if (!this.config.enabled) return null;
|
|
@@ -786,7 +786,7 @@ var qe = class {
|
|
|
786
786
|
};
|
|
787
787
|
//#endregion
|
|
788
788
|
//#region src/cache/config.ts
|
|
789
|
-
function
|
|
789
|
+
function J() {
|
|
790
790
|
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", s;
|
|
791
791
|
s = r ? !1 : i ? !0 : !a;
|
|
792
792
|
let c = process.env.CACHE_BACKGROUND_REFRESH === "true", l = parseInt(process.env.CACHE_REFRESH_INTERVAL || "300", 10);
|
|
@@ -794,7 +794,7 @@ function q() {
|
|
|
794
794
|
let u = {
|
|
795
795
|
enabled: process.env.IMAGE_METADATA_ENABLED !== "false",
|
|
796
796
|
ttl: parseInt(process.env.IMAGE_METADATA_TTL || "604800", 10),
|
|
797
|
-
gateways: process.env.IMAGE_METADATA_GATEWAYS ? process.env.IMAGE_METADATA_GATEWAYS.split(",").map((e) => e.trim()) : o(
|
|
797
|
+
gateways: process.env.IMAGE_METADATA_GATEWAYS ? process.env.IMAGE_METADATA_GATEWAYS.split(",").map((e) => e.trim()) : o(g() ?? e.getHost()),
|
|
798
798
|
timeout: parseInt(process.env.IMAGE_METADATA_TIMEOUT || "5000", 10)
|
|
799
799
|
}, d = parseInt(process.env.CACHE_PAGE_TTL || "300", 10), f = parseInt(process.env.CACHE_ARCHIVE_TTL || "86400", 10);
|
|
800
800
|
return {
|
|
@@ -810,7 +810,7 @@ function q() {
|
|
|
810
810
|
}
|
|
811
811
|
//#endregion
|
|
812
812
|
//#region src/services/arweaveImageService.ts
|
|
813
|
-
var
|
|
813
|
+
var Qe = class {
|
|
814
814
|
config;
|
|
815
815
|
constructor(e) {
|
|
816
816
|
this.config = e;
|
|
@@ -819,46 +819,57 @@ var Xe = class {
|
|
|
819
819
|
let n = u();
|
|
820
820
|
(!n || n.activePath !== "hyper-sidecar" && n.activePath !== "http-proxy") && await a().catch(() => {});
|
|
821
821
|
let r = n ? l(n, s()) : this.config.gateways?.length ? this.config.gateways : o(e.getHost()), i = n?.arweaveProtocol ?? "https";
|
|
822
|
-
for (let e of r)
|
|
823
|
-
let n =
|
|
824
|
-
if (
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
822
|
+
for (let e of r) {
|
|
823
|
+
let n = e.trim().replace(/\/$/, "");
|
|
824
|
+
if (n && !f(n)) try {
|
|
825
|
+
let e = `${i}://${n}/${t}`, r = await this.getImageMetadata(e, n);
|
|
826
|
+
if (r.isImage) return r;
|
|
827
|
+
} catch (r) {
|
|
828
|
+
m(n), console.warn(`Failed to fetch from gateway ${e} for transaction ${t}:`, r);
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
828
831
|
}
|
|
829
832
|
return {
|
|
830
833
|
isImage: !1,
|
|
831
834
|
url: `${i}://${r[0]?.trim() || e.getHost()}/${t}`
|
|
832
835
|
};
|
|
833
836
|
}
|
|
834
|
-
async getImageMetadata(e) {
|
|
837
|
+
async getImageMetadata(e, t) {
|
|
838
|
+
let n = t ?? (() => {
|
|
839
|
+
try {
|
|
840
|
+
return new URL(e).host;
|
|
841
|
+
} catch {
|
|
842
|
+
return e;
|
|
843
|
+
}
|
|
844
|
+
})();
|
|
835
845
|
try {
|
|
836
846
|
let t = await this.fetchWithTimeout(e, { method: "HEAD" });
|
|
837
847
|
if (!t.ok) return {
|
|
838
848
|
isImage: !1,
|
|
839
849
|
url: e
|
|
840
850
|
};
|
|
841
|
-
|
|
842
|
-
|
|
851
|
+
h(n);
|
|
852
|
+
let r = t.headers.get("content-type") || "", i = t.headers.get("content-length");
|
|
853
|
+
if (!this.isImageContentType(r)) return {
|
|
843
854
|
isImage: !1,
|
|
844
855
|
url: e,
|
|
845
|
-
mimeType:
|
|
846
|
-
size:
|
|
856
|
+
mimeType: r || void 0,
|
|
857
|
+
size: i ? parseInt(i, 10) : void 0
|
|
847
858
|
};
|
|
848
|
-
let
|
|
849
|
-
if (!
|
|
850
|
-
let
|
|
859
|
+
let a = await this.fetchWithTimeout(e, { headers: { Range: "bytes=0-8192" } });
|
|
860
|
+
if (!a.ok) return await this.getImageMetadataFromFullRequest(e, r, i);
|
|
861
|
+
let o = Buffer.from(await a.arrayBuffer()), s = this.extractImageDimensions(o, r), c = this.getImageFormat(r, o);
|
|
851
862
|
return {
|
|
852
863
|
isImage: !0,
|
|
853
864
|
url: e,
|
|
854
|
-
mimeType:
|
|
855
|
-
width:
|
|
856
|
-
height:
|
|
857
|
-
size:
|
|
858
|
-
format:
|
|
865
|
+
mimeType: r,
|
|
866
|
+
width: s.width,
|
|
867
|
+
height: s.height,
|
|
868
|
+
size: i ? parseInt(i, 10) : void 0,
|
|
869
|
+
format: c
|
|
859
870
|
};
|
|
860
871
|
} catch (t) {
|
|
861
|
-
return console.warn(`Error fetching image metadata from ${e}:`, t), {
|
|
872
|
+
return m(n), console.warn(`Error fetching image metadata from ${e}:`, t), {
|
|
862
873
|
isImage: !1,
|
|
863
874
|
url: e
|
|
864
875
|
};
|
|
@@ -893,7 +904,7 @@ var Xe = class {
|
|
|
893
904
|
}
|
|
894
905
|
extractImageDimensions(e, t) {
|
|
895
906
|
try {
|
|
896
|
-
let t =
|
|
907
|
+
let t = le(e);
|
|
897
908
|
if (t.width && t.height) return {
|
|
898
909
|
width: t.width,
|
|
899
910
|
height: t.height
|
|
@@ -915,7 +926,7 @@ var Xe = class {
|
|
|
915
926
|
}
|
|
916
927
|
}
|
|
917
928
|
try {
|
|
918
|
-
let e =
|
|
929
|
+
let e = le(t);
|
|
919
930
|
if (e.type) return e.type.toLowerCase();
|
|
920
931
|
} catch {}
|
|
921
932
|
}
|
|
@@ -934,28 +945,28 @@ var Xe = class {
|
|
|
934
945
|
};
|
|
935
946
|
//#endregion
|
|
936
947
|
//#region src/pickFeedItemRichText.ts
|
|
937
|
-
function
|
|
948
|
+
function Y(e, t) {
|
|
938
949
|
for (let n of t) {
|
|
939
950
|
let t = e[n];
|
|
940
951
|
if (typeof t == "string" && t.trim() !== "") return t;
|
|
941
952
|
}
|
|
942
953
|
return "";
|
|
943
954
|
}
|
|
944
|
-
var
|
|
955
|
+
var $e = [
|
|
945
956
|
"summary",
|
|
946
957
|
"Summary",
|
|
947
958
|
"description",
|
|
948
959
|
"Description",
|
|
949
960
|
"text",
|
|
950
961
|
"Text"
|
|
951
|
-
],
|
|
962
|
+
], et = [
|
|
952
963
|
"html",
|
|
953
964
|
"Html",
|
|
954
965
|
"body",
|
|
955
966
|
"Body",
|
|
956
967
|
"content",
|
|
957
968
|
"Content"
|
|
958
|
-
],
|
|
969
|
+
], tt = [
|
|
959
970
|
"summary",
|
|
960
971
|
"Summary",
|
|
961
972
|
"description",
|
|
@@ -963,16 +974,16 @@ var Ze = [
|
|
|
963
974
|
"text",
|
|
964
975
|
"Text"
|
|
965
976
|
];
|
|
966
|
-
function
|
|
967
|
-
let n =
|
|
977
|
+
function nt(e, t) {
|
|
978
|
+
let n = x(e.model) - x(t.model);
|
|
968
979
|
if (n !== 0) return n;
|
|
969
980
|
let r = e.key.localeCompare(t.key);
|
|
970
981
|
return r === 0 ? e.index - t.index : r;
|
|
971
982
|
}
|
|
972
|
-
function
|
|
973
|
-
let t =
|
|
983
|
+
function rt(e) {
|
|
984
|
+
let t = te(e), n = C(e), r = null;
|
|
974
985
|
if (t) for (let [n, i] of Object.entries(t)) {
|
|
975
|
-
if (!
|
|
986
|
+
if (!w(i)) continue;
|
|
976
987
|
let t = e[n];
|
|
977
988
|
if (typeof t != "string" || t.trim() === "") continue;
|
|
978
989
|
let a = {
|
|
@@ -981,7 +992,7 @@ function tt(e) {
|
|
|
981
992
|
index: 0,
|
|
982
993
|
value: t
|
|
983
994
|
};
|
|
984
|
-
(!r ||
|
|
995
|
+
(!r || nt(a, r) < 0) && (r = a);
|
|
985
996
|
}
|
|
986
997
|
if (n) for (let [t, i] of Object.entries(n)) {
|
|
987
998
|
let n = e[t];
|
|
@@ -989,7 +1000,7 @@ function tt(e) {
|
|
|
989
1000
|
let a = Math.min(i.length, n.length);
|
|
990
1001
|
for (let e = 0; e < a; e++) {
|
|
991
1002
|
let a = i[e];
|
|
992
|
-
if (!
|
|
1003
|
+
if (!w(a)) continue;
|
|
993
1004
|
let o = n[e];
|
|
994
1005
|
if (typeof o != "string" || o.trim() === "") continue;
|
|
995
1006
|
let s = {
|
|
@@ -998,50 +1009,50 @@ function tt(e) {
|
|
|
998
1009
|
index: e,
|
|
999
1010
|
value: o
|
|
1000
1011
|
};
|
|
1001
|
-
(!r ||
|
|
1012
|
+
(!r || nt(s, r) < 0) && (r = s);
|
|
1002
1013
|
}
|
|
1003
1014
|
}
|
|
1004
1015
|
return r?.value ?? "";
|
|
1005
1016
|
}
|
|
1006
|
-
function
|
|
1007
|
-
return
|
|
1017
|
+
function it(e) {
|
|
1018
|
+
return Y(e, $e);
|
|
1008
1019
|
}
|
|
1009
|
-
function
|
|
1010
|
-
let t =
|
|
1020
|
+
function at(e) {
|
|
1021
|
+
let t = rt(e);
|
|
1011
1022
|
if (t !== "") return t;
|
|
1012
|
-
let n =
|
|
1013
|
-
return n === "" ?
|
|
1023
|
+
let n = Y(e, et);
|
|
1024
|
+
return n === "" ? Y(e, tt) : n;
|
|
1014
1025
|
}
|
|
1015
|
-
function
|
|
1026
|
+
function X(e) {
|
|
1016
1027
|
return typeof e == "string" && e.includes("data:image/") && e.includes(";base64,");
|
|
1017
1028
|
}
|
|
1018
|
-
function
|
|
1019
|
-
let t =
|
|
1029
|
+
function ot(e) {
|
|
1030
|
+
let t = te(e);
|
|
1020
1031
|
if (t) {
|
|
1021
|
-
for (let [n, r] of Object.entries(t)) if (
|
|
1032
|
+
for (let [n, r] of Object.entries(t)) if (w(r) && X(e[n])) return !0;
|
|
1022
1033
|
}
|
|
1023
|
-
let n =
|
|
1034
|
+
let n = C(e);
|
|
1024
1035
|
if (n) for (let [t, r] of Object.entries(n)) {
|
|
1025
1036
|
let n = e[t];
|
|
1026
1037
|
if (!Array.isArray(n)) continue;
|
|
1027
1038
|
let i = Math.min(r.length, n.length);
|
|
1028
|
-
for (let e = 0; e < i; e++) if (
|
|
1039
|
+
for (let e = 0; e < i; e++) if (w(r[e]) && X(n[e])) return !0;
|
|
1029
1040
|
}
|
|
1030
1041
|
return !1;
|
|
1031
1042
|
}
|
|
1032
|
-
function
|
|
1033
|
-
if (
|
|
1034
|
-
for (let t of
|
|
1035
|
-
for (let t of
|
|
1043
|
+
function st(e) {
|
|
1044
|
+
if (ot(e)) return !0;
|
|
1045
|
+
for (let t of et) if (X(e[t])) return !0;
|
|
1046
|
+
for (let t of $e) if (X(e[t])) return !0;
|
|
1036
1047
|
return !1;
|
|
1037
1048
|
}
|
|
1038
|
-
function
|
|
1039
|
-
return t === "include_items" ? [...e] : e.filter((e) => !
|
|
1049
|
+
function ct(e, t = "omit_items") {
|
|
1050
|
+
return t === "include_items" ? [...e] : e.filter((e) => !st(e));
|
|
1040
1051
|
}
|
|
1041
1052
|
//#endregion
|
|
1042
1053
|
//#region src/index.ts
|
|
1043
|
-
function
|
|
1044
|
-
return
|
|
1054
|
+
function lt(e) {
|
|
1055
|
+
return y(e)?.mediaUrl;
|
|
1045
1056
|
}
|
|
1046
1057
|
function Z(e) {
|
|
1047
1058
|
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e;
|
|
@@ -1050,15 +1061,15 @@ function Z(e) {
|
|
|
1050
1061
|
if (Number.isFinite(t) && t > 0) return t;
|
|
1051
1062
|
}
|
|
1052
1063
|
}
|
|
1053
|
-
function
|
|
1064
|
+
function ut(e) {
|
|
1054
1065
|
if (Array.isArray(e)) {
|
|
1055
1066
|
for (let t of e) {
|
|
1056
|
-
let e =
|
|
1067
|
+
let e = ut(t);
|
|
1057
1068
|
if (e) return e;
|
|
1058
1069
|
}
|
|
1059
1070
|
return;
|
|
1060
1071
|
}
|
|
1061
|
-
let t =
|
|
1072
|
+
let t = lt(e);
|
|
1062
1073
|
if (t) {
|
|
1063
1074
|
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
1064
1075
|
let n = e;
|
|
@@ -1074,7 +1085,7 @@ function st(e) {
|
|
|
1074
1085
|
return { url: t };
|
|
1075
1086
|
}
|
|
1076
1087
|
}
|
|
1077
|
-
function
|
|
1088
|
+
function dt(e) {
|
|
1078
1089
|
if (e._hasImage && e._imageMetadata && typeof e._imageMetadata == "object") {
|
|
1079
1090
|
let t = e._imageMetadata;
|
|
1080
1091
|
if (t.url) return {
|
|
@@ -1098,11 +1109,11 @@ function ct(e) {
|
|
|
1098
1109
|
"thumbnailImage"
|
|
1099
1110
|
]) {
|
|
1100
1111
|
if (!(t in e)) continue;
|
|
1101
|
-
let n =
|
|
1112
|
+
let n = ut(e[t]);
|
|
1102
1113
|
if (n) return n;
|
|
1103
1114
|
}
|
|
1104
1115
|
}
|
|
1105
|
-
function
|
|
1116
|
+
function ft(e, t, n, r, i, a) {
|
|
1106
1117
|
let o = n.mimeType || "image/jpeg";
|
|
1107
1118
|
e.enclosures = [{
|
|
1108
1119
|
url: n.url,
|
|
@@ -1139,13 +1150,13 @@ function lt(e, t, n, r, i, a) {
|
|
|
1139
1150
|
}], 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}`);
|
|
1140
1151
|
}
|
|
1141
1152
|
var Q = null;
|
|
1142
|
-
function
|
|
1143
|
-
return Q ||= new
|
|
1153
|
+
function pt() {
|
|
1154
|
+
return Q ||= new Ze(J()), Q;
|
|
1144
1155
|
}
|
|
1145
|
-
function
|
|
1156
|
+
function mt() {
|
|
1146
1157
|
Q = null;
|
|
1147
1158
|
}
|
|
1148
|
-
async function
|
|
1159
|
+
async function ht(e, t, n) {
|
|
1149
1160
|
let r = e.filter((e) => e.storageTransactionId || e.storage_transaction_id);
|
|
1150
1161
|
if (r.length === 0) return e;
|
|
1151
1162
|
console.log(`Enriching ${r.length} items with image metadata`);
|
|
@@ -1167,10 +1178,10 @@ async function ft(e, t, n) {
|
|
|
1167
1178
|
return o.get(t) || e;
|
|
1168
1179
|
});
|
|
1169
1180
|
}
|
|
1170
|
-
function
|
|
1181
|
+
function gt(e, t) {
|
|
1171
1182
|
let { schemaName: n, siteUrl: r, itemUrlBase: i, itemUrlPath: a, richTextDataUriImages: o = "omit_items" } = t;
|
|
1172
|
-
return
|
|
1173
|
-
let t = e.id || e.seedUid || e.SeedUid || e.storageTransactionId || e.storage_transaction_id, o = i == null ? `${r}/${
|
|
1183
|
+
return ct(e, o).map((e) => {
|
|
1184
|
+
let t = e.id || e.seedUid || e.SeedUid || e.storageTransactionId || e.storage_transaction_id, o = i == null ? `${r}/${T(n)}/${t}` : `${i.replace(/\/$/, "")}/${(a ?? "attestation/view").replace(/^\//, "")}/${t}`, s = e.link || e.Link || e.import_url || e.importUrl || o, c;
|
|
1174
1185
|
if (e.pubDate || e.PubDate) {
|
|
1175
1186
|
let t = e.pubDate || e.PubDate;
|
|
1176
1187
|
c = new Date(t);
|
|
@@ -1179,7 +1190,7 @@ function pt(e, t) {
|
|
|
1179
1190
|
let t = e.publishedAt || e.createdAt || e.updatedAt;
|
|
1180
1191
|
c = t && typeof t == "object" && t.constructor === Date ? t : new Date(t);
|
|
1181
1192
|
} else c = /* @__PURE__ */ new Date();
|
|
1182
|
-
let l =
|
|
1193
|
+
let l = it(e), u = at(e), d = {
|
|
1183
1194
|
...e,
|
|
1184
1195
|
id: t,
|
|
1185
1196
|
title: e.title || e.Title || "Untitled",
|
|
@@ -1200,7 +1211,7 @@ function pt(e, t) {
|
|
|
1200
1211
|
});
|
|
1201
1212
|
}
|
|
1202
1213
|
var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
1203
|
-
let l =
|
|
1214
|
+
let l = N(c), u = T(t), d = `${l.feedUrl}/${u}/${n}`, f = r ? `${d}?v=${r}` : d, p = `${l.title} - ${yt(u)}`, m = /* @__PURE__ */ new Date(), h = P(), g = [];
|
|
1204
1215
|
if (i) {
|
|
1205
1216
|
let e = i.baseUrl.replace(/\?.*$/, ""), t = e.includes("?") ? "&" : "?";
|
|
1206
1217
|
i.hasNext && g.push({
|
|
@@ -1218,7 +1229,7 @@ var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1218
1229
|
rel: e.rel,
|
|
1219
1230
|
href: e.href
|
|
1220
1231
|
});
|
|
1221
|
-
let _ =
|
|
1232
|
+
let _ = gt(e, {
|
|
1222
1233
|
schemaName: t,
|
|
1223
1234
|
siteUrl: l.siteUrl,
|
|
1224
1235
|
itemUrlBase: h.itemUrlBase,
|
|
@@ -1274,7 +1285,7 @@ var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1274
1285
|
return t;
|
|
1275
1286
|
})
|
|
1276
1287
|
};
|
|
1277
|
-
return Promise.resolve(
|
|
1288
|
+
return Promise.resolve(ae(t));
|
|
1278
1289
|
}
|
|
1279
1290
|
case "json": {
|
|
1280
1291
|
let e = i?.hasNext ? `${i.baseUrl.replace(/\?.*$/, "")}?page=${i.page + 1}` : void 0, t = {
|
|
@@ -1303,7 +1314,7 @@ var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1303
1314
|
}
|
|
1304
1315
|
return t;
|
|
1305
1316
|
})
|
|
1306
|
-
}, n =
|
|
1317
|
+
}, n = oe(t);
|
|
1307
1318
|
return Promise.resolve(typeof n == "string" ? n : JSON.stringify(n));
|
|
1308
1319
|
}
|
|
1309
1320
|
default: {
|
|
@@ -1331,26 +1342,26 @@ var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1331
1342
|
value: e.id,
|
|
1332
1343
|
isPermaLink: typeof e.id == "string" && (e.id.startsWith("http://") || e.id.startsWith("https://"))
|
|
1333
1344
|
});
|
|
1334
|
-
let r =
|
|
1335
|
-
if (r &&
|
|
1345
|
+
let r = dt(e);
|
|
1346
|
+
if (r && ft(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) {
|
|
1336
1347
|
let t = /* @__PURE__ */ new Date(e.timeCreated * 1e3);
|
|
1337
1348
|
n.dc.dates || (n.dc.dates = []), n.dc.dates.push(t);
|
|
1338
1349
|
}
|
|
1339
1350
|
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;
|
|
1340
1351
|
})
|
|
1341
1352
|
};
|
|
1342
|
-
return Promise.resolve(
|
|
1353
|
+
return Promise.resolve(Ue(e));
|
|
1343
1354
|
}
|
|
1344
1355
|
}
|
|
1345
1356
|
};
|
|
1346
|
-
function
|
|
1357
|
+
function _t(e) {
|
|
1347
1358
|
switch (e) {
|
|
1348
1359
|
case "atom": return "application/atom+xml; charset=utf-8";
|
|
1349
1360
|
case "json": return "application/feed+json; charset=utf-8";
|
|
1350
1361
|
default: return "application/rss+xml; charset=utf-8";
|
|
1351
1362
|
}
|
|
1352
1363
|
}
|
|
1353
|
-
function
|
|
1364
|
+
function vt(e) {
|
|
1354
1365
|
let t = e.toLowerCase();
|
|
1355
1366
|
return [
|
|
1356
1367
|
"rss",
|
|
@@ -1358,22 +1369,22 @@ function ht(e) {
|
|
|
1358
1369
|
"json"
|
|
1359
1370
|
].includes(t) ? t : null;
|
|
1360
1371
|
}
|
|
1361
|
-
function
|
|
1372
|
+
function yt(e) {
|
|
1362
1373
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1363
1374
|
}
|
|
1364
|
-
async function
|
|
1365
|
-
let o =
|
|
1375
|
+
async function bt(e, t, n, r, i, a) {
|
|
1376
|
+
let o = vt(t);
|
|
1366
1377
|
if (!o) return new Response(JSON.stringify({ error: `Invalid feed format: ${t}` }), {
|
|
1367
1378
|
status: 400,
|
|
1368
1379
|
headers: { "Content-Type": "application/json" }
|
|
1369
1380
|
});
|
|
1370
|
-
let s =
|
|
1381
|
+
let s = T.singular(e.toLowerCase()), c = T(s), l = N(a), u = P(), d = Math.max(1, i ?? 1), f = u.pageSize, p = (d - 1) * f, m = d > 1 ? { page: d } : void 0;
|
|
1371
1382
|
console.log(`Schema name: ${s}`), console.log(`Collection name: ${c}`);
|
|
1372
|
-
let h =
|
|
1383
|
+
let h = pt(), g = J();
|
|
1373
1384
|
try {
|
|
1374
1385
|
if (g.enabled) {
|
|
1375
1386
|
let e = await h.getFeedContent(s, o, m);
|
|
1376
|
-
if (e) return n &&
|
|
1387
|
+
if (e) return n && Je(n, e.etag) ? (console.log(`Cache hit with ETag match for ${s}:${o} - returning 304`), new Response(null, {
|
|
1377
1388
|
status: 304,
|
|
1378
1389
|
headers: {
|
|
1379
1390
|
ETag: e.etag,
|
|
@@ -1395,11 +1406,11 @@ async function _t(e, t, n, r, i, a) {
|
|
|
1395
1406
|
}
|
|
1396
1407
|
console.log(`Cache miss for ${s}:${o} - fetching items`);
|
|
1397
1408
|
let e = await (async () => {
|
|
1398
|
-
let e = await
|
|
1409
|
+
let e = await Se(s, {
|
|
1399
1410
|
limit: f,
|
|
1400
1411
|
skip: p
|
|
1401
1412
|
});
|
|
1402
|
-
return console.log(`Found ${e.length} feed items for schema ${s}`), g.imageMetadata?.enabled ?
|
|
1413
|
+
return console.log(`Found ${e.length} feed items for schema ${s}`), g.imageMetadata?.enabled ? ht(e, new Qe({
|
|
1403
1414
|
gateways: g.imageMetadata.gateways,
|
|
1404
1415
|
timeout: g.imageMetadata.timeout
|
|
1405
1416
|
}), h) : e;
|
|
@@ -1416,7 +1427,7 @@ async function _t(e, t, n, r, i, a) {
|
|
|
1416
1427
|
pageSize: f,
|
|
1417
1428
|
hasNext: i,
|
|
1418
1429
|
baseUrl: t
|
|
1419
|
-
}, u.length ? u : void 0, !1, void 0, a), v =
|
|
1430
|
+
}, u.length ? u : void 0, !1, void 0, a), v = _t(o);
|
|
1420
1431
|
if (g.enabled) {
|
|
1421
1432
|
await h.setFeedContent(s, o, _, v, m);
|
|
1422
1433
|
let e = await h.getFeedContent(s, o, m), t = e?.etag || "", n = e?.lastModified || Math.floor(Date.now() / 1e3);
|
|
@@ -1467,7 +1478,7 @@ async function _t(e, t, n, r, i, a) {
|
|
|
1467
1478
|
});
|
|
1468
1479
|
}
|
|
1469
1480
|
}
|
|
1470
|
-
async function
|
|
1481
|
+
async function xt(e, t, n, r, i, a, o) {
|
|
1471
1482
|
if (t < 1970 || t > 2100) return new Response(JSON.stringify({ error: `Invalid year: ${t}` }), {
|
|
1472
1483
|
status: 400,
|
|
1473
1484
|
headers: { "Content-Type": "application/json" }
|
|
@@ -1476,19 +1487,19 @@ async function vt(e, t, n, r, i, a, o) {
|
|
|
1476
1487
|
status: 400,
|
|
1477
1488
|
headers: { "Content-Type": "application/json" }
|
|
1478
1489
|
});
|
|
1479
|
-
let s =
|
|
1490
|
+
let s = vt(r);
|
|
1480
1491
|
if (!s) return new Response(JSON.stringify({ error: `Invalid feed format: ${r}` }), {
|
|
1481
1492
|
status: 400,
|
|
1482
1493
|
headers: { "Content-Type": "application/json" }
|
|
1483
1494
|
});
|
|
1484
|
-
let c =
|
|
1495
|
+
let c = T.singular(e.toLowerCase()), l = T(c), u = N(o), d = { archive: {
|
|
1485
1496
|
year: t,
|
|
1486
1497
|
month: n
|
|
1487
|
-
} }, f =
|
|
1498
|
+
} }, f = pt(), p = J();
|
|
1488
1499
|
try {
|
|
1489
1500
|
if (p.enabled) {
|
|
1490
1501
|
let e = await f.getFeedContent(c, s, d);
|
|
1491
|
-
if (e) return i &&
|
|
1502
|
+
if (e) return i && Je(i, e.etag) ? new Response(null, {
|
|
1492
1503
|
status: 304,
|
|
1493
1504
|
headers: {
|
|
1494
1505
|
ETag: e.etag,
|
|
@@ -1508,7 +1519,7 @@ async function vt(e, t, n, r, i, a, o) {
|
|
|
1508
1519
|
}
|
|
1509
1520
|
});
|
|
1510
1521
|
}
|
|
1511
|
-
let e = await
|
|
1522
|
+
let e = await Ce(c, t, n), r = `${u.feedUrl}/${l}/${s}`, m = `${u.feedUrl}/${l}/archive`, h = [{
|
|
1512
1523
|
rel: "prev-archive",
|
|
1513
1524
|
href: `${m}/${n === 1 ? t - 1 : t}/${n === 1 ? 12 : n - 1}/${s}`
|
|
1514
1525
|
}, {
|
|
@@ -1519,7 +1530,7 @@ async function vt(e, t, n, r, i, a, o) {
|
|
|
1519
1530
|
rel: "next-archive",
|
|
1520
1531
|
href: `${m}/${g}/${_}/${s}`
|
|
1521
1532
|
});
|
|
1522
|
-
let y = await $(e, c, s, a, void 0, h, !0, void 0, o), b =
|
|
1533
|
+
let y = await $(e, c, s, a, void 0, h, !0, void 0, o), b = _t(s);
|
|
1523
1534
|
if (p.enabled) {
|
|
1524
1535
|
await f.setFeedContent(c, s, y, b, d);
|
|
1525
1536
|
let e = await f.getFeedContent(c, s, d), t = e?.etag || "", n = e?.lastModified || Math.floor(Date.now() / 1e3);
|
|
@@ -1556,6 +1567,6 @@ async function vt(e, t, n, r, i, a, o) {
|
|
|
1556
1567
|
}
|
|
1557
1568
|
}
|
|
1558
1569
|
//#endregion
|
|
1559
|
-
export { t as DEFAULT_ARWEAVE_HOST,
|
|
1570
|
+
export { t as DEFAULT_ARWEAVE_HOST, A as DEFAULT_SITE_CONFIG, b as FEED_RICH_BODY_STORAGE_SCHEMAS, r as SEED_RSS_IMAGE_RELATION_FIELD_KEYS, i as classifyMediaRef, $ as createFeed, ee as enrichImageSeedCloneForFeed, st as feedItemRichTextContainsDataUriImage, ct as filterItemsByRichTextDataUriImagePolicy, fe as getClient, c as getFeedItemStringField, Se as getFeedItemsBySchemaName, Ce as getFeedItemsBySchemaNameForMonth, me as getSiteConfig, xt as handleArchiveFeedRequest, bt as handleFeedRequest, k as initializeFeedPlatform, de as initializeSeedClient, d as isEasAttestationExplorerUrl, w as isFeedRichBodyStorageSchema, P as loadFeedConfig, p as normalizeFeedItemFields, Ee as parseRssString, at as pickFeedItemContent, it as pickFeedItemDescription, mt as resetCacheManager, ge as resetSiteConfig, _ as resolveSeedRssImageRelationFromItem, v as resolveSeedRssImageRelationRef, N as resolveSiteConfig, he as setSiteConfig, pe as teardownSeedClient };
|
|
1560
1571
|
|
|
1561
1572
|
//# sourceMappingURL=index.js.map
|