@seedprotocol/feed 0.5.1 → 0.5.2
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 +2 -2
- package/dist/cache/CacheManager.d.ts +5 -59
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/FileCache.d.ts +2 -54
- package/dist/cache/FileCache.d.ts.map +1 -1
- package/dist/cache/MemoryCache.d.ts +4 -48
- package/dist/cache/MemoryCache.d.ts.map +1 -1
- package/dist/cache/types.d.ts +3 -11
- package/dist/cache/types.d.ts.map +1 -1
- package/dist/feedFieldStorageModel.d.ts +2 -11
- package/dist/feedFieldStorageModel.d.ts.map +1 -1
- package/dist/getFeedItems.d.ts +10 -0
- package/dist/getFeedItems.d.ts.map +1 -1
- package/dist/hydrateArweaveRichText.d.ts +1 -10
- package/dist/hydrateArweaveRichText.d.ts.map +1 -1
- package/dist/imageRelationEnrichment.d.ts +1 -5
- package/dist/imageRelationEnrichment.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +314 -820
- package/dist/index.js.map +1 -1
- package/dist/listRelationKey.d.ts +1 -12
- package/dist/listRelationKey.d.ts.map +1 -1
- package/dist/parseEasPropertyMetadataForFeed.d.ts +2 -24
- package/dist/parseEasPropertyMetadataForFeed.d.ts.map +1 -1
- package/dist/utils/arweaveUrl.d.ts +1 -6
- package/dist/utils/arweaveUrl.d.ts.map +1 -1
- package/dist/utils/etag.d.ts +0 -4
- package/dist/utils/etag.d.ts.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1,43 +1,37 @@
|
|
|
1
|
-
import { BaseArweaveClient as e, DEFAULT_ARWEAVE_HOST as t, DEFAULT_ARWEAVE_HOST as n,
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import ae from "image-size";
|
|
1
|
+
import { BaseArweaveClient as e, DEFAULT_ARWEAVE_HOST as t, DEFAULT_ARWEAVE_HOST as n, SEED_RSS_IMAGE_RELATION_FIELD_KEYS as r, classifyMediaRef as i, ensureReadGatewaySelected as a, getArweaveReadGatewayHostsForPrimary as o, getDefaultArweaveReadGatewayHostsOrdered as s, getFeedItemStringField as c, getReadGatewayHostsForConfig as l, getResolvedSeedGatewayEndpoints as u, isEasAttestationExplorerUrl as d, normalizeFeedItemFields as f, resolveArweaveHostFromEnv as p, resolveSeedRssImageRelationFromItem as m, resolveSeedRssImageRelationRef as h, resolveSeedRssImageRelationRef as g } from "@seedprotocol/arweave";
|
|
2
|
+
import { FEED_RICH_BODY_STORAGE_SCHEMAS as _, enrichImageSeedCloneForFeed as v, feedRichBodyModelPriority as y, getArweaveUrlForTransaction as b, getFeedFieldStorageModels as x, getFeedListElementStorageModels as ee, isFeedRichBodyStorageSchema as S, queryBySchema as te, queryBySchemaForMonth as ne } from "@seedprotocol/query";
|
|
3
|
+
import re from "rss-parser";
|
|
4
|
+
import C from "pluralize";
|
|
5
|
+
import { generateAtomFeed as ie, generateJsonFeed as ae } from "feedsmith";
|
|
6
|
+
import { create as oe } from "xmlbuilder2";
|
|
7
|
+
import { createHash as se } from "crypto";
|
|
8
|
+
import { promises as w } from "fs";
|
|
9
|
+
import { join as T } from "path";
|
|
10
|
+
import ce from "image-size";
|
|
12
11
|
//#region src/bootstrap.ts
|
|
13
|
-
var
|
|
14
|
-
function
|
|
15
|
-
return e ??
|
|
12
|
+
var E = !1;
|
|
13
|
+
function le(e) {
|
|
14
|
+
return e ?? p() ?? n;
|
|
16
15
|
}
|
|
17
|
-
async function
|
|
18
|
-
if (
|
|
16
|
+
async function D(e) {
|
|
17
|
+
if (E) return;
|
|
19
18
|
let [{ registerNodeEasPlatform: t }, { registerNodeArweavePlatform: n }] = await Promise.all([import("@seedprotocol/eas/node"), import("@seedprotocol/arweave/node")]);
|
|
20
|
-
if (t(), n({ arweaveDomain:
|
|
19
|
+
if (t(), n({ arweaveDomain: le(e?.arweaveDomain) }), e?.arweaveDomain) {
|
|
21
20
|
let { BaseArweaveClient: t } = await import("@seedprotocol/arweave");
|
|
22
21
|
t.setHost(e.arweaveDomain);
|
|
23
22
|
}
|
|
24
|
-
|
|
23
|
+
E = !0;
|
|
25
24
|
}
|
|
26
|
-
var
|
|
27
|
-
async function
|
|
28
|
-
return await
|
|
25
|
+
var ue = D;
|
|
26
|
+
async function de() {
|
|
27
|
+
return await D(), { isInitialized: () => E };
|
|
29
28
|
}
|
|
30
|
-
async function
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/utils/arweaveUrl.ts
|
|
35
|
-
function E(t) {
|
|
36
|
-
return `https://${e.getHost()}/${t}`;
|
|
29
|
+
async function fe() {
|
|
30
|
+
E = !1;
|
|
37
31
|
}
|
|
38
32
|
//#endregion
|
|
39
33
|
//#region src/config.ts
|
|
40
|
-
var
|
|
34
|
+
var O = {
|
|
41
35
|
title: "Seed Protocol",
|
|
42
36
|
description: "Content published via Seed Protocol",
|
|
43
37
|
siteUrl: "https://seedprotocol.io",
|
|
@@ -50,15 +44,15 @@ var D = {
|
|
|
50
44
|
link: "https://seedprotocol.io"
|
|
51
45
|
}
|
|
52
46
|
};
|
|
53
|
-
function
|
|
47
|
+
function k(e) {
|
|
54
48
|
return {
|
|
55
49
|
...e,
|
|
56
50
|
author: e.author ? { ...e.author } : void 0
|
|
57
51
|
};
|
|
58
52
|
}
|
|
59
|
-
var
|
|
60
|
-
function
|
|
61
|
-
if (!e) return
|
|
53
|
+
var A = k(O);
|
|
54
|
+
function j(e, t = A) {
|
|
55
|
+
if (!e) return k(t);
|
|
62
56
|
let n = {
|
|
63
57
|
...t,
|
|
64
58
|
...e,
|
|
@@ -70,16 +64,16 @@ function A(e, t = k) {
|
|
|
70
64
|
name: e.author.name ?? n.author?.name ?? ""
|
|
71
65
|
}), n;
|
|
72
66
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
67
|
+
function pe() {
|
|
68
|
+
return k(A);
|
|
75
69
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
70
|
+
function me(e) {
|
|
71
|
+
return A = j(e, O), pe();
|
|
78
72
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
73
|
+
function he() {
|
|
74
|
+
A = k(O);
|
|
81
75
|
}
|
|
82
|
-
function
|
|
76
|
+
function M() {
|
|
83
77
|
return {
|
|
84
78
|
itemUrlBase: process.env.FEED_ITEM_URL_BASE?.trim() || "https://optimism-sepolia.easscan.org",
|
|
85
79
|
itemUrlPath: process.env.FEED_ITEM_URL_PATH?.trim() || "attestation/view",
|
|
@@ -90,192 +84,8 @@ function j() {
|
|
|
90
84
|
};
|
|
91
85
|
}
|
|
92
86
|
//#endregion
|
|
93
|
-
//#region src/listRelationKey.ts
|
|
94
|
-
var pe = /^(.+?)([A-Z][a-zA-Z]+)Ids$/;
|
|
95
|
-
function M(e) {
|
|
96
|
-
let t = pe.exec(e);
|
|
97
|
-
if (t) {
|
|
98
|
-
let e = t[1];
|
|
99
|
-
if (e) return x(e);
|
|
100
|
-
}
|
|
101
|
-
if (e.endsWith("_ids")) {
|
|
102
|
-
let t = e.slice(0, -4), n = t.split("_").filter(Boolean);
|
|
103
|
-
if (n.length >= 2) {
|
|
104
|
-
let e = n[0];
|
|
105
|
-
return e.endsWith("s") ? e : x(e);
|
|
106
|
-
}
|
|
107
|
-
return x(t);
|
|
108
|
-
}
|
|
109
|
-
return e;
|
|
110
|
-
}
|
|
111
|
-
function me(e, t) {
|
|
112
|
-
for (let n of Object.keys(e)) n !== t && M(n) === t && delete e[n];
|
|
113
|
-
}
|
|
114
|
-
function he(e) {
|
|
115
|
-
if (Array.isArray(e) || typeof e != "string") return e;
|
|
116
|
-
let t = e.trim();
|
|
117
|
-
if (!t.startsWith("[")) return e;
|
|
118
|
-
try {
|
|
119
|
-
let e = JSON.parse(t);
|
|
120
|
-
if (Array.isArray(e)) return e;
|
|
121
|
-
} catch {}
|
|
122
|
-
return e;
|
|
123
|
-
}
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/imageRelationEnrichment.ts
|
|
126
|
-
function ge(e) {
|
|
127
|
-
let t = e.storageTransactionId ?? e.storage_transaction_id;
|
|
128
|
-
if (t && typeof t == "string" && t.trim()) try {
|
|
129
|
-
e.arweaveUrl = E(t.trim());
|
|
130
|
-
} catch {}
|
|
131
|
-
}
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/feedFieldStorageModel.ts
|
|
134
|
-
var _e = new Set([
|
|
135
|
-
"html",
|
|
136
|
-
"file",
|
|
137
|
-
"json"
|
|
138
|
-
]), ve = "_feedFieldStorageModels", ye = "_feedListElementStorageModels";
|
|
139
|
-
function N(e) {
|
|
140
|
-
return e.trim().toLowerCase();
|
|
141
|
-
}
|
|
142
|
-
function P(e) {
|
|
143
|
-
return _e.has(N(e));
|
|
144
|
-
}
|
|
145
|
-
function be(e) {
|
|
146
|
-
let t = N(e);
|
|
147
|
-
return t === "html" ? 0 : t === "file" ? 1 : t === "json" ? 2 : 99;
|
|
148
|
-
}
|
|
149
|
-
function F(e) {
|
|
150
|
-
let t = e[ve];
|
|
151
|
-
if (typeof t == "object" && t && !Array.isArray(t)) return t;
|
|
152
|
-
}
|
|
153
|
-
function I(e) {
|
|
154
|
-
let t = e[ye];
|
|
155
|
-
if (typeof t == "object" && t && !Array.isArray(t)) return t;
|
|
156
|
-
}
|
|
157
|
-
function xe(e, t, n) {
|
|
158
|
-
let r = N(n), i = F(e);
|
|
159
|
-
i || (i = {}, e[ve] = i), i[t] = r;
|
|
160
|
-
}
|
|
161
|
-
function Se(e, t, n) {
|
|
162
|
-
let r = I(e);
|
|
163
|
-
r || (r = {}, e[ye] = r), r[t] = n.map(N);
|
|
164
|
-
}
|
|
165
|
-
//#endregion
|
|
166
|
-
//#region src/hydrateArweaveRichText.ts
|
|
167
|
-
var Ce = [
|
|
168
|
-
"html",
|
|
169
|
-
"Html",
|
|
170
|
-
"body",
|
|
171
|
-
"Body",
|
|
172
|
-
"content",
|
|
173
|
-
"Content"
|
|
174
|
-
], we = 8e6;
|
|
175
|
-
function Te(t) {
|
|
176
|
-
let n = t.trim();
|
|
177
|
-
if (!n.startsWith("http://") && !n.startsWith("https://")) return !1;
|
|
178
|
-
try {
|
|
179
|
-
let t = new URL(n), r = t.hostname.toLowerCase();
|
|
180
|
-
if (r !== e.getHost().toLowerCase() && !u(r)) return !1;
|
|
181
|
-
let i = t.pathname.replace(/^\//, "").split("/").filter(Boolean);
|
|
182
|
-
if (i.length !== 1) return !1;
|
|
183
|
-
let a = i[0];
|
|
184
|
-
return /^[A-Za-z0-9_-]{43}$/.test(a);
|
|
185
|
-
} catch {
|
|
186
|
-
return !1;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
async function Ee(e) {
|
|
190
|
-
try {
|
|
191
|
-
let t = await fetch(e, {
|
|
192
|
-
headers: { Accept: "text/html, text/plain, text/markdown, application/json, */*" },
|
|
193
|
-
signal: AbortSignal.timeout(15e3)
|
|
194
|
-
});
|
|
195
|
-
if (!t.ok) return null;
|
|
196
|
-
let n = t.headers.get("content-type") ?? "";
|
|
197
|
-
if (/^(image|video|audio)\//i.test(n)) return null;
|
|
198
|
-
let r = await t.arrayBuffer();
|
|
199
|
-
if (r.byteLength > we) return null;
|
|
200
|
-
let i = new TextDecoder("utf-8", { fatal: !1 }).decode(r);
|
|
201
|
-
return i.length === 0 || i.includes("\0") ? null : i;
|
|
202
|
-
} catch {
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
async function De(e, t) {
|
|
207
|
-
let n = e[t];
|
|
208
|
-
if (typeof n != "string" || n.trim() === "" || !Te(n)) return;
|
|
209
|
-
let r = await Ee(n);
|
|
210
|
-
r !== null && (e[t] = r);
|
|
211
|
-
}
|
|
212
|
-
async function Oe(e) {
|
|
213
|
-
for (let t of e) {
|
|
214
|
-
let e = new Set([...Ce]), n = F(t);
|
|
215
|
-
if (n) for (let [t, r] of Object.entries(n)) P(r) && e.add(t);
|
|
216
|
-
for (let n of e) await De(t, n);
|
|
217
|
-
let r = I(t);
|
|
218
|
-
if (r) for (let [e, n] of Object.entries(r)) {
|
|
219
|
-
let r = t[e];
|
|
220
|
-
if (!Array.isArray(r)) continue;
|
|
221
|
-
let i = Math.min(n.length, r.length);
|
|
222
|
-
for (let e = 0; e < i; e++) {
|
|
223
|
-
if (!P(n[e])) continue;
|
|
224
|
-
let t = r[e];
|
|
225
|
-
if (typeof t != "string" || !Te(t)) continue;
|
|
226
|
-
let i = await Ee(t);
|
|
227
|
-
i !== null && (r[e] = i);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
//#endregion
|
|
233
|
-
//#region src/parseEasPropertyMetadataForFeed.ts
|
|
234
|
-
function ke(e) {
|
|
235
|
-
let t = typeof e == "string" ? e.trim() : "";
|
|
236
|
-
if (!t) return {
|
|
237
|
-
ok: !1,
|
|
238
|
-
reason: "empty"
|
|
239
|
-
};
|
|
240
|
-
let n;
|
|
241
|
-
try {
|
|
242
|
-
n = JSON.parse(t);
|
|
243
|
-
} catch (e) {
|
|
244
|
-
return {
|
|
245
|
-
ok: !1,
|
|
246
|
-
reason: "parse",
|
|
247
|
-
error: e
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
return !Array.isArray(n) || n.length === 0 || !n[0]?.value ? {
|
|
251
|
-
ok: !1,
|
|
252
|
-
reason: "shape"
|
|
253
|
-
} : {
|
|
254
|
-
ok: !0,
|
|
255
|
-
metadata: n[0].value
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
//#endregion
|
|
259
87
|
//#region src/getFeedItems.ts
|
|
260
|
-
var
|
|
261
|
-
query GetSeeds($where: AttestationWhereInput!, $take: Int, $skip: Int) {
|
|
262
|
-
itemSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }], take: $take, skip: $skip) {
|
|
263
|
-
id
|
|
264
|
-
decodedDataJson
|
|
265
|
-
attester
|
|
266
|
-
schema {
|
|
267
|
-
schemaNames {
|
|
268
|
-
name
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
refUID
|
|
272
|
-
revoked
|
|
273
|
-
schemaId
|
|
274
|
-
timeCreated
|
|
275
|
-
isOffchain
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
`, z = (e) => e.replace(/_([a-z])/g, (e, t) => t.toUpperCase()), je = (e) => {
|
|
88
|
+
var ge = (e) => {
|
|
279
89
|
let t = /* @__PURE__ */ new Date(e * 1e3), n = [
|
|
280
90
|
"Sun",
|
|
281
91
|
"Mon",
|
|
@@ -299,21 +109,12 @@ var L = "image", R = ["0x0000000000000000000000000000000000000000000000000000000
|
|
|
299
109
|
"Dec"
|
|
300
110
|
], i = n[t.getUTCDay()], a = r[t.getUTCMonth()], o = t.getUTCFullYear();
|
|
301
111
|
return `${i}, ${t.getUTCDate().toString().padStart(2, "0")} ${a} ${o} ${t.getUTCHours().toString().padStart(2, "0")}:${t.getUTCMinutes().toString().padStart(2, "0")}:${t.getUTCSeconds().toString().padStart(2, "0")} GMT`;
|
|
302
|
-
},
|
|
303
|
-
let [t, n, r] = e.split("_");
|
|
304
|
-
if (!t || !n) return null;
|
|
305
|
-
let i = r === "ids";
|
|
306
|
-
return {
|
|
307
|
-
propertyName: t.endsWith("s") ? t : t + "s",
|
|
308
|
-
modelName: n,
|
|
309
|
-
isList: i
|
|
310
|
-
};
|
|
311
|
-
}, B = (e, t, n, r) => {
|
|
112
|
+
}, _e = (e) => e === "image" ? "images" : e === "post" ? "posts" : e.toLowerCase() + "s", N = (e, t, n, r) => {
|
|
312
113
|
let { itemUrlBase: i, itemUrlPath: a, siteUrl: o } = r;
|
|
313
114
|
!e.title && !e.Title ? (e.title = t, e.Title = t) : e.title && !e.Title ? e.Title = e.title : e.Title && !e.title && (e.title = e.Title);
|
|
314
|
-
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 =
|
|
115
|
+
let s = e.storage_transaction_id && typeof e.storage_transaction_id == "string" && e.storage_transaction_id.trim() !== "" && e.storage_transaction_id !== "undefined" && e.storage_transaction_id !== t ? e.storage_transaction_id.trim() : null, c = e.storageTransactionId && typeof e.storageTransactionId == "string" && e.storageTransactionId.trim() !== "" && e.storageTransactionId !== "undefined" && e.storageTransactionId !== t ? e.storageTransactionId.trim() : null, l = s || c, u = _e(n), d = t && typeof t == "string" && t.trim() !== "" ? t : "unknown", f;
|
|
315
116
|
if (l && l !== t && l.length > 0) try {
|
|
316
|
-
f =
|
|
117
|
+
f = b(l);
|
|
317
118
|
} catch (e) {
|
|
318
119
|
console.error("[feed] [setFeedItemDefaults] Error generating Arweave URL:", e), f = i == null ? `${o.replace(/\/$/, "")}/${u}/${d}` : `${i.replace(/\/$/, "")}/${(a ?? "attestation/view").replace(/^\//, "")}/${d}`;
|
|
319
120
|
}
|
|
@@ -322,248 +123,98 @@ var L = "image", R = ["0x0000000000000000000000000000000000000000000000000000000
|
|
|
322
123
|
!p || p === "undefined" || typeof p == "string" && p.trim() === "" ? (e.link = f, e.Link = f) : ((!e.link || e.link === "undefined") && (e.link = p), (!e.Link || e.Link === "undefined") && (e.Link = p));
|
|
323
124
|
let m = e.guid || e.Guid;
|
|
324
125
|
if (!m || m === "undefined" || typeof m == "string" && m.trim() === "" ? (e.guid = e.link || f, e.Guid = e.guid) : ((!e.guid || e.guid === "undefined") && (e.guid = m), (!e.Guid || e.Guid === "undefined") && (e.Guid = m)), e.timeCreated && !e.pubDate && !e.PubDate) {
|
|
325
|
-
let t =
|
|
126
|
+
let t = ge(e.timeCreated);
|
|
326
127
|
e.pubDate = t, e.PubDate = t;
|
|
327
128
|
} else e.pubDate && !e.PubDate ? e.PubDate = e.pubDate : e.PubDate && !e.pubDate && (e.pubDate = e.PubDate);
|
|
328
129
|
!e.seedUid && !e.SeedUid ? (e.seedUid = t, e.SeedUid = t) : e.seedUid && !e.SeedUid ? e.SeedUid = e.seedUid : e.SeedUid && !e.seedUid && (e.seedUid = e.SeedUid), e.attester && !e.Attester ? e.Attester = e.attester : e.Attester && !e.attester && (e.attester = e.Attester);
|
|
329
|
-
},
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
if (
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
});
|
|
356
|
-
} else R.includes(r.value) || H.add(r.value);
|
|
357
|
-
let d = r.value;
|
|
358
|
-
o && s && Array.isArray(d) ? d = d.map((e) => String(e)) : typeof d != "string" && (d = JSON.stringify(d)), o && !s && t.find((e) => e.id === r.value)?.schema?.schemaNames, o && s && t.filter((e) => Array.isArray(r.value) && r.value.includes(e.id)).length;
|
|
359
|
-
let f = Pe.get(e.refUID);
|
|
360
|
-
if (!f) return;
|
|
361
|
-
let p = U.get(f) || {};
|
|
362
|
-
p[i] = d;
|
|
363
|
-
let m = z(i);
|
|
364
|
-
m !== i && (p[m] = d), U.set(f, p);
|
|
365
|
-
}, Re = async (e) => {
|
|
366
|
-
let t = e.map((e) => e.id);
|
|
367
|
-
for (let n = 0; n < e.length; n++) {
|
|
368
|
-
let r = e[n];
|
|
369
|
-
if (!r) continue;
|
|
370
|
-
t.push(r.id);
|
|
371
|
-
let i = r.schema?.schemaNames?.[0]?.name ?? "unknown";
|
|
372
|
-
V.set(r.id, i), U.has(r.id) || U.set(r.id, {
|
|
373
|
-
seedUid: r.id,
|
|
374
|
-
timeCreated: r.timeCreated,
|
|
375
|
-
attester: r.attester
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
let n = await h({ seedUids: t });
|
|
379
|
-
for (let e = 0; e < n.length; e++) {
|
|
380
|
-
let t = n[e], r = t.refUID;
|
|
381
|
-
Pe.set(t.id, r);
|
|
382
|
-
let i = W.get(r) || [];
|
|
383
|
-
W.set(r, [...i, t]);
|
|
384
|
-
}
|
|
385
|
-
let r = [];
|
|
386
|
-
for (let [e, t] of W.entries()) {
|
|
387
|
-
let n = [...t].sort((e, t) => t.timeCreated - e.timeCreated)[0];
|
|
388
|
-
n && (r.push(n.id), Fe.set(e, n.id));
|
|
389
|
-
}
|
|
390
|
-
let i = _(await m({ versionUids: r }));
|
|
391
|
-
for (let t = 0; t < i.length; t++) await Le(i[t], e);
|
|
392
|
-
}, ze = new Set([
|
|
393
|
-
"seedUid",
|
|
394
|
-
"SeedUid",
|
|
395
|
-
"timeCreated",
|
|
396
|
-
"attester",
|
|
397
|
-
"Attester",
|
|
398
|
-
"storage_transaction_id",
|
|
399
|
-
"storage_provider_transaction_id",
|
|
400
|
-
"storageTransactionId",
|
|
401
|
-
"storageProviderTransactionId"
|
|
402
|
-
]);
|
|
403
|
-
function Be(e) {
|
|
404
|
-
let t = Array.from(U.entries()).filter(([t]) => V.get(t) === e);
|
|
405
|
-
for (let [, e] of t) {
|
|
406
|
-
let t = Object.keys(e).filter((e) => !e.startsWith("_") && !ze.has(e));
|
|
407
|
-
for (let n of t) {
|
|
408
|
-
let t = e[n], r = he(t);
|
|
409
|
-
if (r !== t && Array.isArray(r) && (e[n] = r, t = r), Array.isArray(t)) {
|
|
410
|
-
let r = t;
|
|
411
|
-
if (!r.some((e) => typeof e == "string" && !R.includes(e) && U.has(e))) continue;
|
|
412
|
-
let i = [], a = [], o = !1;
|
|
413
|
-
for (let e of r) {
|
|
414
|
-
if (typeof e != "string" || R.includes(e)) {
|
|
415
|
-
i.push(String(e)), a.push("unknown");
|
|
416
|
-
continue;
|
|
417
|
-
}
|
|
418
|
-
let t = V.get(e) ?? "unknown";
|
|
419
|
-
if (t === L) {
|
|
420
|
-
i.push(e), a.push(L);
|
|
421
|
-
continue;
|
|
422
|
-
}
|
|
423
|
-
let n = U.get(e), r = n?.storageTransactionId ?? n?.storage_transaction_id;
|
|
424
|
-
if (r && typeof r == "string" && r.trim()) try {
|
|
425
|
-
i.push(E(r)), a.push(t), o = !0;
|
|
426
|
-
} catch {
|
|
427
|
-
i.push(e), a.push(t);
|
|
428
|
-
}
|
|
429
|
-
else i.push(e), a.push(t);
|
|
430
|
-
}
|
|
431
|
-
if (o) {
|
|
432
|
-
let t = M(n);
|
|
433
|
-
if (e[t] = i, Se(e, t, a), me(e, t), t !== n) {
|
|
434
|
-
delete e[n];
|
|
435
|
-
let t = z(n);
|
|
436
|
-
t !== n && delete e[t];
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
} else if (typeof t == "string") {
|
|
440
|
-
if (R.includes(t) || !U.has(t)) continue;
|
|
441
|
-
let r = U.get(t);
|
|
442
|
-
if (V.get(t) === L) continue;
|
|
443
|
-
let i = r?.storageTransactionId ?? r?.storage_transaction_id;
|
|
444
|
-
if (i && typeof i == "string" && i.trim()) try {
|
|
445
|
-
let r = n.endsWith("_id") ? n.replace(/_id$/, "") : n;
|
|
446
|
-
e[r] = E(i);
|
|
447
|
-
let a = V.get(t) ?? "unknown";
|
|
448
|
-
xe(e, r, a);
|
|
449
|
-
let o = z(r);
|
|
450
|
-
if (o !== r && xe(e, o, a), r !== n) {
|
|
451
|
-
delete e[n];
|
|
452
|
-
let t = z(n);
|
|
453
|
-
t !== n && delete e[t];
|
|
454
|
-
}
|
|
455
|
-
} catch {}
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
function Ve(e, t, n) {
|
|
461
|
-
if (!n) return;
|
|
462
|
-
let r = Array.from(U.entries()).filter(([t]) => V.get(t) === e);
|
|
463
|
-
for (let [, e] of r) {
|
|
464
|
-
let n = Object.keys(e).filter((e) => !e.startsWith("_") && !ze.has(e));
|
|
465
|
-
for (let r of n) {
|
|
466
|
-
let n = e[r], i = he(n);
|
|
467
|
-
i !== n && Array.isArray(i) && (e[r] = i, n = i);
|
|
468
|
-
let a = Array.isArray(n), o = a ? n : [n], s = [], c = !1;
|
|
469
|
-
for (let e of o) {
|
|
470
|
-
if (typeof e != "string" || R.includes(e)) {
|
|
471
|
-
s.push(e);
|
|
472
|
-
continue;
|
|
473
|
-
}
|
|
474
|
-
let n = U.get(e);
|
|
475
|
-
if (!n) {
|
|
476
|
-
s.push(e);
|
|
477
|
-
continue;
|
|
478
|
-
}
|
|
479
|
-
let r = n?.storageTransactionId ?? n?.storage_transaction_id;
|
|
480
|
-
if (V.get(e) === L) {
|
|
481
|
-
let r = V.get(e) ?? "unknown", i = { ...n };
|
|
482
|
-
B(i, e, r, t), ge(i), s.push(i), c = !0;
|
|
483
|
-
continue;
|
|
484
|
-
}
|
|
485
|
-
if (r && typeof r == "string" && r.trim()) {
|
|
486
|
-
s.push(e);
|
|
487
|
-
continue;
|
|
488
|
-
}
|
|
489
|
-
let i = V.get(e) ?? "unknown", a = { ...n };
|
|
490
|
-
B(a, e, i, t), s.push(a), c = !0;
|
|
491
|
-
}
|
|
492
|
-
if (c) {
|
|
493
|
-
let t = a ? M(r) : r.endsWith("_id") ? r.replace(/_id$/, "") : r;
|
|
494
|
-
if (e[t] = a ? s : s[0], me(e, t), t !== r) {
|
|
495
|
-
delete e[r];
|
|
496
|
-
let t = z(r);
|
|
497
|
-
t !== r && delete e[t];
|
|
498
|
-
}
|
|
130
|
+
}, P = (e, t) => {
|
|
131
|
+
if (!e.title && !e.Title ? (e.title = t, e.Title = t) : e.title && !e.Title ? e.Title = e.title : e.Title && !e.title && (e.title = e.Title), e.timeCreated && !e.pubDate && !e.PubDate) {
|
|
132
|
+
let t = ge(e.timeCreated);
|
|
133
|
+
e.pubDate = t, e.PubDate = t;
|
|
134
|
+
} else e.pubDate && !e.PubDate ? e.PubDate = e.pubDate : e.PubDate && !e.pubDate && (e.pubDate = e.PubDate);
|
|
135
|
+
!e.seedUid && !e.SeedUid ? (e.seedUid = t, e.SeedUid = t) : e.seedUid && !e.SeedUid ? e.SeedUid = e.seedUid : e.SeedUid && !e.seedUid && (e.seedUid = e.SeedUid), e.attester && !e.Attester ? e.Attester = e.attester : e.Attester && !e.attester && (e.attester = e.Attester);
|
|
136
|
+
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
|
+
if (delete e.link, delete e.Link, delete e.guid, delete e.Guid, i && i.length > 0) try {
|
|
138
|
+
let t = b(i);
|
|
139
|
+
e.link = t, e.Link = t;
|
|
140
|
+
} catch {}
|
|
141
|
+
};
|
|
142
|
+
function F(e) {
|
|
143
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
144
|
+
let t = e;
|
|
145
|
+
return typeof t.seedUid == "string" || typeof t.SeedUid == "string";
|
|
146
|
+
}
|
|
147
|
+
function ve(e, t, n) {
|
|
148
|
+
N(e, e.seedUid || e.SeedUid || "", t, n);
|
|
149
|
+
for (let r of Object.keys(e)) {
|
|
150
|
+
if (r.startsWith("_")) continue;
|
|
151
|
+
let i = e[r];
|
|
152
|
+
if (Array.isArray(i)) {
|
|
153
|
+
for (let e of i) if (F(e)) {
|
|
154
|
+
let r = e.seedUid || e.SeedUid || "", i = typeof e.schemaName == "string" ? e.schemaName : t;
|
|
155
|
+
i === "image" ? P(e, r) : N(e, r, i, n);
|
|
499
156
|
}
|
|
157
|
+
} else if (F(i)) {
|
|
158
|
+
let e = i.seedUid || i.SeedUid || "", r = typeof i.schemaName == "string" ? i.schemaName : t;
|
|
159
|
+
r === "image" ? P(i, e) : N(i, e, r, n);
|
|
500
160
|
}
|
|
501
161
|
}
|
|
502
162
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
skip: 0
|
|
509
|
-
});
|
|
510
|
-
await Re(a ?? []), Be(e);
|
|
511
|
-
let o = j(), s = {
|
|
512
|
-
itemUrlBase: o.itemUrlBase,
|
|
513
|
-
itemUrlPath: o.itemUrlPath,
|
|
514
|
-
siteUrl: o.siteUrl
|
|
163
|
+
function I(e, t) {
|
|
164
|
+
let n = M(), r = {
|
|
165
|
+
itemUrlBase: n.itemUrlBase,
|
|
166
|
+
itemUrlPath: n.itemUrlPath,
|
|
167
|
+
siteUrl: n.siteUrl
|
|
515
168
|
};
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
169
|
+
return t.map((t) => {
|
|
170
|
+
let n = t.data;
|
|
171
|
+
return ve(n, e, r), n;
|
|
172
|
+
});
|
|
519
173
|
}
|
|
520
|
-
var
|
|
521
|
-
await
|
|
522
|
-
let n =
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
gte: o,
|
|
528
|
-
lt: s
|
|
529
|
-
} }] }), { itemSeeds: l } = await p.getEasClient().request(Ae, {
|
|
530
|
-
where: c,
|
|
531
|
-
take: 1e3,
|
|
532
|
-
skip: 0
|
|
174
|
+
var ye = async (e, t) => {
|
|
175
|
+
await D();
|
|
176
|
+
let n = M(), { items: r } = await te(e, {
|
|
177
|
+
limit: t?.limit ?? 100,
|
|
178
|
+
skip: t?.skip ?? 0,
|
|
179
|
+
expandRelations: n.expandRelations !== !1,
|
|
180
|
+
hydrateStorage: !0
|
|
533
181
|
});
|
|
534
|
-
return
|
|
535
|
-
}
|
|
182
|
+
return I(e, r);
|
|
183
|
+
}, be = async (e, t, n) => (await D(), I(e, await ne(e, t, n, {
|
|
184
|
+
expandRelations: M().expandRelations !== !1,
|
|
185
|
+
hydrateStorage: !0
|
|
186
|
+
})));
|
|
536
187
|
//#endregion
|
|
537
188
|
//#region src/consume/parseRss.ts
|
|
538
|
-
function
|
|
189
|
+
function xe(e) {
|
|
539
190
|
try {
|
|
540
191
|
return JSON.parse(JSON.stringify(e));
|
|
541
192
|
} catch {
|
|
542
193
|
return { ...e };
|
|
543
194
|
}
|
|
544
195
|
}
|
|
545
|
-
var
|
|
196
|
+
var Se = new re({ customFields: { item: [
|
|
546
197
|
"featureImage",
|
|
547
198
|
"feature_image",
|
|
548
199
|
"content:encoded",
|
|
549
200
|
"seedUid",
|
|
550
201
|
"SeedUid"
|
|
551
202
|
] } });
|
|
552
|
-
async function
|
|
553
|
-
let t = await
|
|
203
|
+
async function Ce(e) {
|
|
204
|
+
let t = await Se.parseString(e);
|
|
554
205
|
return {
|
|
555
206
|
title: t.title,
|
|
556
207
|
link: t.link,
|
|
557
208
|
description: t.description,
|
|
558
|
-
items: (t.items ?? []).map(
|
|
209
|
+
items: (t.items ?? []).map(xe)
|
|
559
210
|
};
|
|
560
211
|
}
|
|
561
212
|
//#endregion
|
|
562
213
|
//#region src/rss/generateRssXml.ts
|
|
563
|
-
var
|
|
214
|
+
var L = "http://purl.org/dc/elements/1.1/", R = "http://purl.org/rss/1.0/modules/content/", z = "http://search.yahoo.com/mrss/", we = { publication: {
|
|
564
215
|
prefix: "publication",
|
|
565
216
|
uri: "https://seedprotocol.io/ns/publication/1.0"
|
|
566
|
-
} },
|
|
217
|
+
} }, Te = "https://seedprotocol.io/ns/relations", Ee = new Set([
|
|
567
218
|
"xml",
|
|
568
219
|
"xmlns",
|
|
569
220
|
"dc",
|
|
@@ -571,17 +222,17 @@ var K = "http://purl.org/dc/elements/1.1/", q = "http://purl.org/rss/1.0/modules
|
|
|
571
222
|
"content",
|
|
572
223
|
"atom",
|
|
573
224
|
"fh"
|
|
574
|
-
]),
|
|
225
|
+
]), De = new Set([
|
|
575
226
|
"Title",
|
|
576
227
|
"Link",
|
|
577
228
|
"Guid",
|
|
578
229
|
"PubDate",
|
|
579
230
|
"SeedUid"
|
|
580
231
|
]);
|
|
581
|
-
function
|
|
582
|
-
return
|
|
232
|
+
function Oe(e, t) {
|
|
233
|
+
return De.has(e) ? e.charAt(0).toLowerCase() + e.slice(1) in t : !1;
|
|
583
234
|
}
|
|
584
|
-
var
|
|
235
|
+
var B = [
|
|
585
236
|
"title",
|
|
586
237
|
"link",
|
|
587
238
|
"description",
|
|
@@ -605,7 +256,7 @@ var Qe = [
|
|
|
605
256
|
"media:category",
|
|
606
257
|
"media:group"
|
|
607
258
|
];
|
|
608
|
-
function
|
|
259
|
+
function V(e) {
|
|
609
260
|
if (e instanceof Date) return e.toUTCString();
|
|
610
261
|
if (typeof e == "string") {
|
|
611
262
|
let t = new Date(e);
|
|
@@ -613,22 +264,22 @@ function $e(e) {
|
|
|
613
264
|
}
|
|
614
265
|
return String(e);
|
|
615
266
|
}
|
|
616
|
-
function
|
|
267
|
+
function ke(e) {
|
|
617
268
|
return /[<>&]|]]>/.test(e);
|
|
618
269
|
}
|
|
619
|
-
function
|
|
270
|
+
function H(e, t) {
|
|
620
271
|
let n = String(t);
|
|
621
|
-
if (n !== "") if (
|
|
272
|
+
if (n !== "") if (ke(n)) if (n.includes("]]>")) {
|
|
622
273
|
let t = n.split("]]>");
|
|
623
274
|
for (let n = 0; n < t.length; n++) e.dat(t[n]), n < t.length - 1 && e.txt("]]>");
|
|
624
275
|
} else e.dat(n);
|
|
625
276
|
else e.txt(n);
|
|
626
277
|
}
|
|
627
|
-
function
|
|
278
|
+
function U(e) {
|
|
628
279
|
return typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof Date);
|
|
629
280
|
}
|
|
630
|
-
var
|
|
631
|
-
...
|
|
281
|
+
var Ae = 4, je = new Set([
|
|
282
|
+
...B,
|
|
632
283
|
"guid",
|
|
633
284
|
"source",
|
|
634
285
|
"dc",
|
|
@@ -636,79 +287,79 @@ var tt = 4, nt = new Set([
|
|
|
636
287
|
"content:encoded",
|
|
637
288
|
"items"
|
|
638
289
|
]);
|
|
639
|
-
function
|
|
290
|
+
function Me(e) {
|
|
640
291
|
return e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e;
|
|
641
292
|
}
|
|
642
|
-
function
|
|
293
|
+
function Ne(e) {
|
|
643
294
|
return e.trim().replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[^A-Za-z_]+/, "").replace(/^$/, "rel").toLowerCase();
|
|
644
295
|
}
|
|
645
|
-
function
|
|
646
|
-
if (!t.has(e) && !
|
|
296
|
+
function Pe(e, t) {
|
|
297
|
+
if (!t.has(e) && !Ee.has(e)) return t.add(e), e;
|
|
647
298
|
let n = 2;
|
|
648
299
|
for (;;) {
|
|
649
300
|
let r = `${e}${n}`;
|
|
650
|
-
if (!t.has(r) && !
|
|
301
|
+
if (!t.has(r) && !Ee.has(r)) return t.add(r), r;
|
|
651
302
|
n += 1;
|
|
652
303
|
}
|
|
653
304
|
}
|
|
654
|
-
function
|
|
655
|
-
return Array.isArray(e) && e.length > 0 && e.every((e) =>
|
|
305
|
+
function Fe(e) {
|
|
306
|
+
return Array.isArray(e) && e.length > 0 && e.every((e) => U(e));
|
|
656
307
|
}
|
|
657
|
-
function
|
|
658
|
-
let t = { ...
|
|
308
|
+
function Ie(e) {
|
|
309
|
+
let t = { ...we }, n = new Set(Object.values(t).map((e) => e.prefix)), r = /* @__PURE__ */ new Set();
|
|
659
310
|
for (let t of e) for (let [e, n] of Object.entries(t)) {
|
|
660
|
-
let t = e === "author" &&
|
|
661
|
-
e.startsWith("_") ||
|
|
311
|
+
let t = e === "author" && U(n) || e === "authors" && Fe(n);
|
|
312
|
+
e.startsWith("_") || je.has(e) && !t || (U(n) || Fe(n)) && r.add(Me(e));
|
|
662
313
|
}
|
|
663
314
|
let i = [...r].sort();
|
|
664
315
|
for (let e of i) t[e] || (t[e] = {
|
|
665
|
-
prefix:
|
|
666
|
-
uri: `${
|
|
316
|
+
prefix: Pe(Ne(e), n),
|
|
317
|
+
uri: `${Te}/${e}/1.0`
|
|
667
318
|
});
|
|
668
319
|
return t;
|
|
669
320
|
}
|
|
670
|
-
function
|
|
321
|
+
function W(e, t) {
|
|
671
322
|
if (e in t) return t[e];
|
|
672
323
|
if (e.endsWith("s") && e.length > 1) {
|
|
673
324
|
let n = e.slice(0, -1);
|
|
674
325
|
if (n in t) return t[n];
|
|
675
326
|
}
|
|
676
327
|
}
|
|
677
|
-
function
|
|
328
|
+
function Le(e, t) {
|
|
678
329
|
return t ? `${t.prefix}:${e}` : e;
|
|
679
330
|
}
|
|
680
|
-
function
|
|
331
|
+
function G(e, t, n, r, i = 0, a) {
|
|
681
332
|
let o = e.ele(n);
|
|
682
333
|
for (let [e, n] of Object.entries(t)) {
|
|
683
334
|
if (n == null || e.startsWith("_") || e === "items") continue;
|
|
684
|
-
let t =
|
|
685
|
-
if (i >=
|
|
686
|
-
|
|
335
|
+
let t = Le(e, a);
|
|
336
|
+
if (i >= Ae) {
|
|
337
|
+
H(o.ele(t), typeof n == "object" ? JSON.stringify(n) : String(n));
|
|
687
338
|
continue;
|
|
688
339
|
}
|
|
689
340
|
if (Array.isArray(n)) {
|
|
690
|
-
let t =
|
|
691
|
-
for (let e of n) e != null && (
|
|
341
|
+
let t = Le(e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e, a);
|
|
342
|
+
for (let e of n) e != null && (U(e) ? G(o, e, t, !1, i + 1, a) : H(o.ele(t), String(e)));
|
|
692
343
|
continue;
|
|
693
344
|
}
|
|
694
|
-
if (
|
|
695
|
-
|
|
345
|
+
if (U(n)) {
|
|
346
|
+
G(o, n, t, !1, i + 1, a);
|
|
696
347
|
continue;
|
|
697
348
|
}
|
|
698
|
-
|
|
349
|
+
H(o.ele(t), String(n));
|
|
699
350
|
}
|
|
700
351
|
if (r) {
|
|
701
352
|
let n = t.name ?? t.seedUid;
|
|
702
|
-
n && e.ele(
|
|
353
|
+
n && e.ele(L, "creator").txt(String(n));
|
|
703
354
|
}
|
|
704
355
|
}
|
|
705
|
-
function
|
|
356
|
+
function Re(e, t, n, r, i) {
|
|
706
357
|
if (!(n == null || t.startsWith("_")) && t !== "items") {
|
|
707
358
|
if (t === "guid") {
|
|
708
359
|
let t = n, r = t?.value ?? String(n);
|
|
709
360
|
if (!r) return;
|
|
710
361
|
let i = {};
|
|
711
|
-
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"),
|
|
362
|
+
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"), H(e.ele("guid", i), r);
|
|
712
363
|
return;
|
|
713
364
|
}
|
|
714
365
|
if (t === "source" && typeof n == "object" && n) {
|
|
@@ -732,35 +383,35 @@ function lt(e, t, n, r, i) {
|
|
|
732
383
|
let t = n;
|
|
733
384
|
for (let [n, r] of Object.entries(t)) if (r != null) if (Array.isArray(r)) {
|
|
734
385
|
for (let t of r) if (t != null) {
|
|
735
|
-
let r = e.ele(
|
|
736
|
-
t instanceof Date ? r.txt(t.toISOString()) :
|
|
386
|
+
let r = e.ele(L, n);
|
|
387
|
+
t instanceof Date ? r.txt(t.toISOString()) : H(r, String(t));
|
|
737
388
|
}
|
|
738
389
|
} else {
|
|
739
|
-
let t = e.ele(
|
|
740
|
-
r instanceof Date ? t.txt(r.toISOString()) :
|
|
390
|
+
let t = e.ele(L, n);
|
|
391
|
+
r instanceof Date ? t.txt(r.toISOString()) : H(t, String(r));
|
|
741
392
|
}
|
|
742
393
|
return;
|
|
743
394
|
}
|
|
744
395
|
if (t === "content:encoded") {
|
|
745
|
-
|
|
396
|
+
H(e.ele(R, "encoded"), String(n));
|
|
746
397
|
return;
|
|
747
398
|
}
|
|
748
399
|
if (t === "content" && typeof n == "string" && !("content:encoded" in r)) {
|
|
749
|
-
|
|
400
|
+
H(e.ele(R, "encoded"), String(n));
|
|
750
401
|
return;
|
|
751
402
|
}
|
|
752
403
|
if (t !== "content") {
|
|
753
404
|
if (t === "media:group" && Array.isArray(n)) {
|
|
754
405
|
for (let t of n) if (t && typeof t == "object") {
|
|
755
|
-
let n = e.ele(
|
|
406
|
+
let n = e.ele(z, "group");
|
|
756
407
|
for (let [e, r] of Object.entries(t)) if (r != null && e.startsWith("media:")) {
|
|
757
408
|
let t = e.slice(6);
|
|
758
409
|
if (Array.isArray(r)) {
|
|
759
410
|
for (let e of r) if (e && typeof e == "object") {
|
|
760
|
-
let r = n.ele(
|
|
761
|
-
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ?
|
|
411
|
+
let r = n.ele(z, t);
|
|
412
|
+
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ? H(r, String(n)) : r.att(t, String(n)));
|
|
762
413
|
}
|
|
763
|
-
} else typeof r == "string" &&
|
|
414
|
+
} else typeof r == "string" && H(n.ele(z, t), r);
|
|
764
415
|
}
|
|
765
416
|
}
|
|
766
417
|
return;
|
|
@@ -771,27 +422,27 @@ function lt(e, t, n, r, i) {
|
|
|
771
422
|
if (typeof t != "object" || !t) continue;
|
|
772
423
|
let n = {}, i = null;
|
|
773
424
|
for (let [e, r] of Object.entries(t)) r != null && (e === "value" ? i = String(r) : n[e] = String(r));
|
|
774
|
-
let a = e.ele(
|
|
775
|
-
i !== null &&
|
|
425
|
+
let a = e.ele(z, r, n);
|
|
426
|
+
i !== null && H(a, i);
|
|
776
427
|
}
|
|
777
428
|
return;
|
|
778
429
|
}
|
|
779
430
|
if (t.startsWith("media:") && typeof n == "string") {
|
|
780
431
|
let r = t.slice(6);
|
|
781
|
-
|
|
432
|
+
H(e.ele(z, r), n);
|
|
782
433
|
return;
|
|
783
434
|
}
|
|
784
435
|
if (n instanceof Date) {
|
|
785
|
-
e.ele(t).txt(
|
|
436
|
+
e.ele(t).txt(V(n));
|
|
786
437
|
return;
|
|
787
438
|
}
|
|
788
|
-
if (t === "author" &&
|
|
789
|
-
|
|
439
|
+
if (t === "author" && U(n)) {
|
|
440
|
+
G(e, n, "author", !0, 0, W(t, i));
|
|
790
441
|
return;
|
|
791
442
|
}
|
|
792
443
|
if (t === "authors" && Array.isArray(n)) {
|
|
793
|
-
let r =
|
|
794
|
-
for (let t of n) if (t &&
|
|
444
|
+
let r = W(t, i);
|
|
445
|
+
for (let t of n) if (t && U(t)) G(e, t, "author", !0, 0, r);
|
|
795
446
|
else {
|
|
796
447
|
let n = typeof t == "string" ? t : t && typeof t == "object" && "name" in t ? `${t.email ?? ""} (${t.name ?? ""})`.trim() || t.name : String(t);
|
|
797
448
|
n && e.ele("author").txt(n);
|
|
@@ -808,137 +459,109 @@ function lt(e, t, n, r, i) {
|
|
|
808
459
|
}
|
|
809
460
|
return;
|
|
810
461
|
}
|
|
811
|
-
if (Array.isArray(n) && n.length > 0 && n.every((e) =>
|
|
812
|
-
let r = t.endsWith("s") ? t.slice(0, -1) : t, a =
|
|
813
|
-
for (let t of n) t &&
|
|
462
|
+
if (Array.isArray(n) && n.length > 0 && n.every((e) => U(e))) {
|
|
463
|
+
let r = t.endsWith("s") ? t.slice(0, -1) : t, a = W(t, i);
|
|
464
|
+
for (let t of n) t && G(e, t, r, !1, 0, a);
|
|
814
465
|
return;
|
|
815
466
|
}
|
|
816
467
|
if (Array.isArray(n) && n.every((e) => typeof e == "string")) {
|
|
817
468
|
let r = t.endsWith("s") ? t.slice(0, -1) : t;
|
|
818
|
-
for (let t of n) t &&
|
|
469
|
+
for (let t of n) t && H(e.ele(r), t);
|
|
819
470
|
return;
|
|
820
471
|
}
|
|
821
|
-
if (
|
|
822
|
-
|
|
472
|
+
if (U(n)) {
|
|
473
|
+
G(e, n, t, !1, 0, W(t, i));
|
|
823
474
|
return;
|
|
824
475
|
}
|
|
825
|
-
|
|
476
|
+
H(e.ele(t), String(n));
|
|
826
477
|
}
|
|
827
478
|
}
|
|
828
479
|
}
|
|
829
|
-
var
|
|
830
|
-
function
|
|
831
|
-
let t =
|
|
480
|
+
var ze = "http://www.w3.org/2005/Atom", Be = "http://purl.org/syndication/history/1.0";
|
|
481
|
+
function Ve(e) {
|
|
482
|
+
let t = oe({
|
|
832
483
|
version: "1.0",
|
|
833
484
|
encoding: "UTF-8"
|
|
834
|
-
}), n =
|
|
835
|
-
"xmlns:dc":
|
|
836
|
-
"xmlns:content":
|
|
837
|
-
"xmlns:media":
|
|
838
|
-
"xmlns:atom":
|
|
485
|
+
}), n = Ie(e.items), r = {
|
|
486
|
+
"xmlns:dc": L,
|
|
487
|
+
"xmlns:content": R,
|
|
488
|
+
"xmlns:media": z,
|
|
489
|
+
"xmlns:atom": ze,
|
|
839
490
|
...Object.values(n).reduce((e, t) => (e[`xmlns:${t.prefix}`] = t.uri, e), {})
|
|
840
491
|
};
|
|
841
|
-
e.isArchive && (r["xmlns:fh"] =
|
|
492
|
+
e.isArchive && (r["xmlns:fh"] = Be);
|
|
842
493
|
let i = t.ele("rss", {
|
|
843
494
|
version: "2.0",
|
|
844
495
|
...r
|
|
845
496
|
}).ele("channel", {
|
|
846
|
-
"xmlns:dc":
|
|
847
|
-
"xmlns:content":
|
|
848
|
-
"xmlns:media":
|
|
497
|
+
"xmlns:dc": L,
|
|
498
|
+
"xmlns:content": R,
|
|
499
|
+
"xmlns:media": z
|
|
849
500
|
});
|
|
850
|
-
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(
|
|
501
|
+
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) {
|
|
851
502
|
let e = {
|
|
852
503
|
rel: t.rel,
|
|
853
504
|
href: t.href
|
|
854
505
|
};
|
|
855
|
-
t.type && (e.type = t.type), i.ele(
|
|
506
|
+
t.type && (e.type = t.type), i.ele(ze, "link", e);
|
|
856
507
|
}
|
|
857
|
-
e.isArchive && i.ele(
|
|
858
|
-
let a = new Set(
|
|
508
|
+
e.isArchive && i.ele(Be, "archive");
|
|
509
|
+
let a = new Set(B);
|
|
859
510
|
for (let t of e.items) {
|
|
860
511
|
let e = i.ele("item"), r = /* @__PURE__ */ new Set();
|
|
861
|
-
for (let i of
|
|
862
|
-
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !
|
|
863
|
-
for (let r of o)
|
|
512
|
+
for (let i of B) i in t && (Re(e, i, t[i], t, n), r.add(i));
|
|
513
|
+
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !Oe(e, t)).sort();
|
|
514
|
+
for (let r of o) Re(e, r, t[r], t, n);
|
|
864
515
|
}
|
|
865
516
|
return t.end({ prettyPrint: !0 });
|
|
866
517
|
}
|
|
867
518
|
//#endregion
|
|
868
519
|
//#region src/cache/types.ts
|
|
869
|
-
function
|
|
520
|
+
function K(e, t, n) {
|
|
870
521
|
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}`;
|
|
871
522
|
}
|
|
872
523
|
//#endregion
|
|
873
524
|
//#region src/utils/etag.ts
|
|
874
|
-
function
|
|
875
|
-
return `"${
|
|
876
|
-
}
|
|
877
|
-
function ht(e, t, n, r) {
|
|
878
|
-
return mt(`${e}-${t}-${n}-${r}`);
|
|
525
|
+
function He(e) {
|
|
526
|
+
return `"${se("md5").update(e).digest("hex").substring(0, 16)}"`;
|
|
879
527
|
}
|
|
880
|
-
function
|
|
881
|
-
return
|
|
528
|
+
function Ue(e, t, n, r) {
|
|
529
|
+
return He(`${e}-${t}-${n}-${r}`);
|
|
882
530
|
}
|
|
883
|
-
function
|
|
531
|
+
function We(e, t) {
|
|
884
532
|
let n = (e) => e.replace(/^"|"$/g, "");
|
|
885
533
|
return n(e) === n(t);
|
|
886
534
|
}
|
|
887
|
-
function
|
|
535
|
+
function Ge(e) {
|
|
888
536
|
return e ? e.split(",").map((e) => e.trim()).filter((e) => e.length > 0) : [];
|
|
889
537
|
}
|
|
890
|
-
function
|
|
891
|
-
let n =
|
|
892
|
-
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) =>
|
|
538
|
+
function Ke(e, t) {
|
|
539
|
+
let n = Ge(e);
|
|
540
|
+
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) => We(e, t));
|
|
893
541
|
}
|
|
894
542
|
//#endregion
|
|
895
543
|
//#region src/cache/MemoryCache.ts
|
|
896
|
-
var
|
|
897
|
-
feedDataCache = /* @__PURE__ */ new Map();
|
|
544
|
+
var qe = class {
|
|
898
545
|
feedContentCache = /* @__PURE__ */ new Map();
|
|
899
546
|
imageMetadataCache = /* @__PURE__ */ new Map();
|
|
900
547
|
config;
|
|
901
|
-
refreshLocks = /* @__PURE__ */ new Map();
|
|
902
548
|
constructor(e) {
|
|
903
549
|
this.config = e;
|
|
904
550
|
}
|
|
905
|
-
getFeedData(e) {
|
|
906
|
-
let t = this.feedDataCache.get(e);
|
|
907
|
-
return t ? Math.floor(Date.now() / 1e3) - t.lastUpdated > this.config.ttl ? (this.feedDataCache.delete(e), this.clearContentCache(e), null) : t : null;
|
|
908
|
-
}
|
|
909
|
-
setFeedData(e, t) {
|
|
910
|
-
let n = Math.floor(Date.now() / 1e3), r = 0, i = "";
|
|
911
|
-
for (let e of t) {
|
|
912
|
-
let t = e.timeCreated;
|
|
913
|
-
t && t > r && (r = t, i = e.id || e.seedUid || e.SeedUid || "");
|
|
914
|
-
}
|
|
915
|
-
r === 0 && (r = n);
|
|
916
|
-
let a = ht(e, "data", r, t.length), o = {
|
|
917
|
-
items: [...t],
|
|
918
|
-
lastProcessedTimestamp: r,
|
|
919
|
-
lastProcessedItemId: i,
|
|
920
|
-
lastUpdated: n,
|
|
921
|
-
etag: a
|
|
922
|
-
};
|
|
923
|
-
this.feedDataCache.set(e, o);
|
|
924
|
-
}
|
|
925
551
|
getFeedContent(e, t, n) {
|
|
926
|
-
let r =
|
|
552
|
+
let r = K(e, t, n), i = this.feedContentCache.get(r);
|
|
927
553
|
return i ? Math.floor(Date.now() / 1e3) > i.expiresAt ? (this.feedContentCache.delete(r), null) : i : null;
|
|
928
554
|
}
|
|
929
555
|
setFeedContent(e, t, n, r, i, a) {
|
|
930
|
-
let o =
|
|
556
|
+
let o = K(e, t, i), s = Math.floor(Date.now() / 1e3), c = s + (a ?? this.config.ttl), l = {
|
|
931
557
|
content: n,
|
|
932
558
|
contentType: r,
|
|
933
|
-
etag:
|
|
559
|
+
etag: Ue(e, t, s, n.length),
|
|
934
560
|
lastModified: s,
|
|
935
561
|
expiresAt: c
|
|
936
562
|
};
|
|
937
563
|
this.feedContentCache.set(o, l);
|
|
938
564
|
}
|
|
939
|
-
clearFeedData(e) {
|
|
940
|
-
this.feedDataCache.delete(e);
|
|
941
|
-
}
|
|
942
565
|
clearContentCache(e) {
|
|
943
566
|
let t = [];
|
|
944
567
|
for (let n of this.feedContentCache.keys()) n.startsWith(`${e}:`) && t.push(n);
|
|
@@ -957,19 +580,7 @@ var bt = class {
|
|
|
957
580
|
this.imageMetadataCache.set(e, r);
|
|
958
581
|
}
|
|
959
582
|
clearAll() {
|
|
960
|
-
this.
|
|
961
|
-
}
|
|
962
|
-
async withRefreshLock(e, t) {
|
|
963
|
-
let n = this.refreshLocks.get(e);
|
|
964
|
-
n && (await n, this.getFeedData(e));
|
|
965
|
-
let r = (async () => {
|
|
966
|
-
try {
|
|
967
|
-
return await t();
|
|
968
|
-
} finally {
|
|
969
|
-
this.refreshLocks.delete(e);
|
|
970
|
-
}
|
|
971
|
-
})();
|
|
972
|
-
return this.refreshLocks.set(e, r), r;
|
|
583
|
+
this.feedContentCache.clear(), this.imageMetadataCache.clear();
|
|
973
584
|
}
|
|
974
585
|
updateConfig(e) {
|
|
975
586
|
this.config = {
|
|
@@ -979,13 +590,11 @@ var bt = class {
|
|
|
979
590
|
}
|
|
980
591
|
getStats() {
|
|
981
592
|
return {
|
|
982
|
-
feedDataCount: this.feedDataCache.size,
|
|
983
593
|
feedContentCount: this.feedContentCache.size,
|
|
984
|
-
imageMetadataCount: this.imageMetadataCache.size
|
|
985
|
-
activeLocks: this.refreshLocks.size
|
|
594
|
+
imageMetadataCount: this.imageMetadataCache.size
|
|
986
595
|
};
|
|
987
596
|
}
|
|
988
|
-
},
|
|
597
|
+
}, Je = class {
|
|
989
598
|
cacheDir;
|
|
990
599
|
config;
|
|
991
600
|
constructor(e) {
|
|
@@ -995,49 +604,29 @@ var bt = class {
|
|
|
995
604
|
}
|
|
996
605
|
async ensureCacheDir() {
|
|
997
606
|
try {
|
|
998
|
-
await
|
|
607
|
+
await w.mkdir(this.cacheDir, { recursive: !0 });
|
|
999
608
|
} catch (e) {
|
|
1000
609
|
if (e.code !== "EEXIST") throw e;
|
|
1001
610
|
}
|
|
1002
611
|
}
|
|
1003
|
-
getFeedDataPath(e) {
|
|
1004
|
-
return C(this.cacheDir, `${e}.json`);
|
|
1005
|
-
}
|
|
1006
612
|
getFeedContentPath(e, t, n) {
|
|
1007
|
-
let r =
|
|
1008
|
-
return
|
|
613
|
+
let r = K(e, t, n).replace(/:/g, "-");
|
|
614
|
+
return T(this.cacheDir, `${r}.json`);
|
|
1009
615
|
}
|
|
1010
616
|
getImageMetadataPath(e) {
|
|
1011
|
-
return
|
|
617
|
+
return T(T(this.cacheDir, "image-metadata"), `${e}.json`);
|
|
1012
618
|
}
|
|
1013
619
|
async ensureImageMetadataDir() {
|
|
1014
620
|
try {
|
|
1015
|
-
let e =
|
|
1016
|
-
await
|
|
621
|
+
let e = T(this.cacheDir, "image-metadata");
|
|
622
|
+
await w.mkdir(e, { recursive: !0 });
|
|
1017
623
|
} catch (e) {
|
|
1018
624
|
if (e.code !== "EEXIST") throw e;
|
|
1019
625
|
}
|
|
1020
626
|
}
|
|
1021
|
-
async getFeedData(e) {
|
|
1022
|
-
try {
|
|
1023
|
-
let t = this.getFeedDataPath(e), n = await S.readFile(t, "utf-8"), r = JSON.parse(n);
|
|
1024
|
-
return Math.floor(Date.now() / 1e3) - r.lastUpdated > this.config.ttl ? (await this.clearFeedData(e), null) : r;
|
|
1025
|
-
} catch (t) {
|
|
1026
|
-
return t.code === "ENOENT" || console.error(`Error reading feed data cache for ${e}:`, t), null;
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
async setFeedData(e, t) {
|
|
1030
|
-
try {
|
|
1031
|
-
await this.ensureCacheDir();
|
|
1032
|
-
let n = this.getFeedDataPath(e);
|
|
1033
|
-
await S.writeFile(n, JSON.stringify(t, null, 2), "utf-8");
|
|
1034
|
-
} catch (t) {
|
|
1035
|
-
console.error(`Error writing feed data cache for ${e}:`, t);
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
627
|
async getFeedContent(e, t, n) {
|
|
1039
628
|
try {
|
|
1040
|
-
let r = this.getFeedContentPath(e, t, n), i = await
|
|
629
|
+
let r = this.getFeedContentPath(e, t, n), i = await w.readFile(r, "utf-8"), a = JSON.parse(i);
|
|
1041
630
|
return Math.floor(Date.now() / 1e3) > a.expiresAt ? (await this.clearFeedContent(e, t, n), null) : a;
|
|
1042
631
|
} catch (n) {
|
|
1043
632
|
return n.code === "ENOENT" || console.error(`Error reading feed content cache for ${e}:${t}:`, n), null;
|
|
@@ -1047,38 +636,30 @@ var bt = class {
|
|
|
1047
636
|
try {
|
|
1048
637
|
await this.ensureCacheDir();
|
|
1049
638
|
let i = this.getFeedContentPath(e, t, r);
|
|
1050
|
-
await
|
|
639
|
+
await w.writeFile(i, JSON.stringify(n, null, 2), "utf-8");
|
|
1051
640
|
} catch (n) {
|
|
1052
641
|
console.error(`Error writing feed content cache for ${e}:${t}:`, n);
|
|
1053
642
|
}
|
|
1054
643
|
}
|
|
1055
|
-
async clearFeedData(e) {
|
|
1056
|
-
try {
|
|
1057
|
-
let t = this.getFeedDataPath(e);
|
|
1058
|
-
await S.unlink(t);
|
|
1059
|
-
} catch (t) {
|
|
1060
|
-
t.code !== "ENOENT" && console.error(`Error clearing feed data cache for ${e}:`, t);
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
644
|
async clearFeedContent(e, t, n) {
|
|
1064
645
|
try {
|
|
1065
646
|
let r = this.getFeedContentPath(e, t, n);
|
|
1066
|
-
await
|
|
647
|
+
await w.unlink(r);
|
|
1067
648
|
} catch (n) {
|
|
1068
649
|
n.code !== "ENOENT" && console.error(`Error clearing feed content cache for ${e}:${t}:`, n);
|
|
1069
650
|
}
|
|
1070
651
|
}
|
|
1071
652
|
async clearAllContentCache(e) {
|
|
1072
653
|
try {
|
|
1073
|
-
let t = await
|
|
1074
|
-
for (let r of t) r.startsWith(n) && r.endsWith(".json") && r !== `${e}.json` && await
|
|
654
|
+
let t = await w.readdir(this.cacheDir), n = `${e}-`;
|
|
655
|
+
for (let r of t) r.startsWith(n) && r.endsWith(".json") && r !== `${e}.json` && await w.unlink(T(this.cacheDir, r));
|
|
1075
656
|
} catch (t) {
|
|
1076
657
|
console.error(`Error clearing all content cache for ${e}:`, t);
|
|
1077
658
|
}
|
|
1078
659
|
}
|
|
1079
660
|
async getImageMetadata(e) {
|
|
1080
661
|
try {
|
|
1081
|
-
let t = this.getImageMetadataPath(e), n = await
|
|
662
|
+
let t = this.getImageMetadataPath(e), n = await w.readFile(t, "utf-8"), r = JSON.parse(n);
|
|
1082
663
|
return Math.floor(Date.now() / 1e3) > r.expiresAt ? (await this.clearImageMetadata(e), null) : r.metadata;
|
|
1083
664
|
} catch (t) {
|
|
1084
665
|
return t.code === "ENOENT" || console.error(`Error reading image metadata cache for ${e}:`, t), null;
|
|
@@ -1092,7 +673,7 @@ var bt = class {
|
|
|
1092
673
|
cachedAt: r,
|
|
1093
674
|
expiresAt: r + (this.config.imageMetadata?.ttl || 604800)
|
|
1094
675
|
};
|
|
1095
|
-
await
|
|
676
|
+
await w.writeFile(n, JSON.stringify(i, null, 2), "utf-8");
|
|
1096
677
|
} catch (t) {
|
|
1097
678
|
console.error(`Error writing image metadata cache for ${e}:`, t);
|
|
1098
679
|
}
|
|
@@ -1100,25 +681,25 @@ var bt = class {
|
|
|
1100
681
|
async clearImageMetadata(e) {
|
|
1101
682
|
try {
|
|
1102
683
|
let t = this.getImageMetadataPath(e);
|
|
1103
|
-
await
|
|
684
|
+
await w.unlink(t);
|
|
1104
685
|
} catch (t) {
|
|
1105
686
|
t.code !== "ENOENT" && console.error(`Error clearing image metadata cache for ${e}:`, t);
|
|
1106
687
|
}
|
|
1107
688
|
}
|
|
1108
689
|
async clearAll() {
|
|
1109
690
|
try {
|
|
1110
|
-
let e = await
|
|
1111
|
-
for (let t of e) t.endsWith(".json") && await
|
|
1112
|
-
let t =
|
|
691
|
+
let e = await w.readdir(this.cacheDir);
|
|
692
|
+
for (let t of e) t.endsWith(".json") && t.includes("-") && await w.unlink(T(this.cacheDir, t));
|
|
693
|
+
let t = T(this.cacheDir, "image-metadata");
|
|
1113
694
|
try {
|
|
1114
|
-
let e = await
|
|
1115
|
-
for (let n of e) n.endsWith(".json") && await
|
|
695
|
+
let e = await w.readdir(t);
|
|
696
|
+
for (let n of e) n.endsWith(".json") && await w.unlink(T(t, n));
|
|
1116
697
|
} catch {}
|
|
1117
698
|
} catch (e) {
|
|
1118
699
|
console.error("Error clearing all caches:", e);
|
|
1119
700
|
}
|
|
1120
701
|
}
|
|
1121
|
-
},
|
|
702
|
+
}, Ye = class {
|
|
1122
703
|
memoryCache;
|
|
1123
704
|
fileCache;
|
|
1124
705
|
config;
|
|
@@ -1129,25 +710,7 @@ var bt = class {
|
|
|
1129
710
|
errors: 0
|
|
1130
711
|
};
|
|
1131
712
|
constructor(e) {
|
|
1132
|
-
this.config = e, this.memoryCache = new
|
|
1133
|
-
}
|
|
1134
|
-
async getFeedData(e) {
|
|
1135
|
-
if (!this.config.enabled) return null;
|
|
1136
|
-
try {
|
|
1137
|
-
let t = this.memoryCache.getFeedData(e);
|
|
1138
|
-
return t ? (this.stats.hits++, t) : (t = await this.fileCache.getFeedData(e), t ? (this.memoryCache.setFeedData(e, t.items), this.stats.hits++, t) : (this.stats.misses++, null));
|
|
1139
|
-
} catch (t) {
|
|
1140
|
-
return console.error(`Error getting feed data cache for ${e}:`, t), this.stats.errors++, null;
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
async setFeedData(e, t) {
|
|
1144
|
-
if (this.config.enabled) try {
|
|
1145
|
-
this.memoryCache.setFeedData(e, t);
|
|
1146
|
-
let n = this.memoryCache.getFeedData(e);
|
|
1147
|
-
n && await this.fileCache.setFeedData(e, n);
|
|
1148
|
-
} catch (t) {
|
|
1149
|
-
console.error(`Error setting feed data cache for ${e}:`, t), this.stats.errors++;
|
|
1150
|
-
}
|
|
713
|
+
this.config = e, this.memoryCache = new qe(e), this.fileCache = new Je(e);
|
|
1151
714
|
}
|
|
1152
715
|
async getFeedContent(e, t, n) {
|
|
1153
716
|
if (!this.config.enabled) return null;
|
|
@@ -1168,37 +731,12 @@ var bt = class {
|
|
|
1168
731
|
console.error(`Error setting feed content cache for ${e}:${t}:`, n), this.stats.errors++;
|
|
1169
732
|
}
|
|
1170
733
|
}
|
|
1171
|
-
async
|
|
1172
|
-
this.memoryCache.
|
|
734
|
+
async clearContent(e) {
|
|
735
|
+
this.memoryCache.clearContentCache(e), await this.fileCache.clearAllContentCache(e);
|
|
1173
736
|
}
|
|
1174
737
|
async clearAll() {
|
|
1175
738
|
this.memoryCache.clearAll(), await this.fileCache.clearAll();
|
|
1176
739
|
}
|
|
1177
|
-
async withRefreshLock(e, t) {
|
|
1178
|
-
return this.memoryCache.withRefreshLock(e, t);
|
|
1179
|
-
}
|
|
1180
|
-
mergeItems(e, t) {
|
|
1181
|
-
let n = /* @__PURE__ */ new Map();
|
|
1182
|
-
for (let t of e) {
|
|
1183
|
-
let e = t.id || t.seedUid || t.SeedUid || "";
|
|
1184
|
-
e && n.set(e, t);
|
|
1185
|
-
}
|
|
1186
|
-
for (let e of t) {
|
|
1187
|
-
let t = e.id || e.seedUid || e.SeedUid || "";
|
|
1188
|
-
t ? n.set(t, e) : n.set(`temp-${Date.now()}-${Math.random()}`, e);
|
|
1189
|
-
}
|
|
1190
|
-
let r = Array.from(n.values());
|
|
1191
|
-
return r.sort((e, t) => {
|
|
1192
|
-
let n = e.timeCreated || 0;
|
|
1193
|
-
return (t.timeCreated || 0) - n;
|
|
1194
|
-
}), r;
|
|
1195
|
-
}
|
|
1196
|
-
filterNewItems(e, t) {
|
|
1197
|
-
return e.filter((e) => {
|
|
1198
|
-
let n = e.timeCreated;
|
|
1199
|
-
return n && n > t;
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1202
740
|
updateConfig(e) {
|
|
1203
741
|
this.config = {
|
|
1204
742
|
...this.config,
|
|
@@ -1238,17 +776,17 @@ var bt = class {
|
|
|
1238
776
|
};
|
|
1239
777
|
//#endregion
|
|
1240
778
|
//#region src/cache/config.ts
|
|
1241
|
-
function
|
|
1242
|
-
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",
|
|
1243
|
-
s = r ? !1 : i ? !0 : !
|
|
779
|
+
function q() {
|
|
780
|
+
let t = parseInt(process.env.CACHE_TTL || "3600", 10), n = process.env.CACHE_DIR || "./cache", r = process.env.CACHE_ENABLED === "false" || process.env.CACHE_ENABLED === "0" || process.env.CACHE_ENABLED === "no" || process.env.CACHE_ENABLED === "off", i = process.env.CACHE_ENABLED === "true" || process.env.CACHE_ENABLED === "1" || process.env.CACHE_ENABLED === "yes", a = process.env.NODE_ENV === "development", s;
|
|
781
|
+
s = r ? !1 : i ? !0 : !a;
|
|
1244
782
|
let c = process.env.CACHE_BACKGROUND_REFRESH === "true", l = parseInt(process.env.CACHE_REFRESH_INTERVAL || "300", 10);
|
|
1245
|
-
s || console.log(`⚠️ Cache is DISABLED (${r ? "CACHE_ENABLED=false" :
|
|
783
|
+
s || console.log(`⚠️ Cache is DISABLED (${r ? "CACHE_ENABLED=false" : a ? "NODE_ENV=development" : "CACHE_ENABLED=false"})`);
|
|
1246
784
|
let u = {
|
|
1247
785
|
enabled: process.env.IMAGE_METADATA_ENABLED !== "false",
|
|
1248
786
|
ttl: parseInt(process.env.IMAGE_METADATA_TTL || "604800", 10),
|
|
1249
|
-
gateways: process.env.IMAGE_METADATA_GATEWAYS ? process.env.IMAGE_METADATA_GATEWAYS.split(",").map((e) => e.trim()) :
|
|
787
|
+
gateways: process.env.IMAGE_METADATA_GATEWAYS ? process.env.IMAGE_METADATA_GATEWAYS.split(",").map((e) => e.trim()) : o(p() ?? e.getHost()),
|
|
1250
788
|
timeout: parseInt(process.env.IMAGE_METADATA_TIMEOUT || "5000", 10)
|
|
1251
|
-
}, d = parseInt(process.env.CACHE_PAGE_TTL || "300", 10),
|
|
789
|
+
}, d = parseInt(process.env.CACHE_PAGE_TTL || "300", 10), f = parseInt(process.env.CACHE_ARCHIVE_TTL || "86400", 10);
|
|
1252
790
|
return {
|
|
1253
791
|
ttl: t,
|
|
1254
792
|
cacheDir: n,
|
|
@@ -1257,22 +795,22 @@ function Ct() {
|
|
|
1257
795
|
refreshInterval: l,
|
|
1258
796
|
imageMetadata: u,
|
|
1259
797
|
pageTtl: d,
|
|
1260
|
-
archiveTtl:
|
|
798
|
+
archiveTtl: f
|
|
1261
799
|
};
|
|
1262
800
|
}
|
|
1263
801
|
//#endregion
|
|
1264
802
|
//#region src/services/arweaveImageService.ts
|
|
1265
|
-
var
|
|
803
|
+
var Xe = class {
|
|
1266
804
|
config;
|
|
1267
805
|
constructor(e) {
|
|
1268
806
|
this.config = e;
|
|
1269
807
|
}
|
|
1270
808
|
async detectImage(t) {
|
|
1271
|
-
let n =
|
|
1272
|
-
(!n || n.activePath !== "hyper-sidecar") && await
|
|
1273
|
-
let r = n ?
|
|
809
|
+
let n = u();
|
|
810
|
+
(!n || n.activePath !== "hyper-sidecar" && n.activePath !== "http-proxy") && await a().catch(() => {});
|
|
811
|
+
let r = n ? l(n, s()) : this.config.gateways?.length ? this.config.gateways : o(e.getHost()), i = n?.arweaveProtocol ?? "https";
|
|
1274
812
|
for (let e of r) try {
|
|
1275
|
-
let n = `${
|
|
813
|
+
let n = `${i}://${e.trim().replace(/\/$/, "")}/${t}`, r = await this.getImageMetadata(n);
|
|
1276
814
|
if (r.isImage) return r;
|
|
1277
815
|
} catch (n) {
|
|
1278
816
|
console.warn(`Failed to fetch from gateway ${e} for transaction ${t}:`, n);
|
|
@@ -1280,7 +818,7 @@ var wt = class {
|
|
|
1280
818
|
}
|
|
1281
819
|
return {
|
|
1282
820
|
isImage: !1,
|
|
1283
|
-
url: `${
|
|
821
|
+
url: `${i}://${r[0]?.trim() || e.getHost()}/${t}`
|
|
1284
822
|
};
|
|
1285
823
|
}
|
|
1286
824
|
async getImageMetadata(e) {
|
|
@@ -1345,7 +883,7 @@ var wt = class {
|
|
|
1345
883
|
}
|
|
1346
884
|
extractImageDimensions(e, t) {
|
|
1347
885
|
try {
|
|
1348
|
-
let t =
|
|
886
|
+
let t = ce(e);
|
|
1349
887
|
if (t.width && t.height) return {
|
|
1350
888
|
width: t.width,
|
|
1351
889
|
height: t.height
|
|
@@ -1367,7 +905,7 @@ var wt = class {
|
|
|
1367
905
|
}
|
|
1368
906
|
}
|
|
1369
907
|
try {
|
|
1370
|
-
let e =
|
|
908
|
+
let e = ce(t);
|
|
1371
909
|
if (e.type) return e.type.toLowerCase();
|
|
1372
910
|
} catch {}
|
|
1373
911
|
}
|
|
@@ -1386,28 +924,28 @@ var wt = class {
|
|
|
1386
924
|
};
|
|
1387
925
|
//#endregion
|
|
1388
926
|
//#region src/pickFeedItemRichText.ts
|
|
1389
|
-
function
|
|
927
|
+
function J(e, t) {
|
|
1390
928
|
for (let n of t) {
|
|
1391
929
|
let t = e[n];
|
|
1392
930
|
if (typeof t == "string" && t.trim() !== "") return t;
|
|
1393
931
|
}
|
|
1394
932
|
return "";
|
|
1395
933
|
}
|
|
1396
|
-
var
|
|
934
|
+
var Ze = [
|
|
1397
935
|
"summary",
|
|
1398
936
|
"Summary",
|
|
1399
937
|
"description",
|
|
1400
938
|
"Description",
|
|
1401
939
|
"text",
|
|
1402
940
|
"Text"
|
|
1403
|
-
],
|
|
941
|
+
], Qe = [
|
|
1404
942
|
"html",
|
|
1405
943
|
"Html",
|
|
1406
944
|
"body",
|
|
1407
945
|
"Body",
|
|
1408
946
|
"content",
|
|
1409
947
|
"Content"
|
|
1410
|
-
],
|
|
948
|
+
], $e = [
|
|
1411
949
|
"summary",
|
|
1412
950
|
"Summary",
|
|
1413
951
|
"description",
|
|
@@ -1415,16 +953,16 @@ var Et = [
|
|
|
1415
953
|
"text",
|
|
1416
954
|
"Text"
|
|
1417
955
|
];
|
|
1418
|
-
function
|
|
1419
|
-
let n =
|
|
956
|
+
function et(e, t) {
|
|
957
|
+
let n = y(e.model) - y(t.model);
|
|
1420
958
|
if (n !== 0) return n;
|
|
1421
959
|
let r = e.key.localeCompare(t.key);
|
|
1422
960
|
return r === 0 ? e.index - t.index : r;
|
|
1423
961
|
}
|
|
1424
|
-
function
|
|
1425
|
-
let t =
|
|
962
|
+
function tt(e) {
|
|
963
|
+
let t = x(e), n = ee(e), r = null;
|
|
1426
964
|
if (t) for (let [n, i] of Object.entries(t)) {
|
|
1427
|
-
if (!
|
|
965
|
+
if (!S(i)) continue;
|
|
1428
966
|
let t = e[n];
|
|
1429
967
|
if (typeof t != "string" || t.trim() === "") continue;
|
|
1430
968
|
let a = {
|
|
@@ -1433,7 +971,7 @@ function At(e) {
|
|
|
1433
971
|
index: 0,
|
|
1434
972
|
value: t
|
|
1435
973
|
};
|
|
1436
|
-
(!r ||
|
|
974
|
+
(!r || et(a, r) < 0) && (r = a);
|
|
1437
975
|
}
|
|
1438
976
|
if (n) for (let [t, i] of Object.entries(n)) {
|
|
1439
977
|
let n = e[t];
|
|
@@ -1441,7 +979,7 @@ function At(e) {
|
|
|
1441
979
|
let a = Math.min(i.length, n.length);
|
|
1442
980
|
for (let e = 0; e < a; e++) {
|
|
1443
981
|
let a = i[e];
|
|
1444
|
-
if (!
|
|
982
|
+
if (!S(a)) continue;
|
|
1445
983
|
let o = n[e];
|
|
1446
984
|
if (typeof o != "string" || o.trim() === "") continue;
|
|
1447
985
|
let s = {
|
|
@@ -1450,102 +988,83 @@ function At(e) {
|
|
|
1450
988
|
index: e,
|
|
1451
989
|
value: o
|
|
1452
990
|
};
|
|
1453
|
-
(!r ||
|
|
991
|
+
(!r || et(s, r) < 0) && (r = s);
|
|
1454
992
|
}
|
|
1455
993
|
}
|
|
1456
994
|
return r?.value ?? "";
|
|
1457
995
|
}
|
|
1458
|
-
function
|
|
1459
|
-
return
|
|
996
|
+
function nt(e) {
|
|
997
|
+
return J(e, Ze);
|
|
1460
998
|
}
|
|
1461
|
-
function
|
|
1462
|
-
let t =
|
|
999
|
+
function rt(e) {
|
|
1000
|
+
let t = tt(e);
|
|
1463
1001
|
if (t !== "") return t;
|
|
1464
|
-
let n =
|
|
1465
|
-
return n === "" ?
|
|
1002
|
+
let n = J(e, Qe);
|
|
1003
|
+
return n === "" ? J(e, $e) : n;
|
|
1466
1004
|
}
|
|
1467
|
-
function
|
|
1005
|
+
function Y(e) {
|
|
1468
1006
|
return typeof e == "string" ? e.includes("data:image/") && e.includes(";base64,") : !1;
|
|
1469
1007
|
}
|
|
1470
|
-
function
|
|
1471
|
-
let t =
|
|
1008
|
+
function it(e) {
|
|
1009
|
+
let t = x(e);
|
|
1472
1010
|
if (t) {
|
|
1473
|
-
for (let [n, r] of Object.entries(t)) if (
|
|
1011
|
+
for (let [n, r] of Object.entries(t)) if (S(r) && Y(e[n])) return !0;
|
|
1474
1012
|
}
|
|
1475
|
-
let n =
|
|
1013
|
+
let n = ee(e);
|
|
1476
1014
|
if (n) for (let [t, r] of Object.entries(n)) {
|
|
1477
1015
|
let n = e[t];
|
|
1478
1016
|
if (!Array.isArray(n)) continue;
|
|
1479
1017
|
let i = Math.min(r.length, n.length);
|
|
1480
|
-
for (let e = 0; e < i; e++) if (
|
|
1018
|
+
for (let e = 0; e < i; e++) if (S(r[e]) && Y(n[e])) return !0;
|
|
1481
1019
|
}
|
|
1482
1020
|
return !1;
|
|
1483
1021
|
}
|
|
1484
|
-
function
|
|
1485
|
-
if (
|
|
1486
|
-
for (let t of
|
|
1487
|
-
for (let t of
|
|
1022
|
+
function X(e) {
|
|
1023
|
+
if (it(e)) return !0;
|
|
1024
|
+
for (let t of Qe) if (Y(e[t])) return !0;
|
|
1025
|
+
for (let t of Ze) if (Y(e[t])) return !0;
|
|
1488
1026
|
return !1;
|
|
1489
1027
|
}
|
|
1490
|
-
function
|
|
1491
|
-
return t === "include_items" ? [...e] : e.filter((e) => !
|
|
1028
|
+
function at(e, t = "omit_items") {
|
|
1029
|
+
return t === "include_items" ? [...e] : e.filter((e) => !X(e));
|
|
1492
1030
|
}
|
|
1493
1031
|
//#endregion
|
|
1494
1032
|
//#region src/index.ts
|
|
1495
|
-
function
|
|
1496
|
-
|
|
1497
|
-
if (typeof e == "string") {
|
|
1498
|
-
if (e.startsWith("http://") || e.startsWith("https://")) return e;
|
|
1499
|
-
try {
|
|
1500
|
-
return E(e);
|
|
1501
|
-
} catch {
|
|
1502
|
-
return;
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
if (typeof e == "object" && !Array.isArray(e)) {
|
|
1506
|
-
let t = e, n = t.arweaveUrl;
|
|
1507
|
-
if (typeof n == "string" && n.trim()) return n.trim();
|
|
1508
|
-
let r = t.storageTransactionId ?? t.storage_transaction_id;
|
|
1509
|
-
if (r && typeof r == "string" && r.trim()) try {
|
|
1510
|
-
return E(r.trim());
|
|
1511
|
-
} catch {
|
|
1512
|
-
return;
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1033
|
+
function ot(e) {
|
|
1034
|
+
return g(e)?.mediaUrl;
|
|
1516
1035
|
}
|
|
1517
|
-
function
|
|
1036
|
+
function Z(e) {
|
|
1518
1037
|
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e;
|
|
1519
1038
|
if (typeof e == "string") {
|
|
1520
1039
|
let t = Number(e);
|
|
1521
1040
|
if (Number.isFinite(t) && t > 0) return t;
|
|
1522
1041
|
}
|
|
1523
1042
|
}
|
|
1524
|
-
function
|
|
1043
|
+
function st(e) {
|
|
1525
1044
|
if (Array.isArray(e)) {
|
|
1526
1045
|
for (let t of e) {
|
|
1527
|
-
let e =
|
|
1046
|
+
let e = st(t);
|
|
1528
1047
|
if (e) return e;
|
|
1529
1048
|
}
|
|
1530
1049
|
return;
|
|
1531
1050
|
}
|
|
1532
|
-
let t =
|
|
1051
|
+
let t = ot(e);
|
|
1533
1052
|
if (t) {
|
|
1534
1053
|
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
1535
1054
|
let n = e;
|
|
1536
1055
|
return {
|
|
1537
1056
|
url: t,
|
|
1538
1057
|
mimeType: typeof n.mimeType == "string" && n.mimeType || typeof n.type == "string" && n.type || typeof n.contentType == "string" && n.contentType || void 0,
|
|
1539
|
-
width:
|
|
1540
|
-
height:
|
|
1541
|
-
size:
|
|
1058
|
+
width: Z(n.width),
|
|
1059
|
+
height: Z(n.height),
|
|
1060
|
+
size: Z(n.size ?? n.fileSize),
|
|
1542
1061
|
format: typeof n.format == "string" ? n.format : void 0
|
|
1543
1062
|
};
|
|
1544
1063
|
}
|
|
1545
1064
|
return { url: t };
|
|
1546
1065
|
}
|
|
1547
1066
|
}
|
|
1548
|
-
function
|
|
1067
|
+
function ct(e) {
|
|
1549
1068
|
if (e._hasImage && e._imageMetadata && typeof e._imageMetadata == "object") {
|
|
1550
1069
|
let t = e._imageMetadata;
|
|
1551
1070
|
if (t.url) return {
|
|
@@ -1569,11 +1088,11 @@ function zt(e) {
|
|
|
1569
1088
|
"thumbnailImage"
|
|
1570
1089
|
]) {
|
|
1571
1090
|
if (!(t in e)) continue;
|
|
1572
|
-
let n =
|
|
1091
|
+
let n = st(e[t]);
|
|
1573
1092
|
if (n) return n;
|
|
1574
1093
|
}
|
|
1575
1094
|
}
|
|
1576
|
-
function
|
|
1095
|
+
function lt(e, t, n, r, i, a) {
|
|
1577
1096
|
let o = n.mimeType || "image/jpeg";
|
|
1578
1097
|
e.enclosures = [{
|
|
1579
1098
|
url: n.url,
|
|
@@ -1609,14 +1128,14 @@ function Bt(e, t, n, r, i, a) {
|
|
|
1609
1128
|
"media:description": l
|
|
1610
1129
|
}], 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}`);
|
|
1611
1130
|
}
|
|
1612
|
-
var
|
|
1613
|
-
function
|
|
1614
|
-
return
|
|
1131
|
+
var Q = null;
|
|
1132
|
+
function ut() {
|
|
1133
|
+
return Q ||= new Ye(q()), Q;
|
|
1615
1134
|
}
|
|
1616
|
-
function
|
|
1617
|
-
|
|
1135
|
+
function dt() {
|
|
1136
|
+
Q = null;
|
|
1618
1137
|
}
|
|
1619
|
-
async function
|
|
1138
|
+
async function ft(e, t, n) {
|
|
1620
1139
|
let r = e.filter((e) => e.storageTransactionId || e.storage_transaction_id);
|
|
1621
1140
|
if (r.length === 0) return e;
|
|
1622
1141
|
console.log(`Enriching ${r.length} items with image metadata`);
|
|
@@ -1638,10 +1157,10 @@ async function Wt(e, t, n) {
|
|
|
1638
1157
|
return o.get(t) || e;
|
|
1639
1158
|
});
|
|
1640
1159
|
}
|
|
1641
|
-
function
|
|
1160
|
+
function pt(e, t) {
|
|
1642
1161
|
let { schemaName: n, siteUrl: r, itemUrlBase: i, itemUrlPath: a, richTextDataUriImages: o = "omit_items" } = t;
|
|
1643
|
-
return
|
|
1644
|
-
let t = e.id || e.seedUid || e.SeedUid || e.storageTransactionId || e.storage_transaction_id, o = i == null ? `${r}/${
|
|
1162
|
+
return at(e, o).map((e) => {
|
|
1163
|
+
let t = e.id || e.seedUid || e.SeedUid || e.storageTransactionId || e.storage_transaction_id, o = i == null ? `${r}/${C(n)}/${t}` : `${i.replace(/\/$/, "")}/${(a ?? "attestation/view").replace(/^\//, "")}/${t}`, s = e.link || e.Link || e.import_url || e.importUrl || o, c;
|
|
1645
1164
|
if (e.pubDate || e.PubDate) {
|
|
1646
1165
|
let t = e.pubDate || e.PubDate;
|
|
1647
1166
|
c = new Date(t);
|
|
@@ -1650,7 +1169,7 @@ function Gt(e, t) {
|
|
|
1650
1169
|
let t = e.publishedAt || e.createdAt || e.updatedAt;
|
|
1651
1170
|
c = t && typeof t == "object" && t.constructor === Date ? t : new Date(t);
|
|
1652
1171
|
} else c = /* @__PURE__ */ new Date();
|
|
1653
|
-
let l =
|
|
1172
|
+
let l = nt(e), u = rt(e), d = {
|
|
1654
1173
|
...e,
|
|
1655
1174
|
id: t,
|
|
1656
1175
|
title: e.title || e.Title || "Untitled",
|
|
@@ -1670,8 +1189,8 @@ function Gt(e, t) {
|
|
|
1670
1189
|
}), d;
|
|
1671
1190
|
});
|
|
1672
1191
|
}
|
|
1673
|
-
var
|
|
1674
|
-
let l =
|
|
1192
|
+
var $ = (e, t, n, r, i, a, o, s, c) => {
|
|
1193
|
+
let l = j(c), u = C(t), d = `${l.feedUrl}/${u}/${n}`, f = r ? `${d}?v=${r}` : d, p = `${l.title} - ${gt(u)}`, m = /* @__PURE__ */ new Date(), h = M(), g = [];
|
|
1675
1194
|
if (i) {
|
|
1676
1195
|
let e = i.baseUrl.replace(/\?.*$/, ""), t = e.includes("?") ? "&" : "?";
|
|
1677
1196
|
i.hasNext && g.push({
|
|
@@ -1689,7 +1208,7 @@ var Kt = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1689
1208
|
rel: e.rel,
|
|
1690
1209
|
href: e.href
|
|
1691
1210
|
});
|
|
1692
|
-
let _ =
|
|
1211
|
+
let _ = pt(e, {
|
|
1693
1212
|
schemaName: t,
|
|
1694
1213
|
siteUrl: l.siteUrl,
|
|
1695
1214
|
itemUrlBase: h.itemUrlBase,
|
|
@@ -1745,10 +1264,10 @@ var Kt = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1745
1264
|
return t;
|
|
1746
1265
|
})
|
|
1747
1266
|
};
|
|
1748
|
-
return Promise.resolve(
|
|
1267
|
+
return Promise.resolve(ie(t));
|
|
1749
1268
|
}
|
|
1750
1269
|
case "json": {
|
|
1751
|
-
let e = i?.hasNext ? `${i.baseUrl.replace(/\?.*$/, "")}?page=${i.page + 1}` : void 0, t =
|
|
1270
|
+
let e = i?.hasNext ? `${i.baseUrl.replace(/\?.*$/, "")}?page=${i.page + 1}` : void 0, t = ae({
|
|
1752
1271
|
title: p,
|
|
1753
1272
|
home_page_url: l.siteUrl,
|
|
1754
1273
|
feed_url: f,
|
|
@@ -1802,26 +1321,26 @@ var Kt = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1802
1321
|
value: e.id,
|
|
1803
1322
|
isPermaLink: typeof e.id == "string" && (e.id.startsWith("http://") || e.id.startsWith("https://"))
|
|
1804
1323
|
});
|
|
1805
|
-
let r =
|
|
1806
|
-
if (r &&
|
|
1324
|
+
let r = ct(e);
|
|
1325
|
+
if (r && lt(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) {
|
|
1807
1326
|
let t = /* @__PURE__ */ new Date(e.timeCreated * 1e3);
|
|
1808
1327
|
n.dc.dates || (n.dc.dates = []), n.dc.dates.push(t);
|
|
1809
1328
|
}
|
|
1810
1329
|
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;
|
|
1811
1330
|
})
|
|
1812
1331
|
};
|
|
1813
|
-
return Promise.resolve(
|
|
1332
|
+
return Promise.resolve(Ve(e));
|
|
1814
1333
|
}
|
|
1815
1334
|
}
|
|
1816
1335
|
};
|
|
1817
|
-
function
|
|
1336
|
+
function mt(e) {
|
|
1818
1337
|
switch (e) {
|
|
1819
1338
|
case "atom": return "application/atom+xml; charset=utf-8";
|
|
1820
1339
|
case "json": return "application/feed+json; charset=utf-8";
|
|
1821
1340
|
default: return "application/rss+xml; charset=utf-8";
|
|
1822
1341
|
}
|
|
1823
1342
|
}
|
|
1824
|
-
function
|
|
1343
|
+
function ht(e) {
|
|
1825
1344
|
let t = e.toLowerCase();
|
|
1826
1345
|
return [
|
|
1827
1346
|
"rss",
|
|
@@ -1829,22 +1348,22 @@ function Jt(e) {
|
|
|
1829
1348
|
"json"
|
|
1830
1349
|
].includes(t) ? t : null;
|
|
1831
1350
|
}
|
|
1832
|
-
function
|
|
1351
|
+
function gt(e) {
|
|
1833
1352
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1834
1353
|
}
|
|
1835
|
-
async function
|
|
1836
|
-
let o =
|
|
1354
|
+
async function _t(e, t, n, r, i, a) {
|
|
1355
|
+
let o = ht(t);
|
|
1837
1356
|
if (!o) return new Response(JSON.stringify({ error: `Invalid feed format: ${t}` }), {
|
|
1838
1357
|
status: 400,
|
|
1839
1358
|
headers: { "Content-Type": "application/json" }
|
|
1840
1359
|
});
|
|
1841
|
-
let s =
|
|
1360
|
+
let s = C.singular(e.toLowerCase()), c = C(s), l = j(a), u = M(), d = Math.max(1, i ?? 1), f = u.pageSize, p = (d - 1) * f, m = d > 1 ? { page: d } : void 0;
|
|
1842
1361
|
console.log(`Schema name: ${s}`), console.log(`Collection name: ${c}`);
|
|
1843
|
-
let h =
|
|
1362
|
+
let h = ut(), g = q();
|
|
1844
1363
|
try {
|
|
1845
1364
|
if (g.enabled) {
|
|
1846
1365
|
let e = await h.getFeedContent(s, o, m);
|
|
1847
|
-
if (e) return n &&
|
|
1366
|
+
if (e) return n && Ke(n, e.etag) ? (console.log(`Cache hit with ETag match for ${s}:${o} - returning 304`), new Response(null, {
|
|
1848
1367
|
status: 304,
|
|
1849
1368
|
headers: {
|
|
1850
1369
|
ETag: e.etag,
|
|
@@ -1865,37 +1384,12 @@ async function Xt(e, t, n, r, i, a) {
|
|
|
1865
1384
|
}));
|
|
1866
1385
|
}
|
|
1867
1386
|
console.log(`Cache miss for ${s}:${o} - fetching items`);
|
|
1868
|
-
let e =
|
|
1869
|
-
let e = await
|
|
1870
|
-
if (e) {
|
|
1871
|
-
console.log(`Incremental fetch: last processed timestamp: ${e.lastProcessedTimestamp}`);
|
|
1872
|
-
let n = await G(s, {
|
|
1873
|
-
limit: f,
|
|
1874
|
-
skip: 0
|
|
1875
|
-
}), r = h.filterNewItems(n, e.lastProcessedTimestamp);
|
|
1876
|
-
r.length > 0 ? (console.log(`Found ${r.length} new items, merging with ${e.items.length} cached items`), t = h.mergeItems(e.items, r).slice(0, f)) : t = e.items;
|
|
1877
|
-
} else {
|
|
1878
|
-
console.log("Cold cache - fetching page 1");
|
|
1879
|
-
let e = await ce();
|
|
1880
|
-
e && console.log(`Client initialized: ${e.isInitialized()}`), t = await G(s, {
|
|
1881
|
-
limit: f,
|
|
1882
|
-
skip: 0
|
|
1883
|
-
}), console.log(`Found ${t.length} feed items for schema ${s}`);
|
|
1884
|
-
}
|
|
1885
|
-
if (g.imageMetadata?.enabled) {
|
|
1886
|
-
let e = new wt({
|
|
1887
|
-
gateways: g.imageMetadata.gateways,
|
|
1888
|
-
timeout: g.imageMetadata.timeout
|
|
1889
|
-
}), n = await Wt(t, e, h);
|
|
1890
|
-
return await h.setFeedData(s, t), n;
|
|
1891
|
-
}
|
|
1892
|
-
return await h.setFeedData(s, t), t;
|
|
1893
|
-
}) : await (async () => {
|
|
1894
|
-
let e = await G(s, {
|
|
1387
|
+
let e = await (async () => {
|
|
1388
|
+
let e = await ye(s, {
|
|
1895
1389
|
limit: f,
|
|
1896
1390
|
skip: p
|
|
1897
1391
|
});
|
|
1898
|
-
return g.imageMetadata?.enabled ?
|
|
1392
|
+
return console.log(`Found ${e.length} feed items for schema ${s}`), g.imageMetadata?.enabled ? ft(e, new Xe({
|
|
1899
1393
|
gateways: g.imageMetadata.gateways,
|
|
1900
1394
|
timeout: g.imageMetadata.timeout
|
|
1901
1395
|
}), h) : e;
|
|
@@ -1907,12 +1401,12 @@ async function Xt(e, t, n, r, i, a) {
|
|
|
1907
1401
|
href: `${l.feedUrl}/${c}/archive/${t.getFullYear()}/${t.getMonth() + 1}/${o}`
|
|
1908
1402
|
});
|
|
1909
1403
|
}
|
|
1910
|
-
let _ = await
|
|
1404
|
+
let _ = await $(e, s, o, r, {
|
|
1911
1405
|
page: d,
|
|
1912
1406
|
pageSize: f,
|
|
1913
1407
|
hasNext: i,
|
|
1914
1408
|
baseUrl: t
|
|
1915
|
-
}, u.length ? u : void 0, !1, void 0, a), v =
|
|
1409
|
+
}, u.length ? u : void 0, !1, void 0, a), v = mt(o);
|
|
1916
1410
|
if (g.enabled) {
|
|
1917
1411
|
await h.setFeedContent(s, o, _, v, m);
|
|
1918
1412
|
let e = await h.getFeedContent(s, o, m), t = e?.etag || "", n = e?.lastModified || Math.floor(Date.now() / 1e3);
|
|
@@ -1963,7 +1457,7 @@ async function Xt(e, t, n, r, i, a) {
|
|
|
1963
1457
|
});
|
|
1964
1458
|
}
|
|
1965
1459
|
}
|
|
1966
|
-
async function
|
|
1460
|
+
async function vt(e, t, n, r, i, a, o) {
|
|
1967
1461
|
if (t < 1970 || t > 2100) return new Response(JSON.stringify({ error: `Invalid year: ${t}` }), {
|
|
1968
1462
|
status: 400,
|
|
1969
1463
|
headers: { "Content-Type": "application/json" }
|
|
@@ -1972,19 +1466,19 @@ async function Zt(e, t, n, r, i, a, o) {
|
|
|
1972
1466
|
status: 400,
|
|
1973
1467
|
headers: { "Content-Type": "application/json" }
|
|
1974
1468
|
});
|
|
1975
|
-
let s =
|
|
1469
|
+
let s = ht(r);
|
|
1976
1470
|
if (!s) return new Response(JSON.stringify({ error: `Invalid feed format: ${r}` }), {
|
|
1977
1471
|
status: 400,
|
|
1978
1472
|
headers: { "Content-Type": "application/json" }
|
|
1979
1473
|
});
|
|
1980
|
-
let c =
|
|
1474
|
+
let c = C.singular(e.toLowerCase()), l = C(c), u = j(o), d = { archive: {
|
|
1981
1475
|
year: t,
|
|
1982
1476
|
month: n
|
|
1983
|
-
} }, f =
|
|
1477
|
+
} }, f = ut(), p = q();
|
|
1984
1478
|
try {
|
|
1985
1479
|
if (p.enabled) {
|
|
1986
1480
|
let e = await f.getFeedContent(c, s, d);
|
|
1987
|
-
if (e) return i &&
|
|
1481
|
+
if (e) return i && Ke(i, e.etag) ? new Response(null, {
|
|
1988
1482
|
status: 304,
|
|
1989
1483
|
headers: {
|
|
1990
1484
|
ETag: e.etag,
|
|
@@ -2004,7 +1498,7 @@ async function Zt(e, t, n, r, i, a, o) {
|
|
|
2004
1498
|
}
|
|
2005
1499
|
});
|
|
2006
1500
|
}
|
|
2007
|
-
let e = await
|
|
1501
|
+
let e = await be(c, t, n), r = `${u.feedUrl}/${l}/${s}`, m = `${u.feedUrl}/${l}/archive`, h = [{
|
|
2008
1502
|
rel: "prev-archive",
|
|
2009
1503
|
href: `${m}/${n === 1 ? t - 1 : t}/${n === 1 ? 12 : n - 1}/${s}`
|
|
2010
1504
|
}, {
|
|
@@ -2015,7 +1509,7 @@ async function Zt(e, t, n, r, i, a, o) {
|
|
|
2015
1509
|
rel: "next-archive",
|
|
2016
1510
|
href: `${m}/${g}/${_}/${s}`
|
|
2017
1511
|
});
|
|
2018
|
-
let y = await
|
|
1512
|
+
let y = await $(e, c, s, a, void 0, h, !0, void 0, o), b = mt(s);
|
|
2019
1513
|
if (p.enabled) {
|
|
2020
1514
|
await f.setFeedContent(c, s, y, b, d);
|
|
2021
1515
|
let e = await f.getFeedContent(c, s, d), t = e?.etag || "", n = e?.lastModified || Math.floor(Date.now() / 1e3);
|
|
@@ -2052,6 +1546,6 @@ async function Zt(e, t, n, r, i, a, o) {
|
|
|
2052
1546
|
}
|
|
2053
1547
|
}
|
|
2054
1548
|
//#endregion
|
|
2055
|
-
export { t as DEFAULT_ARWEAVE_HOST,
|
|
1549
|
+
export { t as DEFAULT_ARWEAVE_HOST, O as DEFAULT_SITE_CONFIG, _ as FEED_RICH_BODY_STORAGE_SCHEMAS, r as SEED_RSS_IMAGE_RELATION_FIELD_KEYS, i as classifyMediaRef, $ as createFeed, v as enrichImageSeedCloneForFeed, X as feedItemRichTextContainsDataUriImage, at as filterItemsByRichTextDataUriImagePolicy, de as getClient, c as getFeedItemStringField, ye as getFeedItemsBySchemaName, be as getFeedItemsBySchemaNameForMonth, pe as getSiteConfig, vt as handleArchiveFeedRequest, _t as handleFeedRequest, D as initializeFeedPlatform, ue as initializeSeedClient, d as isEasAttestationExplorerUrl, S as isFeedRichBodyStorageSchema, M as loadFeedConfig, f as normalizeFeedItemFields, Ce as parseRssString, rt as pickFeedItemContent, nt as pickFeedItemDescription, dt as resetCacheManager, he as resetSiteConfig, m as resolveSeedRssImageRelationFromItem, h as resolveSeedRssImageRelationRef, j as resolveSiteConfig, me as setSiteConfig, fe as teardownSeedClient };
|
|
2056
1550
|
|
|
2057
1551
|
//# sourceMappingURL=index.js.map
|