@seedprotocol/feed 0.6.7 → 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 +196 -199
- package/dist/index.js.map +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 ie 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
|
-
}
|
|
25
|
-
var de = k;
|
|
26
|
-
async function fe() {
|
|
27
|
-
return await k(), { isInitialized: () => O };
|
|
24
|
+
D = !0;
|
|
28
25
|
}
|
|
26
|
+
var fe = O;
|
|
29
27
|
async function pe() {
|
|
30
|
-
O
|
|
28
|
+
return await O(), { isInitialized: () => D };
|
|
29
|
+
}
|
|
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 A = {
|
|
|
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 N(e, t = M) {
|
|
|
64
65
|
name: e.author.name ?? n.author?.name ?? ""
|
|
65
66
|
}), n;
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
-
return j
|
|
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 P() {
|
|
|
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 F = (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 F = (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,17 +227,17 @@ 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
|
-
var
|
|
240
|
+
var B = [
|
|
240
241
|
"title",
|
|
241
242
|
"link",
|
|
242
243
|
"description",
|
|
@@ -260,7 +261,7 @@ var V = [
|
|
|
260
261
|
"media:category",
|
|
261
262
|
"media:group"
|
|
262
263
|
];
|
|
263
|
-
function
|
|
264
|
+
function V(e) {
|
|
264
265
|
if (e instanceof Date) return e.toUTCString();
|
|
265
266
|
if (typeof e == "string") {
|
|
266
267
|
let t = new Date(e);
|
|
@@ -268,13 +269,13 @@ function H(e) {
|
|
|
268
269
|
}
|
|
269
270
|
return String(e);
|
|
270
271
|
}
|
|
271
|
-
function
|
|
272
|
+
function Me(e) {
|
|
272
273
|
return /[<>&]|]]>/.test(e);
|
|
273
274
|
}
|
|
274
|
-
function
|
|
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("]]>");
|
|
@@ -282,11 +283,11 @@ function U(e, t) {
|
|
|
282
283
|
} else e.txt(n);
|
|
283
284
|
}
|
|
284
285
|
}
|
|
285
|
-
function
|
|
286
|
+
function U(e) {
|
|
286
287
|
return typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof Date);
|
|
287
288
|
}
|
|
288
|
-
var
|
|
289
|
-
...
|
|
289
|
+
var Ne = 4, Pe = /* @__PURE__ */ new Set([
|
|
290
|
+
...B,
|
|
290
291
|
"guid",
|
|
291
292
|
"source",
|
|
292
293
|
"dc",
|
|
@@ -294,70 +295,70 @@ var Me = 4, Ne = /* @__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 Le(e) {
|
|
313
|
-
return Array.isArray(e) && e.length > 0 && e.every((e) => W(e));
|
|
314
|
-
}
|
|
315
313
|
function Re(e) {
|
|
316
|
-
|
|
314
|
+
return Array.isArray(e) && e.length > 0 && e.every((e) => U(e));
|
|
315
|
+
}
|
|
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" &&
|
|
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: Ie(
|
|
324
|
-
uri: `${
|
|
324
|
+
prefix: Le(Ie(e), n),
|
|
325
|
+
uri: `${ke}/${e}/1.0`
|
|
325
326
|
});
|
|
326
327
|
return t;
|
|
327
328
|
}
|
|
328
|
-
function
|
|
329
|
+
function W(e, t) {
|
|
329
330
|
if (e in t) return t[e];
|
|
330
331
|
if (e.endsWith("s") && e.length > 1) {
|
|
331
332
|
let n = e.slice(0, -1);
|
|
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
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 >=
|
|
344
|
-
|
|
343
|
+
let t = G(e, a);
|
|
344
|
+
if (i >= Ne) {
|
|
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 && (
|
|
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
|
-
if (
|
|
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
364
|
function Be(e, t, n, r, i) {
|
|
@@ -366,7 +367,7 @@ function Be(e, t, n, r, i) {
|
|
|
366
367
|
let t = n, r = t?.value ?? String(n);
|
|
367
368
|
if (!r) return;
|
|
368
369
|
let i = {};
|
|
369
|
-
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"),
|
|
370
|
+
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"), H(e.ele("guid", i), r);
|
|
370
371
|
return;
|
|
371
372
|
}
|
|
372
373
|
if (t === "source" && typeof n == "object" && n) {
|
|
@@ -391,36 +392,36 @@ function Be(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
|
-
t instanceof Date ? r.txt(t.toISOString()) :
|
|
395
|
+
let r = e.ele(I, n);
|
|
396
|
+
t instanceof Date ? r.txt(t.toISOString()) : H(r, String(t));
|
|
396
397
|
}
|
|
397
398
|
} else {
|
|
398
|
-
let t = e.ele(
|
|
399
|
-
r instanceof Date ? t.txt(r.toISOString()) :
|
|
399
|
+
let t = e.ele(I, n);
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ?
|
|
421
|
+
let r = n.ele(R, t);
|
|
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" &&
|
|
424
|
+
} else typeof r == "string" && H(n.ele(R, t), r);
|
|
424
425
|
}
|
|
425
426
|
}
|
|
426
427
|
return;
|
|
@@ -431,27 +432,27 @@ function Be(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
|
-
i !== null &&
|
|
435
|
+
let a = e.ele(R, r, n);
|
|
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
|
-
|
|
442
|
+
H(e.ele(R, r), n);
|
|
442
443
|
return;
|
|
443
444
|
}
|
|
444
445
|
if (n instanceof Date) {
|
|
445
|
-
e.ele(t).txt(
|
|
446
|
+
e.ele(t).txt(V(n));
|
|
446
447
|
return;
|
|
447
448
|
}
|
|
448
|
-
if (t === "author" &&
|
|
449
|
-
K(e, n, "author", !0, 0,
|
|
449
|
+
if (t === "author" && U(n)) {
|
|
450
|
+
K(e, n, "author", !0, 0, W(t, i));
|
|
450
451
|
return;
|
|
451
452
|
}
|
|
452
453
|
if (t === "authors" && Array.isArray(n)) {
|
|
453
|
-
let r =
|
|
454
|
-
for (let t of n) if (t &&
|
|
454
|
+
let r = W(t, i);
|
|
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);
|
|
@@ -468,33 +469,33 @@ function Be(e, t, n, r, i) {
|
|
|
468
469
|
}
|
|
469
470
|
return;
|
|
470
471
|
}
|
|
471
|
-
if (Array.isArray(n) && n.length > 0 && n.every((e) =>
|
|
472
|
-
let r = t.endsWith("s") ? t.slice(0, -1) : t, a =
|
|
472
|
+
if (Array.isArray(n) && n.length > 0 && n.every((e) => U(e))) {
|
|
473
|
+
let r = t.endsWith("s") ? t.slice(0, -1) : t, a = W(t, i);
|
|
473
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")) {
|
|
477
478
|
let r = t.endsWith("s") ? t.slice(0, -1) : t;
|
|
478
|
-
for (let t of n) t &&
|
|
479
|
+
for (let t of n) t && H(e.ele(r), t);
|
|
479
480
|
return;
|
|
480
481
|
}
|
|
481
|
-
if (
|
|
482
|
-
K(e, n, t, !1, 0,
|
|
482
|
+
if (U(n)) {
|
|
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
490
|
var Ve = "http://www.w3.org/2005/Atom", He = "http://purl.org/syndication/history/1.0";
|
|
490
491
|
function Ue(e) {
|
|
491
|
-
let t =
|
|
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":
|
|
495
|
+
}), n = ze(e.items), r = {
|
|
496
|
+
"xmlns:dc": I,
|
|
497
|
+
"xmlns:content": L,
|
|
498
|
+
"xmlns:media": R,
|
|
498
499
|
"xmlns:atom": Ve,
|
|
499
500
|
...Object.values(n).reduce((e, t) => (e[`xmlns:${t.prefix}`] = t.uri, e), {})
|
|
500
501
|
};
|
|
@@ -503,11 +504,11 @@ function Ue(e) {
|
|
|
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
|
-
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(
|
|
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
|
|
@@ -515,11 +516,11 @@ function Ue(e) {
|
|
|
515
516
|
t.type && (e.type = t.type), i.ele(Ve, "link", e);
|
|
516
517
|
}
|
|
517
518
|
e.isArchive && i.ele(He, "archive");
|
|
518
|
-
let a = new Set(
|
|
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
|
|
522
|
-
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !
|
|
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();
|
|
523
524
|
for (let r of o) Be(e, r, t[r], t, n);
|
|
524
525
|
}
|
|
525
526
|
return t.end({ prettyPrint: !0 });
|
|
@@ -532,7 +533,7 @@ function q(e, t, n) {
|
|
|
532
533
|
//#endregion
|
|
533
534
|
//#region src/utils/etag.ts
|
|
534
535
|
function We(e) {
|
|
535
|
-
return `"${
|
|
536
|
+
return `"${le("md5").update(e).digest("hex").substring(0, 16)}"`;
|
|
536
537
|
}
|
|
537
538
|
function Ge(e, t, n, r) {
|
|
538
539
|
return We(`${e}-${t}-${n}-${r}`);
|
|
@@ -613,30 +614,30 @@ var Ye = 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
623
|
let r = q(e, t, n).replace(/:/g, "-");
|
|
623
|
-
return
|
|
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 Ye = 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 Ye = 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 Ye = 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,19 +692,19 @@ var Ye = 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);
|
|
@@ -787,20 +788,20 @@ var Ye = class {
|
|
|
787
788
|
//#endregion
|
|
788
789
|
//#region src/cache/config.ts
|
|
789
790
|
function J() {
|
|
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
|
-
|
|
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,
|
|
@@ -816,22 +817,18 @@ var Qe = class {
|
|
|
816
817
|
this.config = e;
|
|
817
818
|
}
|
|
818
819
|
async detectImage(t) {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
let
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
} catch (r) {
|
|
828
|
-
m(n), console.warn(`Failed to fetch from gateway ${e} for transaction ${t}:`, r);
|
|
829
|
-
continue;
|
|
830
|
-
}
|
|
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
|
+
if (r.isImage) return r;
|
|
825
|
+
} catch (n) {
|
|
826
|
+
f(e), console.warn(`Failed to fetch from gateway ${e} for transaction ${t}:`, n);
|
|
827
|
+
continue;
|
|
831
828
|
}
|
|
832
829
|
return {
|
|
833
830
|
isImage: !1,
|
|
834
|
-
url: `${
|
|
831
|
+
url: `${n[0] ?? e.getBaseUrl()}/${t}`
|
|
835
832
|
};
|
|
836
833
|
}
|
|
837
834
|
async getImageMetadata(e, t) {
|
|
@@ -848,7 +845,7 @@ var Qe = class {
|
|
|
848
845
|
isImage: !1,
|
|
849
846
|
url: e
|
|
850
847
|
};
|
|
851
|
-
|
|
848
|
+
p(n);
|
|
852
849
|
let r = t.headers.get("content-type") || "", i = t.headers.get("content-length");
|
|
853
850
|
if (!this.isImageContentType(r)) return {
|
|
854
851
|
isImage: !1,
|
|
@@ -869,7 +866,7 @@ var Qe = class {
|
|
|
869
866
|
format: c
|
|
870
867
|
};
|
|
871
868
|
} catch (t) {
|
|
872
|
-
return
|
|
869
|
+
return f(n), console.warn(`Error fetching image metadata from ${e}:`, t), {
|
|
873
870
|
isImage: !1,
|
|
874
871
|
url: e
|
|
875
872
|
};
|
|
@@ -904,7 +901,7 @@ var Qe = class {
|
|
|
904
901
|
}
|
|
905
902
|
extractImageDimensions(e, t) {
|
|
906
903
|
try {
|
|
907
|
-
let t =
|
|
904
|
+
let t = ue(e);
|
|
908
905
|
if (t.width && t.height) return {
|
|
909
906
|
width: t.width,
|
|
910
907
|
height: t.height
|
|
@@ -926,7 +923,7 @@ var Qe = class {
|
|
|
926
923
|
}
|
|
927
924
|
}
|
|
928
925
|
try {
|
|
929
|
-
let e =
|
|
926
|
+
let e = ue(t);
|
|
930
927
|
if (e.type) return e.type.toLowerCase();
|
|
931
928
|
} catch {}
|
|
932
929
|
}
|
|
@@ -975,15 +972,15 @@ var $e = [
|
|
|
975
972
|
"Text"
|
|
976
973
|
];
|
|
977
974
|
function nt(e, t) {
|
|
978
|
-
let n =
|
|
975
|
+
let n = b(e.model) - b(t.model);
|
|
979
976
|
if (n !== 0) return n;
|
|
980
977
|
let r = e.key.localeCompare(t.key);
|
|
981
978
|
return r === 0 ? e.index - t.index : r;
|
|
982
979
|
}
|
|
983
980
|
function rt(e) {
|
|
984
|
-
let t =
|
|
981
|
+
let t = x(e), n = S(e), r = null;
|
|
985
982
|
if (t) for (let [n, i] of Object.entries(t)) {
|
|
986
|
-
if (!
|
|
983
|
+
if (!C(i)) continue;
|
|
987
984
|
let t = e[n];
|
|
988
985
|
if (typeof t != "string" || t.trim() === "") continue;
|
|
989
986
|
let a = {
|
|
@@ -1000,7 +997,7 @@ function rt(e) {
|
|
|
1000
997
|
let a = Math.min(i.length, n.length);
|
|
1001
998
|
for (let e = 0; e < a; e++) {
|
|
1002
999
|
let a = i[e];
|
|
1003
|
-
if (!
|
|
1000
|
+
if (!C(a)) continue;
|
|
1004
1001
|
let o = n[e];
|
|
1005
1002
|
if (typeof o != "string" || o.trim() === "") continue;
|
|
1006
1003
|
let s = {
|
|
@@ -1027,16 +1024,16 @@ function X(e) {
|
|
|
1027
1024
|
return typeof e == "string" && e.includes("data:image/") && e.includes(";base64,");
|
|
1028
1025
|
}
|
|
1029
1026
|
function ot(e) {
|
|
1030
|
-
let t =
|
|
1027
|
+
let t = x(e);
|
|
1031
1028
|
if (t) {
|
|
1032
|
-
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;
|
|
1033
1030
|
}
|
|
1034
|
-
let n =
|
|
1031
|
+
let n = S(e);
|
|
1035
1032
|
if (n) for (let [t, r] of Object.entries(n)) {
|
|
1036
1033
|
let n = e[t];
|
|
1037
1034
|
if (!Array.isArray(n)) continue;
|
|
1038
1035
|
let i = Math.min(r.length, n.length);
|
|
1039
|
-
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;
|
|
1040
1037
|
}
|
|
1041
1038
|
return !1;
|
|
1042
1039
|
}
|
|
@@ -1052,7 +1049,7 @@ function ct(e, t = "omit_items") {
|
|
|
1052
1049
|
//#endregion
|
|
1053
1050
|
//#region src/index.ts
|
|
1054
1051
|
function lt(e) {
|
|
1055
|
-
return
|
|
1052
|
+
return _(e)?.mediaUrl;
|
|
1056
1053
|
}
|
|
1057
1054
|
function Z(e) {
|
|
1058
1055
|
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e;
|
|
@@ -1181,7 +1178,7 @@ async function ht(e, t, n) {
|
|
|
1181
1178
|
function gt(e, t) {
|
|
1182
1179
|
let { schemaName: n, siteUrl: r, itemUrlBase: i, itemUrlPath: a, richTextDataUriImages: o = "omit_items" } = t;
|
|
1183
1180
|
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}/${
|
|
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;
|
|
1185
1182
|
if (e.pubDate || e.PubDate) {
|
|
1186
1183
|
let t = e.pubDate || e.PubDate;
|
|
1187
1184
|
c = new Date(t);
|
|
@@ -1211,7 +1208,7 @@ function gt(e, t) {
|
|
|
1211
1208
|
});
|
|
1212
1209
|
}
|
|
1213
1210
|
var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
1214
|
-
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 = [];
|
|
1215
1212
|
if (i) {
|
|
1216
1213
|
let e = i.baseUrl.replace(/\?.*$/, ""), t = e.includes("?") ? "&" : "?";
|
|
1217
1214
|
i.hasNext && g.push({
|
|
@@ -1285,7 +1282,7 @@ var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1285
1282
|
return t;
|
|
1286
1283
|
})
|
|
1287
1284
|
};
|
|
1288
|
-
return Promise.resolve(
|
|
1285
|
+
return Promise.resolve(oe(t));
|
|
1289
1286
|
}
|
|
1290
1287
|
case "json": {
|
|
1291
1288
|
let e = i?.hasNext ? `${i.baseUrl.replace(/\?.*$/, "")}?page=${i.page + 1}` : void 0, t = {
|
|
@@ -1314,7 +1311,7 @@ var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1314
1311
|
}
|
|
1315
1312
|
return t;
|
|
1316
1313
|
})
|
|
1317
|
-
}, n =
|
|
1314
|
+
}, n = se(t);
|
|
1318
1315
|
return Promise.resolve(typeof n == "string" ? n : JSON.stringify(n));
|
|
1319
1316
|
}
|
|
1320
1317
|
default: {
|
|
@@ -1378,7 +1375,7 @@ async function bt(e, t, n, r, i, a) {
|
|
|
1378
1375
|
status: 400,
|
|
1379
1376
|
headers: { "Content-Type": "application/json" }
|
|
1380
1377
|
});
|
|
1381
|
-
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;
|
|
1382
1379
|
console.log(`Schema name: ${s}`), console.log(`Collection name: ${c}`);
|
|
1383
1380
|
let h = pt(), g = J();
|
|
1384
1381
|
try {
|
|
@@ -1406,7 +1403,7 @@ async function bt(e, t, n, r, i, a) {
|
|
|
1406
1403
|
}
|
|
1407
1404
|
console.log(`Cache miss for ${s}:${o} - fetching items`);
|
|
1408
1405
|
let e = await (async () => {
|
|
1409
|
-
let e = await
|
|
1406
|
+
let e = await Ce(s, {
|
|
1410
1407
|
limit: f,
|
|
1411
1408
|
skip: p
|
|
1412
1409
|
});
|
|
@@ -1492,7 +1489,7 @@ async function xt(e, t, n, r, i, a, o) {
|
|
|
1492
1489
|
status: 400,
|
|
1493
1490
|
headers: { "Content-Type": "application/json" }
|
|
1494
1491
|
});
|
|
1495
|
-
let c =
|
|
1492
|
+
let c = w.singular(e.toLowerCase()), l = w(c), u = M(o), d = { archive: {
|
|
1496
1493
|
year: t,
|
|
1497
1494
|
month: n
|
|
1498
1495
|
} }, f = pt(), p = J();
|
|
@@ -1519,7 +1516,7 @@ async function xt(e, t, n, r, i, a, o) {
|
|
|
1519
1516
|
}
|
|
1520
1517
|
});
|
|
1521
1518
|
}
|
|
1522
|
-
let e = await
|
|
1519
|
+
let e = await we(c, t, n), r = `${u.feedUrl}/${l}/${s}`, m = `${u.feedUrl}/${l}/archive`, h = [{
|
|
1523
1520
|
rel: "prev-archive",
|
|
1524
1521
|
href: `${m}/${n === 1 ? t - 1 : t}/${n === 1 ? 12 : n - 1}/${s}`
|
|
1525
1522
|
}, {
|
|
@@ -1567,6 +1564,6 @@ async function xt(e, t, n, r, i, a, o) {
|
|
|
1567
1564
|
}
|
|
1568
1565
|
}
|
|
1569
1566
|
//#endregion
|
|
1570
|
-
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 };
|
|
1571
1568
|
|
|
1572
1569
|
//# sourceMappingURL=index.js.map
|