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