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