@seedprotocol/feed 0.4.17 → 0.4.18
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/dist/getFeedItems.d.ts.map +1 -1
- package/dist/index.js +265 -265
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BaseArweaveClient as Te, getSeedsBySchemaName as
|
|
2
|
-
import { gql as
|
|
1
|
+
import { BaseArweaveClient as Te, getSeedsBySchemaName as Se, withExcludeRevokedFilter as ce, EasClient as le, getItemVersionsFromEas as Ee, getItemPropertiesFromEas as Ae, pickLatestPropertyAttestationsByRefAndSchema as Ie, setSchemaUidForSchemaDefinition as _e, DEFAULT_ARWEAVE_GATEWAYS as de, client as k, DEFAULT_ARWEAVE_HOST as Me } from "@seedprotocol/sdk";
|
|
2
|
+
import { gql as Ue } from "graphql-request";
|
|
3
3
|
import P from "pluralize";
|
|
4
|
-
import { generateJsonFeed as
|
|
5
|
-
import { create as
|
|
6
|
-
import { createHash as
|
|
7
|
-
import { promises as
|
|
4
|
+
import { generateJsonFeed as Fe, generateAtomFeed as be } from "feedsmith";
|
|
5
|
+
import { create as ve } from "xmlbuilder2";
|
|
6
|
+
import { createHash as ke } from "crypto";
|
|
7
|
+
import { promises as E } from "fs";
|
|
8
8
|
import { join as U } from "path";
|
|
9
9
|
import ee from "image-size";
|
|
10
10
|
function V(a) {
|
|
@@ -16,7 +16,7 @@ function O() {
|
|
|
16
16
|
}
|
|
17
17
|
const L = [
|
|
18
18
|
"0x0000000000000000000000000000000000000000000000000000000000000020"
|
|
19
|
-
], fe =
|
|
19
|
+
], fe = Ue`
|
|
20
20
|
query GetSeeds($where: AttestationWhereInput!, $take: Int, $skip: Int) {
|
|
21
21
|
itemSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }], take: $take, skip: $skip) {
|
|
22
22
|
id
|
|
@@ -34,10 +34,10 @@ const L = [
|
|
|
34
34
|
isOffchain
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
`, G = (a) => a.replace(/_([a-z])/g, (e, t) => t.toUpperCase()),
|
|
38
|
-
const e = new Date(a * 1e3), t = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], o = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], s = t[e.getUTCDay()], r = o[e.getUTCMonth()], n = e.getUTCFullYear(), i = e.getUTCDate().toString().padStart(2, "0"), l = e.getUTCHours().toString().padStart(2, "0"),
|
|
39
|
-
return `${s}, ${i} ${r} ${n} ${l}:${
|
|
40
|
-
},
|
|
37
|
+
`, G = (a) => a.replace(/_([a-z])/g, (e, t) => t.toUpperCase()), xe = (a) => {
|
|
38
|
+
const e = new Date(a * 1e3), t = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], o = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], s = t[e.getUTCDay()], r = o[e.getUTCMonth()], n = e.getUTCFullYear(), i = e.getUTCDate().toString().padStart(2, "0"), l = e.getUTCHours().toString().padStart(2, "0"), d = e.getUTCMinutes().toString().padStart(2, "0"), f = e.getUTCSeconds().toString().padStart(2, "0");
|
|
39
|
+
return `${s}, ${i} ${r} ${n} ${l}:${d}:${f} GMT`;
|
|
40
|
+
}, Le = (a) => a === "image" ? "images" : a === "post" ? "posts" : a.toLowerCase() + "s", Pe = (a) => {
|
|
41
41
|
const [e, t, o] = a.split("_");
|
|
42
42
|
if (!e || !t) return null;
|
|
43
43
|
const s = o === "ids";
|
|
@@ -45,29 +45,29 @@ const L = [
|
|
|
45
45
|
}, he = (a, e, t, o) => {
|
|
46
46
|
const { itemUrlBase: s, itemUrlPath: r, siteUrl: n } = o;
|
|
47
47
|
!a.title && !a.Title ? (a.title = e, a.Title = e) : a.title && !a.Title ? a.Title = a.title : a.Title && !a.title && (a.title = a.Title);
|
|
48
|
-
const i = a.storage_transaction_id && typeof a.storage_transaction_id == "string" && a.storage_transaction_id.trim() !== "" && a.storage_transaction_id !== "undefined" && a.storage_transaction_id !== e ? a.storage_transaction_id.trim() : null, l = a.storageTransactionId && typeof a.storageTransactionId == "string" && a.storageTransactionId.trim() !== "" && a.storageTransactionId !== "undefined" && a.storageTransactionId !== e ? a.storageTransactionId.trim() : null,
|
|
48
|
+
const i = a.storage_transaction_id && typeof a.storage_transaction_id == "string" && a.storage_transaction_id.trim() !== "" && a.storage_transaction_id !== "undefined" && a.storage_transaction_id !== e ? a.storage_transaction_id.trim() : null, l = a.storageTransactionId && typeof a.storageTransactionId == "string" && a.storageTransactionId.trim() !== "" && a.storageTransactionId !== "undefined" && a.storageTransactionId !== e ? a.storageTransactionId.trim() : null, d = i || l, f = Le(t), p = e && typeof e == "string" && e.trim() !== "" ? e : "unknown";
|
|
49
49
|
let g;
|
|
50
|
-
if (
|
|
50
|
+
if (d && d !== e && d.length > 0)
|
|
51
51
|
try {
|
|
52
|
-
g = V(
|
|
52
|
+
g = V(d);
|
|
53
53
|
} catch (C) {
|
|
54
|
-
console.error("[feed] [setFeedItemDefaults] Error generating Arweave URL:", C), s != null ? g = `${s.replace(/\/$/, "")}/${(r ?? "attestation/view").replace(/^\//, "")}/${p}` : g = `${n.replace(/\/$/, "")}/${
|
|
54
|
+
console.error("[feed] [setFeedItemDefaults] Error generating Arweave URL:", C), s != null ? g = `${s.replace(/\/$/, "")}/${(r ?? "attestation/view").replace(/^\//, "")}/${p}` : g = `${n.replace(/\/$/, "")}/${f}/${p}`;
|
|
55
55
|
}
|
|
56
56
|
else
|
|
57
|
-
s != null ? g = `${s.replace(/\/$/, "")}/${(r ?? "attestation/view").replace(/^\//, "")}/${p}` : g = `${n.replace(/\/$/, "")}/${
|
|
57
|
+
s != null ? g = `${s.replace(/\/$/, "")}/${(r ?? "attestation/view").replace(/^\//, "")}/${p}` : g = `${n.replace(/\/$/, "")}/${f}/${p}`;
|
|
58
58
|
const m = a.link || a.Link;
|
|
59
59
|
!m || m === "undefined" || typeof m == "string" && m.trim() === "" ? (a.link = g, a.Link = g) : ((!a.link || a.link === "undefined") && (a.link = m), (!a.Link || a.Link === "undefined") && (a.Link = m));
|
|
60
60
|
const y = a.guid || a.Guid;
|
|
61
61
|
if (!y || y === "undefined" || typeof y == "string" && y.trim() === "" ? (a.guid = a.link || g, a.Guid = a.guid) : ((!a.guid || a.guid === "undefined") && (a.guid = y), (!a.Guid || a.Guid === "undefined") && (a.Guid = y)), a.timeCreated && !a.pubDate && !a.PubDate) {
|
|
62
|
-
const C =
|
|
62
|
+
const C = xe(a.timeCreated);
|
|
63
63
|
a.pubDate = C, a.PubDate = C;
|
|
64
64
|
} else a.pubDate && !a.PubDate ? a.PubDate = a.pubDate : a.PubDate && !a.pubDate && (a.pubDate = a.PubDate);
|
|
65
65
|
!a.seedUid && !a.SeedUid ? (a.seedUid = e, a.SeedUid = e) : a.seedUid && !a.SeedUid ? a.SeedUid = a.seedUid : a.SeedUid && !a.seedUid && (a.seedUid = a.SeedUid), a.attester && !a.Attester ? a.Attester = a.attester : a.Attester && !a.attester && (a.attester = a.Attester);
|
|
66
66
|
}, R = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Set(), Z = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new Map(), ge = /* @__PURE__ */ new Map();
|
|
67
|
-
function
|
|
67
|
+
function Re() {
|
|
68
68
|
R.clear(), X.clear(), Z.clear(), M.clear(), z.clear(), ge.clear();
|
|
69
69
|
}
|
|
70
|
-
const
|
|
70
|
+
const Ne = async (a, e) => {
|
|
71
71
|
let t;
|
|
72
72
|
try {
|
|
73
73
|
t = JSON.parse(a.decodedDataJson)[0]?.value ?? {};
|
|
@@ -79,61 +79,61 @@ const Re = async (a, e) => {
|
|
|
79
79
|
if (!o)
|
|
80
80
|
return;
|
|
81
81
|
const s = a.schemaId;
|
|
82
|
-
|
|
82
|
+
_e({
|
|
83
83
|
text: o,
|
|
84
84
|
schemaUid: s
|
|
85
85
|
});
|
|
86
86
|
let r = !1, n = !1;
|
|
87
|
-
const i = t.type, l = (i === "bytes32" || i === "bytes32[]") && o !== "storage_transaction_id" && o !== "storage_provider_transaction_id",
|
|
88
|
-
if (l ||
|
|
87
|
+
const i = t.type, l = (i === "bytes32" || i === "bytes32[]") && o !== "storage_transaction_id" && o !== "storage_provider_transaction_id", d = !l && (o.endsWith("_id") || o.endsWith("_ids")) && o !== "storage_transaction_id" && o !== "storage_provider_transaction_id";
|
|
88
|
+
if (l || d)
|
|
89
89
|
if (r = !0, Array.isArray(t.value)) {
|
|
90
|
-
if (n = !0,
|
|
91
|
-
const y =
|
|
90
|
+
if (n = !0, d) {
|
|
91
|
+
const y = Pe(o);
|
|
92
92
|
y && (o = y.propertyName);
|
|
93
93
|
}
|
|
94
94
|
t.value.forEach((y) => {
|
|
95
95
|
L.includes(y) || X.add(y);
|
|
96
96
|
});
|
|
97
97
|
} else L.includes(t.value) || X.add(t.value);
|
|
98
|
-
let
|
|
99
|
-
typeof
|
|
98
|
+
let f = t.value;
|
|
99
|
+
typeof f != "string" && (f = JSON.stringify(f)), r && !n && e.find((C) => C.id === t.value)?.schema?.schemaNames, r && n && e.filter(
|
|
100
100
|
(C) => Array.isArray(t.value) && t.value.includes(C.id)
|
|
101
101
|
).length > 0;
|
|
102
102
|
const p = Z.get(a.refUID);
|
|
103
103
|
if (!p)
|
|
104
104
|
return;
|
|
105
105
|
const g = M.get(p) || {};
|
|
106
|
-
g[o] =
|
|
106
|
+
g[o] = f;
|
|
107
107
|
const m = G(o);
|
|
108
|
-
m !== o && (g[m] =
|
|
108
|
+
m !== o && (g[m] = f), M.set(p, g);
|
|
109
109
|
}, te = async (a) => {
|
|
110
|
-
const e = a.map((
|
|
111
|
-
for (let
|
|
112
|
-
const
|
|
113
|
-
if (!
|
|
114
|
-
e.push(
|
|
115
|
-
const
|
|
116
|
-
R.set(
|
|
117
|
-
seedUid:
|
|
118
|
-
timeCreated:
|
|
119
|
-
attester:
|
|
110
|
+
const e = a.map((n) => n.id);
|
|
111
|
+
for (let n = 0; n < a.length; n++) {
|
|
112
|
+
const i = a[n];
|
|
113
|
+
if (!i) continue;
|
|
114
|
+
e.push(i.id);
|
|
115
|
+
const l = i.schema?.schemaNames?.[0]?.name ?? "unknown";
|
|
116
|
+
R.set(i.id, l), M.has(i.id) || M.set(i.id, {
|
|
117
|
+
seedUid: i.id,
|
|
118
|
+
timeCreated: i.timeCreated,
|
|
119
|
+
attester: i.attester
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
const t = await
|
|
123
|
-
for (let
|
|
124
|
-
const
|
|
125
|
-
Z.set(
|
|
126
|
-
const
|
|
127
|
-
z.set(
|
|
122
|
+
const t = await Ee({ seedUids: e });
|
|
123
|
+
for (let n = 0; n < t.length; n++) {
|
|
124
|
+
const i = t[n], l = i.refUID;
|
|
125
|
+
Z.set(i.id, l);
|
|
126
|
+
const d = z.get(l) || [];
|
|
127
|
+
z.set(l, [...d, i]);
|
|
128
128
|
}
|
|
129
129
|
const o = [];
|
|
130
|
-
for (const [
|
|
131
|
-
const
|
|
132
|
-
|
|
130
|
+
for (const [n, i] of z.entries()) {
|
|
131
|
+
const d = [...i].sort((f, p) => p.timeCreated - f.timeCreated)[0];
|
|
132
|
+
d && (o.push(d.id), ge.set(n, d.id));
|
|
133
133
|
}
|
|
134
|
-
const s = await
|
|
135
|
-
for (let
|
|
136
|
-
await
|
|
134
|
+
const s = await Ae({ versionUids: o }), r = Ie(s);
|
|
135
|
+
for (let n = 0; n < r.length; n++)
|
|
136
|
+
await Ne(r[n], a);
|
|
137
137
|
}, ue = /* @__PURE__ */ new Set([
|
|
138
138
|
"seedUid",
|
|
139
139
|
"SeedUid",
|
|
@@ -145,7 +145,7 @@ const Re = async (a, e) => {
|
|
|
145
145
|
"storageTransactionId",
|
|
146
146
|
"storageProviderTransactionId"
|
|
147
147
|
]);
|
|
148
|
-
function
|
|
148
|
+
function je(a) {
|
|
149
149
|
const e = Array.from(M.entries()).filter(
|
|
150
150
|
([t]) => R.get(t) === a
|
|
151
151
|
);
|
|
@@ -160,26 +160,26 @@ function Ne(a) {
|
|
|
160
160
|
if (!i.some(
|
|
161
161
|
(p) => typeof p == "string" && !L.includes(p) && M.has(p)
|
|
162
162
|
)) continue;
|
|
163
|
-
const
|
|
164
|
-
let
|
|
163
|
+
const d = [];
|
|
164
|
+
let f = !1;
|
|
165
165
|
for (const p of i) {
|
|
166
166
|
if (typeof p != "string" || L.includes(p)) {
|
|
167
|
-
|
|
167
|
+
d.push(String(p));
|
|
168
168
|
continue;
|
|
169
169
|
}
|
|
170
170
|
const g = M.get(p), m = g?.storageTransactionId ?? g?.storage_transaction_id;
|
|
171
171
|
if (m && typeof m == "string" && m.trim())
|
|
172
172
|
try {
|
|
173
|
-
|
|
173
|
+
d.push(V(m)), f = !0;
|
|
174
174
|
} catch {
|
|
175
|
-
|
|
175
|
+
d.push(p);
|
|
176
176
|
}
|
|
177
177
|
else
|
|
178
|
-
|
|
178
|
+
d.push(p);
|
|
179
179
|
}
|
|
180
|
-
if (
|
|
180
|
+
if (f) {
|
|
181
181
|
const p = s.endsWith("_ids") ? s.replace(/_ids$/, "") : s;
|
|
182
|
-
if (t[p] =
|
|
182
|
+
if (t[p] = d, p !== s) {
|
|
183
183
|
delete t[s];
|
|
184
184
|
const g = G(s);
|
|
185
185
|
g !== s && delete t[g];
|
|
@@ -190,11 +190,11 @@ function Ne(a) {
|
|
|
190
190
|
const i = M.get(r), l = i?.storageTransactionId ?? i?.storage_transaction_id;
|
|
191
191
|
if (l && typeof l == "string" && l.trim())
|
|
192
192
|
try {
|
|
193
|
-
const
|
|
194
|
-
if (t[
|
|
193
|
+
const d = s.endsWith("_id") ? s.replace(/_id$/, "") : s;
|
|
194
|
+
if (t[d] = V(l), d !== s) {
|
|
195
195
|
delete t[s];
|
|
196
|
-
const
|
|
197
|
-
|
|
196
|
+
const f = G(s);
|
|
197
|
+
f !== s && delete t[f];
|
|
198
198
|
}
|
|
199
199
|
} catch {
|
|
200
200
|
}
|
|
@@ -202,7 +202,7 @@ function Ne(a) {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function Oe(a, e, t) {
|
|
206
206
|
if (!t) return;
|
|
207
207
|
const o = Array.from(M.entries()).filter(
|
|
208
208
|
([s]) => R.get(s) === a
|
|
@@ -212,29 +212,29 @@ function je(a, e, t) {
|
|
|
212
212
|
(n) => !n.startsWith("_") && !ue.has(n)
|
|
213
213
|
);
|
|
214
214
|
for (const n of r) {
|
|
215
|
-
const i = s[n], l = Array.isArray(i),
|
|
215
|
+
const i = s[n], l = Array.isArray(i), d = l ? i : [i], f = [];
|
|
216
216
|
let p = !1;
|
|
217
|
-
for (const g of
|
|
217
|
+
for (const g of d) {
|
|
218
218
|
if (typeof g != "string" || L.includes(g)) {
|
|
219
|
-
|
|
219
|
+
f.push(g);
|
|
220
220
|
continue;
|
|
221
221
|
}
|
|
222
222
|
const m = M.get(g);
|
|
223
223
|
if (!m) {
|
|
224
|
-
|
|
224
|
+
f.push(g);
|
|
225
225
|
continue;
|
|
226
226
|
}
|
|
227
227
|
const y = m?.storageTransactionId ?? m?.storage_transaction_id;
|
|
228
228
|
if (y && typeof y == "string" && y.trim()) {
|
|
229
|
-
|
|
229
|
+
f.push(g);
|
|
230
230
|
continue;
|
|
231
231
|
}
|
|
232
232
|
const C = R.get(g) ?? "unknown", c = { ...m };
|
|
233
|
-
he(c, g, C, e),
|
|
233
|
+
he(c, g, C, e), f.push(c), p = !0;
|
|
234
234
|
}
|
|
235
235
|
if (p) {
|
|
236
236
|
const g = n.endsWith("_id") ? n.replace(/_id$/, "") : n.endsWith("_ids") ? n.replace(/_ids$/, "") : n;
|
|
237
|
-
if (s[g] = l ?
|
|
237
|
+
if (s[g] = l ? f : f[0], g !== n) {
|
|
238
238
|
delete s[n];
|
|
239
239
|
const m = G(n);
|
|
240
240
|
m !== n && delete s[m];
|
|
@@ -244,7 +244,7 @@ function je(a, e, t) {
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
async function pe(a, e, t) {
|
|
247
|
-
|
|
247
|
+
Re(), await te(e);
|
|
248
248
|
const o = le.getEasClient(), s = Array.from(X), { itemSeeds: r } = await o.request(fe, {
|
|
249
249
|
where: ce({
|
|
250
250
|
id: {
|
|
@@ -254,25 +254,25 @@ async function pe(a, e, t) {
|
|
|
254
254
|
take: s.length || 1,
|
|
255
255
|
skip: 0
|
|
256
256
|
});
|
|
257
|
-
await te(r ?? []),
|
|
257
|
+
await te(r ?? []), je(a);
|
|
258
258
|
const n = O(), i = {
|
|
259
259
|
itemUrlBase: n.itemUrlBase,
|
|
260
260
|
itemUrlPath: n.itemUrlPath,
|
|
261
261
|
siteUrl: n.siteUrl
|
|
262
262
|
};
|
|
263
|
-
return
|
|
263
|
+
return Oe(
|
|
264
264
|
a,
|
|
265
265
|
i,
|
|
266
266
|
t
|
|
267
267
|
), Array.from(M.entries()).filter(([l]) => R.get(l) === a).map(([, l]) => {
|
|
268
|
-
const
|
|
269
|
-
return he(l,
|
|
268
|
+
const d = l.seedUid || l.SeedUid;
|
|
269
|
+
return he(l, d, a, i), l;
|
|
270
270
|
});
|
|
271
271
|
}
|
|
272
272
|
const q = async (a, e) => {
|
|
273
|
-
const t = O(), o = e?.limit ?? 100, s = e?.skip ?? 0, r = await
|
|
273
|
+
const t = O(), o = e?.limit ?? 100, s = e?.skip ?? 0, r = await Se(a, o, s);
|
|
274
274
|
return pe(a, r, t.expandRelations !== !1);
|
|
275
|
-
},
|
|
275
|
+
}, Be = async (a, e, t) => {
|
|
276
276
|
const o = O(), s = new Date(e, t - 1, 1), r = new Date(e, t, 0, 23, 59, 59), n = Math.floor(s.getTime() / 1e3), i = Math.floor(r.getTime() / 1e3) + 1, l = ce({
|
|
277
277
|
AND: [
|
|
278
278
|
{
|
|
@@ -290,15 +290,15 @@ const q = async (a, e) => {
|
|
|
290
290
|
timeCreated: { gte: n, lt: i }
|
|
291
291
|
}
|
|
292
292
|
]
|
|
293
|
-
}),
|
|
293
|
+
}), d = le.getEasClient(), { itemSeeds: f } = await d.request(fe, {
|
|
294
294
|
where: l,
|
|
295
295
|
take: 1e3,
|
|
296
296
|
skip: 0
|
|
297
297
|
});
|
|
298
|
-
return pe(a,
|
|
299
|
-
}, j = "http://purl.org/dc/elements/1.1/", J = "http://purl.org/rss/1.0/modules/content/", v = "http://search.yahoo.com/mrss/",
|
|
300
|
-
function
|
|
301
|
-
return
|
|
298
|
+
return pe(a, f ?? [], o.expandRelations !== !1);
|
|
299
|
+
}, j = "http://purl.org/dc/elements/1.1/", J = "http://purl.org/rss/1.0/modules/content/", v = "http://search.yahoo.com/mrss/", We = /* @__PURE__ */ new Set(["Title", "Link", "Guid", "PubDate", "SeedUid"]);
|
|
300
|
+
function ze(a, e) {
|
|
301
|
+
return We.has(a) ? a.charAt(0).toLowerCase() + a.slice(1) in e : !1;
|
|
302
302
|
}
|
|
303
303
|
const ae = [
|
|
304
304
|
"title",
|
|
@@ -333,13 +333,13 @@ function Y(a) {
|
|
|
333
333
|
}
|
|
334
334
|
return String(a);
|
|
335
335
|
}
|
|
336
|
-
function
|
|
336
|
+
function He(a) {
|
|
337
337
|
return /[<>&]|]]>/.test(a);
|
|
338
338
|
}
|
|
339
339
|
function _(a, e) {
|
|
340
340
|
const t = String(e);
|
|
341
341
|
if (t !== "")
|
|
342
|
-
if (
|
|
342
|
+
if (He(t))
|
|
343
343
|
if (t.includes("]]>")) {
|
|
344
344
|
const o = t.split("]]>");
|
|
345
345
|
for (let s = 0; s < o.length; s++)
|
|
@@ -400,8 +400,8 @@ function ne(a, e, t, o) {
|
|
|
400
400
|
if (Array.isArray(i)) {
|
|
401
401
|
for (const l of i)
|
|
402
402
|
if (l != null) {
|
|
403
|
-
const
|
|
404
|
-
l instanceof Date ?
|
|
403
|
+
const d = a.ele(j, n);
|
|
404
|
+
l instanceof Date ? d.txt(l.toISOString()) : _(d, String(l));
|
|
405
405
|
}
|
|
406
406
|
} else {
|
|
407
407
|
const l = a.ele(j, n);
|
|
@@ -426,10 +426,10 @@ function ne(a, e, t, o) {
|
|
|
426
426
|
if (n === null || typeof n != "object") continue;
|
|
427
427
|
const i = {};
|
|
428
428
|
let l = null;
|
|
429
|
-
for (const [
|
|
430
|
-
p != null && (
|
|
431
|
-
const
|
|
432
|
-
l !== null && _(
|
|
429
|
+
for (const [f, p] of Object.entries(n))
|
|
430
|
+
p != null && (f === "value" ? l = String(p) : i[f] = String(p));
|
|
431
|
+
const d = a.ele(v, r, i);
|
|
432
|
+
l !== null && _(d, l);
|
|
433
433
|
}
|
|
434
434
|
return;
|
|
435
435
|
}
|
|
@@ -444,15 +444,15 @@ function ne(a, e, t, o) {
|
|
|
444
444
|
const n = a.ele(v, "group");
|
|
445
445
|
for (const [i, l] of Object.entries(r))
|
|
446
446
|
if (l != null && i.startsWith("media:")) {
|
|
447
|
-
const
|
|
447
|
+
const d = i.slice(6);
|
|
448
448
|
if (Array.isArray(l)) {
|
|
449
|
-
for (const
|
|
450
|
-
if (
|
|
451
|
-
const p = n.ele(v,
|
|
452
|
-
for (const [g, m] of Object.entries(
|
|
449
|
+
for (const f of l)
|
|
450
|
+
if (f && typeof f == "object") {
|
|
451
|
+
const p = n.ele(v, d);
|
|
452
|
+
for (const [g, m] of Object.entries(f))
|
|
453
453
|
m != null && (g === "url" || g === "value" ? _(p, String(m)) : p.att(g, String(m)));
|
|
454
454
|
}
|
|
455
|
-
} else typeof l == "string" && _(n.ele(v,
|
|
455
|
+
} else typeof l == "string" && _(n.ele(v, d), l);
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
458
|
return;
|
|
@@ -508,8 +508,8 @@ function ne(a, e, t, o) {
|
|
|
508
508
|
_(s, String(t));
|
|
509
509
|
}
|
|
510
510
|
const re = "http://www.w3.org/2005/Atom", se = "http://purl.org/syndication/history/1.0";
|
|
511
|
-
function
|
|
512
|
-
const e =
|
|
511
|
+
function Ve(a) {
|
|
512
|
+
const e = ve({ version: "1.0", encoding: "UTF-8" }), t = {
|
|
513
513
|
"xmlns:dc": j,
|
|
514
514
|
"xmlns:content": J,
|
|
515
515
|
"xmlns:media": v,
|
|
@@ -530,13 +530,13 @@ function He(a) {
|
|
|
530
530
|
const r = new Set(ae);
|
|
531
531
|
for (const n of a.items) {
|
|
532
532
|
const i = s.ele("item"), l = /* @__PURE__ */ new Set();
|
|
533
|
-
for (const
|
|
534
|
-
|
|
535
|
-
const
|
|
536
|
-
(
|
|
533
|
+
for (const f of ae)
|
|
534
|
+
f in n && (ne(i, f, n[f], n), l.add(f));
|
|
535
|
+
const d = Object.keys(n).filter(
|
|
536
|
+
(f) => !l.has(f) && !r.has(f) && !f.startsWith("_") && !ze(f, n)
|
|
537
537
|
).sort();
|
|
538
|
-
for (const
|
|
539
|
-
ne(i,
|
|
538
|
+
for (const f of d)
|
|
539
|
+
ne(i, f, n[f], n);
|
|
540
540
|
}
|
|
541
541
|
return e.end({ prettyPrint: !0 });
|
|
542
542
|
}
|
|
@@ -544,28 +544,28 @@ function K(a, e, t) {
|
|
|
544
544
|
return t?.archive ? `${a}:${e}:archive-${t.archive.year}-${t.archive.month}` : t?.page != null && t.page > 1 ? `${a}:${e}:page-${t.page}` : `${a}:${e}`;
|
|
545
545
|
}
|
|
546
546
|
function me(a) {
|
|
547
|
-
return `"${
|
|
547
|
+
return `"${ke("md5").update(a).digest("hex").substring(0, 16)}"`;
|
|
548
548
|
}
|
|
549
|
-
function
|
|
549
|
+
function Ge(a, e, t, o) {
|
|
550
550
|
const s = `${a}-${e}-${t}-${o}`;
|
|
551
551
|
return me(s);
|
|
552
552
|
}
|
|
553
|
-
function
|
|
553
|
+
function Xe(a, e, t, o) {
|
|
554
554
|
const s = `${a}-${e}-${t}-${o}`;
|
|
555
555
|
return me(s);
|
|
556
556
|
}
|
|
557
|
-
function
|
|
557
|
+
function Je(a, e) {
|
|
558
558
|
const t = (o) => o.replace(/^"|"$/g, "");
|
|
559
559
|
return t(a) === t(e);
|
|
560
560
|
}
|
|
561
|
-
function
|
|
561
|
+
function qe(a) {
|
|
562
562
|
return a ? a.split(",").map((e) => e.trim()).filter((e) => e.length > 0) : [];
|
|
563
563
|
}
|
|
564
564
|
function ye(a, e) {
|
|
565
|
-
const t =
|
|
566
|
-
return t.length === 0 ? !1 : t.includes("*") ? !0 : t.some((o) =>
|
|
565
|
+
const t = qe(a);
|
|
566
|
+
return t.length === 0 ? !1 : t.includes("*") ? !0 : t.some((o) => Je(o, e));
|
|
567
567
|
}
|
|
568
|
-
class
|
|
568
|
+
class Ye {
|
|
569
569
|
feedDataCache = /* @__PURE__ */ new Map();
|
|
570
570
|
feedContentCache = /* @__PURE__ */ new Map();
|
|
571
571
|
imageMetadataCache = /* @__PURE__ */ new Map();
|
|
@@ -588,11 +588,11 @@ class qe {
|
|
|
588
588
|
const o = Math.floor(Date.now() / 1e3);
|
|
589
589
|
let s = 0, r = "";
|
|
590
590
|
for (const l of t) {
|
|
591
|
-
const
|
|
592
|
-
|
|
591
|
+
const d = l.timeCreated;
|
|
592
|
+
d && d > s && (s = d, r = l.id || l.seedUid || l.SeedUid || "");
|
|
593
593
|
}
|
|
594
594
|
s === 0 && (s = o);
|
|
595
|
-
const n =
|
|
595
|
+
const n = Ge(e, "data", s, t.length), i = {
|
|
596
596
|
items: [...t],
|
|
597
597
|
// Create a copy
|
|
598
598
|
lastProcessedTimestamp: s,
|
|
@@ -613,12 +613,12 @@ class qe {
|
|
|
613
613
|
* Set cached feed content for a schema and format
|
|
614
614
|
*/
|
|
615
615
|
setFeedContent(e, t, o, s, r, n) {
|
|
616
|
-
const i = K(e, t, r), l = Math.floor(Date.now() / 1e3),
|
|
616
|
+
const i = K(e, t, r), l = Math.floor(Date.now() / 1e3), d = n ?? this.config.ttl, f = l + d, p = Xe(e, t, l, o.length), g = {
|
|
617
617
|
content: o,
|
|
618
618
|
contentType: s,
|
|
619
619
|
etag: p,
|
|
620
620
|
lastModified: l,
|
|
621
|
-
expiresAt:
|
|
621
|
+
expiresAt: f
|
|
622
622
|
};
|
|
623
623
|
this.feedContentCache.set(i, g);
|
|
624
624
|
}
|
|
@@ -695,7 +695,7 @@ class qe {
|
|
|
695
695
|
};
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
|
-
class
|
|
698
|
+
class Ke {
|
|
699
699
|
cacheDir;
|
|
700
700
|
config;
|
|
701
701
|
constructor(e) {
|
|
@@ -708,7 +708,7 @@ class Ye {
|
|
|
708
708
|
*/
|
|
709
709
|
async ensureCacheDir() {
|
|
710
710
|
try {
|
|
711
|
-
await
|
|
711
|
+
await E.mkdir(this.cacheDir, { recursive: !0 });
|
|
712
712
|
} catch (e) {
|
|
713
713
|
if (e.code !== "EEXIST")
|
|
714
714
|
throw e;
|
|
@@ -740,7 +740,7 @@ class Ye {
|
|
|
740
740
|
async ensureImageMetadataDir() {
|
|
741
741
|
try {
|
|
742
742
|
const e = U(this.cacheDir, "image-metadata");
|
|
743
|
-
await
|
|
743
|
+
await E.mkdir(e, { recursive: !0 });
|
|
744
744
|
} catch (e) {
|
|
745
745
|
if (e.code !== "EEXIST")
|
|
746
746
|
throw e;
|
|
@@ -751,7 +751,7 @@ class Ye {
|
|
|
751
751
|
*/
|
|
752
752
|
async getFeedData(e) {
|
|
753
753
|
try {
|
|
754
|
-
const t = this.getFeedDataPath(e), o = await
|
|
754
|
+
const t = this.getFeedDataPath(e), o = await E.readFile(t, "utf-8"), s = JSON.parse(o);
|
|
755
755
|
return Math.floor(Date.now() / 1e3) - s.lastUpdated > this.config.ttl ? (await this.clearFeedData(e), null) : s;
|
|
756
756
|
} catch (t) {
|
|
757
757
|
return t.code === "ENOENT" || console.error(`Error reading feed data cache for ${e}:`, t), null;
|
|
@@ -764,7 +764,7 @@ class Ye {
|
|
|
764
764
|
try {
|
|
765
765
|
await this.ensureCacheDir();
|
|
766
766
|
const o = this.getFeedDataPath(e);
|
|
767
|
-
await
|
|
767
|
+
await E.writeFile(o, JSON.stringify(t, null, 2), "utf-8");
|
|
768
768
|
} catch (o) {
|
|
769
769
|
console.error(`Error writing feed data cache for ${e}:`, o);
|
|
770
770
|
}
|
|
@@ -774,7 +774,7 @@ class Ye {
|
|
|
774
774
|
*/
|
|
775
775
|
async getFeedContent(e, t, o) {
|
|
776
776
|
try {
|
|
777
|
-
const s = this.getFeedContentPath(e, t, o), r = await
|
|
777
|
+
const s = this.getFeedContentPath(e, t, o), r = await E.readFile(s, "utf-8"), n = JSON.parse(r);
|
|
778
778
|
return Math.floor(Date.now() / 1e3) > n.expiresAt ? (await this.clearFeedContent(e, t, o), null) : n;
|
|
779
779
|
} catch (s) {
|
|
780
780
|
return s.code === "ENOENT" || console.error(
|
|
@@ -790,7 +790,7 @@ class Ye {
|
|
|
790
790
|
try {
|
|
791
791
|
await this.ensureCacheDir();
|
|
792
792
|
const r = this.getFeedContentPath(e, t, s);
|
|
793
|
-
await
|
|
793
|
+
await E.writeFile(r, JSON.stringify(o, null, 2), "utf-8");
|
|
794
794
|
} catch (r) {
|
|
795
795
|
console.error(
|
|
796
796
|
`Error writing feed content cache for ${e}:${t}:`,
|
|
@@ -804,7 +804,7 @@ class Ye {
|
|
|
804
804
|
async clearFeedData(e) {
|
|
805
805
|
try {
|
|
806
806
|
const t = this.getFeedDataPath(e);
|
|
807
|
-
await
|
|
807
|
+
await E.unlink(t);
|
|
808
808
|
} catch (t) {
|
|
809
809
|
t.code !== "ENOENT" && console.error(`Error clearing feed data cache for ${e}:`, t);
|
|
810
810
|
}
|
|
@@ -815,7 +815,7 @@ class Ye {
|
|
|
815
815
|
async clearFeedContent(e, t, o) {
|
|
816
816
|
try {
|
|
817
817
|
const s = this.getFeedContentPath(e, t, o);
|
|
818
|
-
await
|
|
818
|
+
await E.unlink(s);
|
|
819
819
|
} catch (s) {
|
|
820
820
|
s.code !== "ENOENT" && console.error(
|
|
821
821
|
`Error clearing feed content cache for ${e}:${t}:`,
|
|
@@ -828,9 +828,9 @@ class Ye {
|
|
|
828
828
|
*/
|
|
829
829
|
async clearAllContentCache(e) {
|
|
830
830
|
try {
|
|
831
|
-
const t = await
|
|
831
|
+
const t = await E.readdir(this.cacheDir), o = `${e}-`, s = ".json";
|
|
832
832
|
for (const r of t)
|
|
833
|
-
r.startsWith(o) && r.endsWith(s) && r !== `${e}.json` && await
|
|
833
|
+
r.startsWith(o) && r.endsWith(s) && r !== `${e}.json` && await E.unlink(U(this.cacheDir, r));
|
|
834
834
|
} catch (t) {
|
|
835
835
|
console.error(`Error clearing all content cache for ${e}:`, t);
|
|
836
836
|
}
|
|
@@ -840,7 +840,7 @@ class Ye {
|
|
|
840
840
|
*/
|
|
841
841
|
async getImageMetadata(e) {
|
|
842
842
|
try {
|
|
843
|
-
const t = this.getImageMetadataPath(e), o = await
|
|
843
|
+
const t = this.getImageMetadataPath(e), o = await E.readFile(t, "utf-8"), s = JSON.parse(o);
|
|
844
844
|
return Math.floor(Date.now() / 1e3) > s.expiresAt ? (await this.clearImageMetadata(e), null) : s.metadata;
|
|
845
845
|
} catch (t) {
|
|
846
846
|
return t.code === "ENOENT" || console.error(`Error reading image metadata cache for ${e}:`, t), null;
|
|
@@ -857,7 +857,7 @@ class Ye {
|
|
|
857
857
|
cachedAt: s,
|
|
858
858
|
expiresAt: n
|
|
859
859
|
};
|
|
860
|
-
await
|
|
860
|
+
await E.writeFile(o, JSON.stringify(i, null, 2), "utf-8");
|
|
861
861
|
} catch (o) {
|
|
862
862
|
console.error(`Error writing image metadata cache for ${e}:`, o);
|
|
863
863
|
}
|
|
@@ -868,7 +868,7 @@ class Ye {
|
|
|
868
868
|
async clearImageMetadata(e) {
|
|
869
869
|
try {
|
|
870
870
|
const t = this.getImageMetadataPath(e);
|
|
871
|
-
await
|
|
871
|
+
await E.unlink(t);
|
|
872
872
|
} catch (t) {
|
|
873
873
|
t.code !== "ENOENT" && console.error(`Error clearing image metadata cache for ${e}:`, t);
|
|
874
874
|
}
|
|
@@ -878,14 +878,14 @@ class Ye {
|
|
|
878
878
|
*/
|
|
879
879
|
async clearAll() {
|
|
880
880
|
try {
|
|
881
|
-
const e = await
|
|
881
|
+
const e = await E.readdir(this.cacheDir);
|
|
882
882
|
for (const o of e)
|
|
883
|
-
o.endsWith(".json") && await
|
|
883
|
+
o.endsWith(".json") && await E.unlink(U(this.cacheDir, o));
|
|
884
884
|
const t = U(this.cacheDir, "image-metadata");
|
|
885
885
|
try {
|
|
886
|
-
const o = await
|
|
886
|
+
const o = await E.readdir(t);
|
|
887
887
|
for (const s of o)
|
|
888
|
-
s.endsWith(".json") && await
|
|
888
|
+
s.endsWith(".json") && await E.unlink(U(t, s));
|
|
889
889
|
} catch {
|
|
890
890
|
}
|
|
891
891
|
} catch (e) {
|
|
@@ -893,7 +893,7 @@ class Ye {
|
|
|
893
893
|
}
|
|
894
894
|
}
|
|
895
895
|
}
|
|
896
|
-
class
|
|
896
|
+
class Ze {
|
|
897
897
|
memoryCache;
|
|
898
898
|
fileCache;
|
|
899
899
|
config;
|
|
@@ -904,7 +904,7 @@ class Ke {
|
|
|
904
904
|
errors: 0
|
|
905
905
|
};
|
|
906
906
|
constructor(e) {
|
|
907
|
-
this.config = e, this.memoryCache = new
|
|
907
|
+
this.config = e, this.memoryCache = new Ye(e), this.fileCache = new Ke(e);
|
|
908
908
|
}
|
|
909
909
|
/**
|
|
910
910
|
* Get cached feed data for a schema
|
|
@@ -1092,10 +1092,10 @@ function Q() {
|
|
|
1092
1092
|
10
|
|
1093
1093
|
);
|
|
1094
1094
|
r || console.log(`⚠️ Cache is DISABLED (${t ? "CACHE_ENABLED=false" : s ? "NODE_ENV=development" : "CACHE_ENABLED=false"})`);
|
|
1095
|
-
const l = process.env.IMAGE_METADATA_ENABLED !== "false",
|
|
1095
|
+
const l = process.env.IMAGE_METADATA_ENABLED !== "false", d = parseInt(process.env.IMAGE_METADATA_TTL || "604800", 10), f = process.env.IMAGE_METADATA_GATEWAYS ? process.env.IMAGE_METADATA_GATEWAYS.split(",").map((C) => C.trim()) : [...de], p = parseInt(process.env.IMAGE_METADATA_TIMEOUT || "5000", 10), g = {
|
|
1096
1096
|
enabled: l,
|
|
1097
|
-
ttl:
|
|
1098
|
-
gateways:
|
|
1097
|
+
ttl: d,
|
|
1098
|
+
gateways: f,
|
|
1099
1099
|
timeout: p
|
|
1100
1100
|
}, m = parseInt(process.env.CACHE_PAGE_TTL || "300", 10), y = parseInt(process.env.CACHE_ARCHIVE_TTL || "86400", 10);
|
|
1101
1101
|
return {
|
|
@@ -1253,14 +1253,14 @@ let x, b = null, H = null;
|
|
|
1253
1253
|
function we() {
|
|
1254
1254
|
if (!H) {
|
|
1255
1255
|
const a = Q();
|
|
1256
|
-
H = new
|
|
1256
|
+
H = new Ze(a);
|
|
1257
1257
|
}
|
|
1258
1258
|
return H;
|
|
1259
1259
|
}
|
|
1260
|
-
function
|
|
1260
|
+
function ht() {
|
|
1261
1261
|
H = null;
|
|
1262
1262
|
}
|
|
1263
|
-
const
|
|
1263
|
+
const Qe = async () => {
|
|
1264
1264
|
if (b)
|
|
1265
1265
|
return b;
|
|
1266
1266
|
if (!x)
|
|
@@ -1271,13 +1271,13 @@ const Ze = async () => {
|
|
|
1271
1271
|
filePaths: "app-files",
|
|
1272
1272
|
files: "/app-files"
|
|
1273
1273
|
},
|
|
1274
|
-
arweaveDomain:
|
|
1274
|
+
arweaveDomain: Me
|
|
1275
1275
|
}, addresses: [] }), console.log("✅ Seed Protocol client initialized successfully"), x = k, b = null;
|
|
1276
1276
|
} catch (a) {
|
|
1277
1277
|
throw console.error("❌ Failed to initialize Seed Protocol client:", a), b = null, a;
|
|
1278
1278
|
}
|
|
1279
1279
|
})(), b;
|
|
1280
|
-
},
|
|
1280
|
+
}, et = async () => x || (b ? (await b, x) : (await Qe(), x)), gt = async () => {
|
|
1281
1281
|
try {
|
|
1282
1282
|
console.log("Tearing down Seed Protocol client..."), typeof k.stop == "function" && (await k.stop(), console.log("✅ Seed Protocol client stopped")), typeof k.unload == "function" && (await k.unload(), console.log("✅ Seed Protocol client unloaded")), console.log("✅ Seed Protocol client teardown complete");
|
|
1283
1283
|
} catch (a) {
|
|
@@ -1307,10 +1307,10 @@ async function ie(a, e, t) {
|
|
|
1307
1307
|
const l = i.storageTransactionId || i.storage_transaction_id;
|
|
1308
1308
|
if (!l) return i;
|
|
1309
1309
|
try {
|
|
1310
|
-
let
|
|
1311
|
-
return
|
|
1312
|
-
} catch (
|
|
1313
|
-
return console.warn(`Error enriching item with transaction ${l}:`,
|
|
1310
|
+
let d = await t.getImageMetadata(l);
|
|
1311
|
+
return d || (console.log(`Detecting image for transaction ${l}`), d = await e.detectImage(l), await t.setImageMetadata(l, d)), d.isImage && (i._imageMetadata = d, i._hasImage = !0), i;
|
|
1312
|
+
} catch (d) {
|
|
1313
|
+
return console.warn(`Error enriching item with transaction ${l}:`, d), i;
|
|
1314
1314
|
}
|
|
1315
1315
|
}), r = await Promise.all(s), n = /* @__PURE__ */ new Map();
|
|
1316
1316
|
return r.forEach((i) => {
|
|
@@ -1321,34 +1321,34 @@ async function ie(a, e, t) {
|
|
|
1321
1321
|
return n.get(l) || i;
|
|
1322
1322
|
});
|
|
1323
1323
|
}
|
|
1324
|
-
function
|
|
1324
|
+
function tt(a, e) {
|
|
1325
1325
|
const { schemaName: t, siteUrl: o, itemUrlBase: s, itemUrlPath: r } = e;
|
|
1326
1326
|
return a.map((n) => {
|
|
1327
|
-
const i = n.id || n.seedUid || n.SeedUid || n.storageTransactionId || n.storage_transaction_id, l = s != null ? `${s.replace(/\/$/, "")}/${(r ?? "attestation/view").replace(/^\//, "")}/${i}` : `${o}/${P(t)}/${i}`,
|
|
1328
|
-
let
|
|
1327
|
+
const i = n.id || n.seedUid || n.SeedUid || n.storageTransactionId || n.storage_transaction_id, l = s != null ? `${s.replace(/\/$/, "")}/${(r ?? "attestation/view").replace(/^\//, "")}/${i}` : `${o}/${P(t)}/${i}`, d = n.link || n.Link || n.import_url || n.importUrl || l;
|
|
1328
|
+
let f;
|
|
1329
1329
|
if (n.pubDate || n.PubDate) {
|
|
1330
1330
|
const g = n.pubDate || n.PubDate;
|
|
1331
|
-
|
|
1331
|
+
f = new Date(g);
|
|
1332
1332
|
} else if (n.timeCreated)
|
|
1333
|
-
|
|
1333
|
+
f = new Date(n.timeCreated * 1e3);
|
|
1334
1334
|
else if (n.publishedAt || n.createdAt || n.updatedAt) {
|
|
1335
1335
|
const g = n.publishedAt || n.createdAt || n.updatedAt;
|
|
1336
|
-
|
|
1336
|
+
f = g && typeof g == "object" && g.constructor === Date ? g : new Date(g);
|
|
1337
1337
|
} else
|
|
1338
|
-
|
|
1338
|
+
f = /* @__PURE__ */ new Date();
|
|
1339
1339
|
const p = {
|
|
1340
1340
|
...n,
|
|
1341
1341
|
// Preserve all dynamic properties first
|
|
1342
1342
|
// Map to standard feed fields
|
|
1343
1343
|
id: i,
|
|
1344
1344
|
title: n.title || n.Title || "Untitled",
|
|
1345
|
-
link:
|
|
1345
|
+
link: d,
|
|
1346
1346
|
description: n.summary || n.description || n.text || "",
|
|
1347
1347
|
content: n.html || n.content || n.summary || n.text || "",
|
|
1348
|
-
pubDate:
|
|
1349
|
-
date:
|
|
1348
|
+
pubDate: f,
|
|
1349
|
+
date: f,
|
|
1350
1350
|
// Map guid - use full URL when available for proper permalink
|
|
1351
|
-
guid: n.guid || n.Guid || n.link || n.Link ||
|
|
1351
|
+
guid: n.guid || n.Guid || n.link || n.Link || d
|
|
1352
1352
|
};
|
|
1353
1353
|
if (n._imageMetadata && n._hasImage) {
|
|
1354
1354
|
const g = n._imageMetadata;
|
|
@@ -1364,7 +1364,7 @@ function et(a, e) {
|
|
|
1364
1364
|
});
|
|
1365
1365
|
}
|
|
1366
1366
|
const Ce = (a, e, t, o, s, r, n) => {
|
|
1367
|
-
const i = P(e), l = `${$.siteUrl}/${i}/${t}`,
|
|
1367
|
+
const i = P(e), l = `${$.siteUrl}/${i}/${t}`, d = o ? `${l}?v=${o}` : l, f = `${$.title} - ${at(i)}`, p = /* @__PURE__ */ new Date(), g = O(), m = [];
|
|
1368
1368
|
if (s) {
|
|
1369
1369
|
const C = s.baseUrl.replace(/\?.*$/, ""), c = C.includes("?") ? "&" : "?";
|
|
1370
1370
|
s.hasNext && m.push({ rel: "next", href: `${C}${c}page=${s.page + 1}` }), s.page > 1 && (m.push({ rel: "previous", href: `${C}${c}page=${s.page - 1}` }), m.push({ rel: "first", href: `${C}${c}page=1` }));
|
|
@@ -1372,7 +1372,7 @@ const Ce = (a, e, t, o, s, r, n) => {
|
|
|
1372
1372
|
if (r?.length)
|
|
1373
1373
|
for (const C of r)
|
|
1374
1374
|
m.push({ rel: C.rel, href: C.href });
|
|
1375
|
-
const y =
|
|
1375
|
+
const y = tt(a, {
|
|
1376
1376
|
schemaName: e,
|
|
1377
1377
|
siteUrl: $.siteUrl,
|
|
1378
1378
|
itemUrlBase: g.itemUrlBase,
|
|
@@ -1381,7 +1381,7 @@ const Ce = (a, e, t, o, s, r, n) => {
|
|
|
1381
1381
|
switch (t) {
|
|
1382
1382
|
case "atom": {
|
|
1383
1383
|
const C = [
|
|
1384
|
-
{ href:
|
|
1384
|
+
{ href: d, rel: "self" },
|
|
1385
1385
|
{ href: $.siteUrl }
|
|
1386
1386
|
];
|
|
1387
1387
|
for (const u of m)
|
|
@@ -1391,8 +1391,8 @@ const Ce = (a, e, t, o, s, r, n) => {
|
|
|
1391
1391
|
type: u.type
|
|
1392
1392
|
});
|
|
1393
1393
|
const c = {
|
|
1394
|
-
id:
|
|
1395
|
-
title:
|
|
1394
|
+
id: d,
|
|
1395
|
+
title: f,
|
|
1396
1396
|
updated: p,
|
|
1397
1397
|
links: C,
|
|
1398
1398
|
subtitle: $.description,
|
|
@@ -1403,7 +1403,7 @@ const Ce = (a, e, t, o, s, r, n) => {
|
|
|
1403
1403
|
uri: $.author.link
|
|
1404
1404
|
} : void 0,
|
|
1405
1405
|
entries: y.map((u) => {
|
|
1406
|
-
const
|
|
1406
|
+
const h = {
|
|
1407
1407
|
id: u.id || u.link,
|
|
1408
1408
|
title: u.title || "Untitled",
|
|
1409
1409
|
updated: u.date || u.pubDate || p,
|
|
@@ -1411,64 +1411,64 @@ const Ce = (a, e, t, o, s, r, n) => {
|
|
|
1411
1411
|
...u
|
|
1412
1412
|
// Preserve all dynamic properties
|
|
1413
1413
|
};
|
|
1414
|
-
if (u.content && (
|
|
1414
|
+
if (u.content && (h.content = u.content), u.description && (h.summary = u.description), u._imageMetadata && u._hasImage) {
|
|
1415
1415
|
const w = u._imageMetadata;
|
|
1416
|
-
if (
|
|
1416
|
+
if (h.links || (h.links = []), h.links.push({
|
|
1417
1417
|
href: w.url,
|
|
1418
1418
|
rel: "enclosure",
|
|
1419
1419
|
type: w.mimeType || "image/jpeg",
|
|
1420
1420
|
length: w.size
|
|
1421
|
-
}), w.url &&
|
|
1421
|
+
}), w.url && h.content && !h.content.includes(w.url)) {
|
|
1422
1422
|
const T = `<img src="${w.url}" alt="${u.title || ""}"${w.width ? ` width="${w.width}"` : ""}${w.height ? ` height="${w.height}"` : ""} />`;
|
|
1423
|
-
|
|
1424
|
-
${
|
|
1425
|
-
${
|
|
1423
|
+
h.content = typeof h.content == "string" ? `${T}
|
|
1424
|
+
${h.content}` : { type: "html", value: `${T}
|
|
1425
|
+
${h.content.value || h.content}` };
|
|
1426
1426
|
}
|
|
1427
1427
|
}
|
|
1428
|
-
return
|
|
1428
|
+
return h;
|
|
1429
1429
|
})
|
|
1430
1430
|
};
|
|
1431
|
-
return Promise.resolve(
|
|
1431
|
+
return Promise.resolve(be(c));
|
|
1432
1432
|
}
|
|
1433
1433
|
case "json": {
|
|
1434
1434
|
const C = s?.hasNext ? `${s.baseUrl.replace(/\?.*$/, "")}?page=${s.page + 1}` : void 0, c = {
|
|
1435
|
-
title:
|
|
1435
|
+
title: f,
|
|
1436
1436
|
home_page_url: $.siteUrl,
|
|
1437
|
-
feed_url:
|
|
1437
|
+
feed_url: d,
|
|
1438
1438
|
...C && { next_url: C },
|
|
1439
1439
|
description: $.description,
|
|
1440
1440
|
author: $.author ? {
|
|
1441
1441
|
name: $.author.name,
|
|
1442
1442
|
url: $.author.link
|
|
1443
1443
|
} : void 0,
|
|
1444
|
-
items: y.map((
|
|
1444
|
+
items: y.map((h) => {
|
|
1445
1445
|
const w = {
|
|
1446
|
-
id:
|
|
1447
|
-
...
|
|
1446
|
+
id: h.id || h.link,
|
|
1447
|
+
...h
|
|
1448
1448
|
// Preserve all dynamic properties
|
|
1449
1449
|
};
|
|
1450
|
-
if (
|
|
1451
|
-
const T =
|
|
1450
|
+
if (h.title && (w.title = h.title), h.link && (w.url = h.link), h.content && (w.content_html = h.content), h.description && (w.summary = h.description), (h.date || h.pubDate) && (w.date_published = h.date || h.pubDate), h._imageMetadata && h._hasImage) {
|
|
1451
|
+
const T = h._imageMetadata;
|
|
1452
1452
|
if (w.image = T.url, w.attachments || (w.attachments = []), w.attachments.push({
|
|
1453
1453
|
url: T.url,
|
|
1454
1454
|
mime_type: T.mimeType || "image/jpeg",
|
|
1455
1455
|
size_in_bytes: T.size,
|
|
1456
|
-
title:
|
|
1456
|
+
title: h.title || "Image"
|
|
1457
1457
|
}), T.url && w.content_html && !w.content_html.includes(T.url)) {
|
|
1458
|
-
const
|
|
1459
|
-
w.content_html = `${
|
|
1458
|
+
const S = `<img src="${T.url}" alt="${h.title || ""}"${T.width ? ` width="${T.width}"` : ""}${T.height ? ` height="${T.height}"` : ""} />`;
|
|
1459
|
+
w.content_html = `${S}
|
|
1460
1460
|
${w.content_html}`;
|
|
1461
1461
|
}
|
|
1462
1462
|
}
|
|
1463
1463
|
return w;
|
|
1464
1464
|
})
|
|
1465
|
-
}, u =
|
|
1465
|
+
}, u = Fe(c);
|
|
1466
1466
|
return Promise.resolve(typeof u == "string" ? u : JSON.stringify(u));
|
|
1467
1467
|
}
|
|
1468
1468
|
case "rss":
|
|
1469
1469
|
default: {
|
|
1470
1470
|
const C = {
|
|
1471
|
-
title:
|
|
1471
|
+
title: f,
|
|
1472
1472
|
link: $.siteUrl,
|
|
1473
1473
|
description: $.description,
|
|
1474
1474
|
links: m.length ? m.map((c) => ({ rel: c.rel, href: c.href, type: c.type })) : void 0,
|
|
@@ -1490,30 +1490,30 @@ ${w.content_html}`;
|
|
|
1490
1490
|
value: c.id,
|
|
1491
1491
|
isPermaLink: typeof c.id == "string" && (c.id.startsWith("http://") || c.id.startsWith("https://"))
|
|
1492
1492
|
}), c._imageMetadata && c._hasImage) {
|
|
1493
|
-
const
|
|
1493
|
+
const h = c._imageMetadata;
|
|
1494
1494
|
u.enclosures = [{
|
|
1495
|
-
url:
|
|
1496
|
-
type:
|
|
1497
|
-
length:
|
|
1495
|
+
url: h.url,
|
|
1496
|
+
type: h.mimeType || "image/jpeg",
|
|
1497
|
+
length: h.size
|
|
1498
1498
|
}];
|
|
1499
1499
|
const w = {
|
|
1500
|
-
url:
|
|
1501
|
-
type:
|
|
1500
|
+
url: h.url,
|
|
1501
|
+
type: h.mimeType || "image/jpeg",
|
|
1502
1502
|
medium: "image"
|
|
1503
1503
|
// image, video, audio, document
|
|
1504
1504
|
};
|
|
1505
|
-
|
|
1505
|
+
h.width && (w.width = h.width), h.height && (w.height = h.height), h.size && (w.fileSize = h.size), h.format && (w.format = h.format), u["media:content"] = [w];
|
|
1506
1506
|
const T = {
|
|
1507
|
-
url:
|
|
1507
|
+
url: h.url
|
|
1508
1508
|
};
|
|
1509
|
-
|
|
1510
|
-
const
|
|
1511
|
-
if (
|
|
1512
|
-
const
|
|
1513
|
-
c.title &&
|
|
1509
|
+
h.width && (T.width = h.width), h.height && (T.height = h.height), u["media:thumbnail"] = [T], c.title && (u["media:title"] = c.title);
|
|
1510
|
+
const S = c.description || c.summary || c.title || "";
|
|
1511
|
+
if (S && (u["media:description"] = S), c.title) {
|
|
1512
|
+
const A = [];
|
|
1513
|
+
c.title && A.push(...c.title.toLowerCase().split(/\s+/).filter((D) => D.length > 3)), c.description && A.push(...c.description.toLowerCase().split(/\s+/).filter((D) => D.length > 3)), A.length > 0 && (u["media:keywords"] = [...new Set(A)].slice(0, 10).join(", "));
|
|
1514
1514
|
}
|
|
1515
|
-
if (c.authors && Array.isArray(c.authors) && c.authors.length > 0 ? u["media:credit"] = c.authors.map((
|
|
1516
|
-
value:
|
|
1515
|
+
if (c.authors && Array.isArray(c.authors) && c.authors.length > 0 ? u["media:credit"] = c.authors.map((A) => ({
|
|
1516
|
+
value: A.name || A.displayName || "Unknown",
|
|
1517
1517
|
role: "author"
|
|
1518
1518
|
})) : $.author && (u["media:credit"] = [{
|
|
1519
1519
|
value: $.author.name,
|
|
@@ -1525,15 +1525,15 @@ ${w.content_html}`;
|
|
|
1525
1525
|
"media:content": [w],
|
|
1526
1526
|
"media:thumbnail": [T],
|
|
1527
1527
|
"media:title": c.title || "Untitled",
|
|
1528
|
-
"media:description":
|
|
1529
|
-
}],
|
|
1530
|
-
const
|
|
1531
|
-
u["content:encoded"] = `${
|
|
1528
|
+
"media:description": S
|
|
1529
|
+
}], h.url && c.content && !c.content.includes(h.url)) {
|
|
1530
|
+
const A = `<img src="${h.url}" alt="${c.title || ""}"${h.width ? ` width="${h.width}"` : ""}${h.height ? ` height="${h.height}"` : ""} />`;
|
|
1531
|
+
u["content:encoded"] = `${A}
|
|
1532
1532
|
${c.content}`;
|
|
1533
1533
|
}
|
|
1534
1534
|
}
|
|
1535
1535
|
if (!u.enclosures && (c.feature_image || c.featureImage)) {
|
|
1536
|
-
const
|
|
1536
|
+
const h = c.feature_image || c.featureImage, w = typeof h == "string" && h.startsWith("http") ? h : V(h);
|
|
1537
1537
|
u.enclosures = [{
|
|
1538
1538
|
url: w,
|
|
1539
1539
|
type: "image/jpeg"
|
|
@@ -1541,13 +1541,13 @@ ${c.content}`;
|
|
|
1541
1541
|
}];
|
|
1542
1542
|
}
|
|
1543
1543
|
if (u.dc = {}, (c.date || c.pubDate) && (u.dc.date = c.date || c.pubDate), c.timeCreated) {
|
|
1544
|
-
const
|
|
1545
|
-
u.dc.dates || (u.dc.dates = []), u.dc.dates.push(
|
|
1544
|
+
const h = new Date(c.timeCreated * 1e3);
|
|
1545
|
+
u.dc.dates || (u.dc.dates = []), u.dc.dates.push(h);
|
|
1546
1546
|
}
|
|
1547
1547
|
return (c.seedUid || c.SeedUid) && (u.dc.identifier || (u.dc.identifier = []), u.dc.identifier.push(c.seedUid || c.SeedUid)), (c.storageTransactionId || c.storage_transaction_id) && (u.dc.identifier || (u.dc.identifier = []), u.dc.identifier.push(c.storageTransactionId || c.storage_transaction_id)), (c.import_url || c.importUrl) && (u.dc.source = c.import_url || c.importUrl), (c.seedUid || c.SeedUid) && (u.seedUid = c.seedUid || c.SeedUid), (c.storageTransactionId || c.storage_transaction_id) && (u.storageTransactionId = c.storageTransactionId || c.storage_transaction_id), c.timeCreated && (u.timeCreated = c.timeCreated), u;
|
|
1548
1548
|
})
|
|
1549
1549
|
};
|
|
1550
|
-
return Promise.resolve(
|
|
1550
|
+
return Promise.resolve(Ve(C));
|
|
1551
1551
|
}
|
|
1552
1552
|
}
|
|
1553
1553
|
};
|
|
@@ -1566,10 +1566,10 @@ function $e(a) {
|
|
|
1566
1566
|
const e = a.toLowerCase();
|
|
1567
1567
|
return ["rss", "atom", "json"].includes(e) ? e : null;
|
|
1568
1568
|
}
|
|
1569
|
-
function
|
|
1569
|
+
function at(a) {
|
|
1570
1570
|
return a.charAt(0).toUpperCase() + a.slice(1);
|
|
1571
1571
|
}
|
|
1572
|
-
async function
|
|
1572
|
+
async function ut(a, e, t, o, s) {
|
|
1573
1573
|
const r = $e(e);
|
|
1574
1574
|
if (!r)
|
|
1575
1575
|
return new Response(
|
|
@@ -1579,7 +1579,7 @@ async function gt(a, e, t, o, s) {
|
|
|
1579
1579
|
headers: { "Content-Type": "application/json" }
|
|
1580
1580
|
}
|
|
1581
1581
|
);
|
|
1582
|
-
const n = P.singular(a.toLowerCase()), i = P(n), l = O(),
|
|
1582
|
+
const n = P.singular(a.toLowerCase()), i = P(n), l = O(), d = Math.max(1, s ?? 1), f = l.pageSize, p = (d - 1) * f, g = d > 1 ? { page: d } : void 0;
|
|
1583
1583
|
console.log(`Schema name: ${n}`), console.log(`Collection name: ${i}`);
|
|
1584
1584
|
const m = we(), y = Q();
|
|
1585
1585
|
try {
|
|
@@ -1608,65 +1608,65 @@ async function gt(a, e, t, o, s) {
|
|
|
1608
1608
|
}
|
|
1609
1609
|
console.log(`Cache miss for ${n}:${r} - fetching items`);
|
|
1610
1610
|
const C = async () => {
|
|
1611
|
-
const D = await q(n, { limit:
|
|
1611
|
+
const D = await q(n, { limit: f, skip: p });
|
|
1612
1612
|
if (y.imageMetadata?.enabled) {
|
|
1613
|
-
const
|
|
1613
|
+
const I = new oe({
|
|
1614
1614
|
gateways: y.imageMetadata.gateways,
|
|
1615
1615
|
timeout: y.imageMetadata.timeout
|
|
1616
1616
|
});
|
|
1617
|
-
return ie(D,
|
|
1617
|
+
return ie(D, I, m);
|
|
1618
1618
|
}
|
|
1619
1619
|
return D;
|
|
1620
|
-
}, c = y.enabled &&
|
|
1620
|
+
}, c = y.enabled && d === 1 ? await m.withRefreshLock(n, async () => {
|
|
1621
1621
|
const D = await m.getFeedData(n);
|
|
1622
|
-
let
|
|
1622
|
+
let I;
|
|
1623
1623
|
if (D) {
|
|
1624
1624
|
console.log(`Incremental fetch: last processed timestamp: ${D.lastProcessedTimestamp}`);
|
|
1625
|
-
const F = await q(n, { limit:
|
|
1626
|
-
N.length > 0 ? (console.log(`Found ${N.length} new items, merging with ${D.items.length} cached items`),
|
|
1625
|
+
const F = await q(n, { limit: f, skip: 0 }), N = m.filterNewItems(F, D.lastProcessedTimestamp);
|
|
1626
|
+
N.length > 0 ? (console.log(`Found ${N.length} new items, merging with ${D.items.length} cached items`), I = m.mergeItems(D.items, N).slice(0, f)) : I = D.items;
|
|
1627
1627
|
} else {
|
|
1628
1628
|
console.log("Cold cache - fetching page 1");
|
|
1629
|
-
const F = await
|
|
1630
|
-
F && console.log(`Client initialized: ${F.isInitialized()}`),
|
|
1629
|
+
const F = await et();
|
|
1630
|
+
F && console.log(`Client initialized: ${F.isInitialized()}`), I = await q(n, { limit: f, skip: 0 }), console.log(`Found ${I.length} feed items for schema ${n}`);
|
|
1631
1631
|
}
|
|
1632
1632
|
if (y.imageMetadata?.enabled) {
|
|
1633
1633
|
const F = new oe({
|
|
1634
1634
|
gateways: y.imageMetadata.gateways,
|
|
1635
1635
|
timeout: y.imageMetadata.timeout
|
|
1636
|
-
}), N = await ie(
|
|
1637
|
-
return await m.setFeedData(n,
|
|
1636
|
+
}), N = await ie(I, F, m);
|
|
1637
|
+
return await m.setFeedData(n, I), N;
|
|
1638
1638
|
}
|
|
1639
|
-
return await m.setFeedData(n,
|
|
1640
|
-
}) : await C(), u = `${$.feedUrl}/${i}/${r}`,
|
|
1641
|
-
if (
|
|
1642
|
-
const D = /* @__PURE__ */ new Date(),
|
|
1639
|
+
return await m.setFeedData(n, I), I;
|
|
1640
|
+
}) : await C(), u = `${$.feedUrl}/${i}/${r}`, h = c.length === f, w = [];
|
|
1641
|
+
if (d === 1) {
|
|
1642
|
+
const D = /* @__PURE__ */ new Date(), I = new Date(D.getFullYear(), D.getMonth() - 1, 1);
|
|
1643
1643
|
w.push({
|
|
1644
1644
|
rel: "prev-archive",
|
|
1645
|
-
href: `${$.feedUrl}/${i}/archive/${
|
|
1645
|
+
href: `${$.feedUrl}/${i}/archive/${I.getFullYear()}/${I.getMonth() + 1}/${r}`
|
|
1646
1646
|
});
|
|
1647
1647
|
}
|
|
1648
|
-
const
|
|
1648
|
+
const S = await Ce(
|
|
1649
1649
|
c,
|
|
1650
1650
|
n,
|
|
1651
1651
|
r,
|
|
1652
1652
|
o,
|
|
1653
1653
|
{
|
|
1654
|
-
page:
|
|
1655
|
-
pageSize:
|
|
1656
|
-
hasNext:
|
|
1654
|
+
page: d,
|
|
1655
|
+
pageSize: f,
|
|
1656
|
+
hasNext: h,
|
|
1657
1657
|
baseUrl: u
|
|
1658
1658
|
},
|
|
1659
1659
|
w.length ? w : void 0,
|
|
1660
1660
|
!1
|
|
1661
|
-
),
|
|
1661
|
+
), A = De(r);
|
|
1662
1662
|
if (y.enabled) {
|
|
1663
|
-
await m.setFeedContent(n, r,
|
|
1664
|
-
const D = await m.getFeedContent(n, r, g),
|
|
1665
|
-
return new Response(
|
|
1663
|
+
await m.setFeedContent(n, r, S, A, g);
|
|
1664
|
+
const D = await m.getFeedContent(n, r, g), I = D?.etag || "", F = D?.lastModified || Math.floor(Date.now() / 1e3);
|
|
1665
|
+
return new Response(S, {
|
|
1666
1666
|
status: 200,
|
|
1667
1667
|
headers: {
|
|
1668
|
-
"Content-Type":
|
|
1669
|
-
ETag:
|
|
1668
|
+
"Content-Type": A,
|
|
1669
|
+
ETag: I,
|
|
1670
1670
|
"Last-Modified": new Date(F * 1e3).toUTCString(),
|
|
1671
1671
|
"Cache-Control": "public, max-age=3600, s-maxage=3600, must-revalidate",
|
|
1672
1672
|
"X-Feed-Schema": n,
|
|
@@ -1675,10 +1675,10 @@ async function gt(a, e, t, o, s) {
|
|
|
1675
1675
|
}
|
|
1676
1676
|
});
|
|
1677
1677
|
}
|
|
1678
|
-
return new Response(
|
|
1678
|
+
return new Response(S, {
|
|
1679
1679
|
status: 200,
|
|
1680
1680
|
headers: {
|
|
1681
|
-
"Content-Type":
|
|
1681
|
+
"Content-Type": A,
|
|
1682
1682
|
"Cache-Control": "public, max-age=3600, s-maxage=3600",
|
|
1683
1683
|
"X-Feed-Schema": n,
|
|
1684
1684
|
"X-Feed-Format": r
|
|
@@ -1713,7 +1713,7 @@ async function gt(a, e, t, o, s) {
|
|
|
1713
1713
|
);
|
|
1714
1714
|
}
|
|
1715
1715
|
}
|
|
1716
|
-
async function
|
|
1716
|
+
async function pt(a, e, t, o, s, r) {
|
|
1717
1717
|
if (e < 1970 || e > 2100)
|
|
1718
1718
|
return new Response(
|
|
1719
1719
|
JSON.stringify({ error: `Invalid year: ${e}` }),
|
|
@@ -1730,24 +1730,24 @@ async function ut(a, e, t, o, s, r) {
|
|
|
1730
1730
|
JSON.stringify({ error: `Invalid feed format: ${o}` }),
|
|
1731
1731
|
{ status: 400, headers: { "Content-Type": "application/json" } }
|
|
1732
1732
|
);
|
|
1733
|
-
const i = P.singular(a.toLowerCase()), l = P(i),
|
|
1733
|
+
const i = P.singular(a.toLowerCase()), l = P(i), d = { archive: { year: e, month: t } }, f = we(), p = Q();
|
|
1734
1734
|
try {
|
|
1735
1735
|
if (p.enabled) {
|
|
1736
|
-
const
|
|
1737
|
-
if (
|
|
1738
|
-
return s && ye(s,
|
|
1736
|
+
const S = await f.getFeedContent(i, n, d);
|
|
1737
|
+
if (S)
|
|
1738
|
+
return s && ye(s, S.etag) ? new Response(null, {
|
|
1739
1739
|
status: 304,
|
|
1740
1740
|
headers: {
|
|
1741
|
-
ETag:
|
|
1742
|
-
"Last-Modified": new Date(
|
|
1741
|
+
ETag: S.etag,
|
|
1742
|
+
"Last-Modified": new Date(S.lastModified * 1e3).toUTCString(),
|
|
1743
1743
|
"Cache-Control": "public, max-age=86400, s-maxage=86400, must-revalidate"
|
|
1744
1744
|
}
|
|
1745
|
-
}) : new Response(
|
|
1745
|
+
}) : new Response(S.content, {
|
|
1746
1746
|
status: 200,
|
|
1747
1747
|
headers: {
|
|
1748
|
-
"Content-Type":
|
|
1749
|
-
ETag:
|
|
1750
|
-
"Last-Modified": new Date(
|
|
1748
|
+
"Content-Type": S.contentType,
|
|
1749
|
+
ETag: S.etag,
|
|
1750
|
+
"Last-Modified": new Date(S.lastModified * 1e3).toUTCString(),
|
|
1751
1751
|
"Cache-Control": "public, max-age=86400, s-maxage=86400, must-revalidate",
|
|
1752
1752
|
"X-Feed-Schema": i,
|
|
1753
1753
|
"X-Feed-Format": n,
|
|
@@ -1755,11 +1755,11 @@ async function ut(a, e, t, o, s, r) {
|
|
|
1755
1755
|
}
|
|
1756
1756
|
});
|
|
1757
1757
|
}
|
|
1758
|
-
const g = await
|
|
1758
|
+
const g = await Be(i, e, t), m = `${$.feedUrl}/${l}/${n}`, y = `${$.feedUrl}/${l}/archive`, C = [
|
|
1759
1759
|
{ rel: "prev-archive", href: `${y}/${t === 1 ? e - 1 : e}/${t === 1 ? 12 : t - 1}/${n}` },
|
|
1760
1760
|
{ rel: "current", href: m }
|
|
1761
|
-
], c = t === 12 ? e + 1 : e, u = t === 12 ? 1 : t + 1,
|
|
1762
|
-
(c <
|
|
1761
|
+
], c = t === 12 ? e + 1 : e, u = t === 12 ? 1 : t + 1, h = /* @__PURE__ */ new Date();
|
|
1762
|
+
(c < h.getFullYear() || c === h.getFullYear() && u <= h.getMonth() + 1) && C.push({ rel: "next-archive", href: `${y}/${c}/${u}/${n}` });
|
|
1763
1763
|
const w = await Ce(
|
|
1764
1764
|
g,
|
|
1765
1765
|
i,
|
|
@@ -1770,13 +1770,13 @@ async function ut(a, e, t, o, s, r) {
|
|
|
1770
1770
|
!0
|
|
1771
1771
|
), T = De(n);
|
|
1772
1772
|
if (p.enabled) {
|
|
1773
|
-
await
|
|
1774
|
-
const
|
|
1773
|
+
await f.setFeedContent(i, n, w, T, d);
|
|
1774
|
+
const S = await f.getFeedContent(i, n, d), A = S?.etag || "", D = S?.lastModified || Math.floor(Date.now() / 1e3);
|
|
1775
1775
|
return new Response(w, {
|
|
1776
1776
|
status: 200,
|
|
1777
1777
|
headers: {
|
|
1778
1778
|
"Content-Type": T,
|
|
1779
|
-
ETag:
|
|
1779
|
+
ETag: A,
|
|
1780
1780
|
"Last-Modified": new Date(D * 1e3).toUTCString(),
|
|
1781
1781
|
"Cache-Control": "public, max-age=86400, s-maxage=86400, must-revalidate",
|
|
1782
1782
|
"X-Feed-Schema": i,
|
|
@@ -1806,14 +1806,14 @@ async function ut(a, e, t, o, s, r) {
|
|
|
1806
1806
|
}
|
|
1807
1807
|
export {
|
|
1808
1808
|
Ce as createFeed,
|
|
1809
|
-
|
|
1809
|
+
et as getClient,
|
|
1810
1810
|
q as getFeedItemsBySchemaName,
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1811
|
+
Be as getFeedItemsBySchemaNameForMonth,
|
|
1812
|
+
pt as handleArchiveFeedRequest,
|
|
1813
|
+
ut as handleFeedRequest,
|
|
1814
|
+
Qe as initializeSeedClient,
|
|
1815
1815
|
O as loadFeedConfig,
|
|
1816
|
-
|
|
1817
|
-
|
|
1816
|
+
ht as resetCacheManager,
|
|
1817
|
+
gt as teardownSeedClient
|
|
1818
1818
|
};
|
|
1819
1819
|
//# sourceMappingURL=index.js.map
|