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