@seedprotocol/feed 0.4.9 → 0.4.11
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/index.d.ts.map +1 -1
- package/dist/index.js +93 -90
- package/dist/index.js.map +1 -1
- package/dist/utils/arweaveUrl.d.ts +7 -0
- package/dist/utils/arweaveUrl.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,wBAAwB,EAAE,CAAC;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAA+C,MAAM,SAAS,CAAC;AAuBpG;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAAa,OAAO,CAAC,IAAI,CAkCzD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAa,OAAO,CAAC,GAAG,CAe7C,CAAA;AAGD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,IAAI,CAmBvD,CAAA;AAkLD,eAAO,MAAM,UAAU,GACrB,OAAO,WAAW,EAAE,EACpB,YAAY,MAAM,EAClB,QAAQ,UAAU,EAClB,YAAY,MAAM,KACjB,OAAO,CAAC,MAAM,CAgUhB,CAAA;AA8BD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,iBAAiB,EAAE,MAAM,EACzB,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,EAC3B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,CAAC,CAqNnB"}
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { gql as
|
|
3
|
-
import
|
|
4
|
-
import { generateJsonFeed as
|
|
5
|
-
import { create as
|
|
6
|
-
import { createHash as
|
|
1
|
+
import { BaseArweaveClient as Q, EasClient as ee, getSeedsBySchemaName as te, getItemVersionsFromEas as ae, getItemPropertiesFromEas as ne, setSchemaUidForSchemaDefinition as re, DEFAULT_ARWEAVE_GATEWAYS as X, client as T, DEFAULT_ARWEAVE_HOST as se } from "@seedprotocol/sdk";
|
|
2
|
+
import { gql as ie } from "graphql-request";
|
|
3
|
+
import U from "pluralize";
|
|
4
|
+
import { generateJsonFeed as oe, generateAtomFeed as ce } from "feedsmith";
|
|
5
|
+
import { create as le } from "xmlbuilder2";
|
|
6
|
+
import { createHash as de } from "crypto";
|
|
7
7
|
import { promises as y } from "fs";
|
|
8
8
|
import { join as S } from "path";
|
|
9
9
|
import N from "image-size";
|
|
10
|
+
function b(a) {
|
|
11
|
+
return `https://${Q.getHost()}/${a}`;
|
|
12
|
+
}
|
|
10
13
|
function K() {
|
|
11
14
|
const a = process.env.FEED_ITEM_URL_BASE?.trim() || "https://optimism-sepolia.easscan.org", e = process.env.FEED_ITEM_URL_PATH?.trim() || "attestation/view", t = process.env.FEED_SITE_URL?.trim() || "https://seedprotocol.io";
|
|
12
15
|
return { itemUrlBase: a, itemUrlPath: e, siteUrl: t };
|
|
13
16
|
}
|
|
14
17
|
const M = [
|
|
15
18
|
"0x0000000000000000000000000000000000000000000000000000000000000020"
|
|
16
|
-
],
|
|
19
|
+
], fe = ie`
|
|
17
20
|
query GetSeeds($where: AttestationWhereInput!, $take: Int) {
|
|
18
21
|
itemSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }], take: $take) {
|
|
19
22
|
id
|
|
@@ -31,22 +34,22 @@ const M = [
|
|
|
31
34
|
isOffchain
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
|
-
`, L = (a) => a.replace(/_([a-z])/g, (e, t) => t.toUpperCase()),
|
|
37
|
+
`, L = (a) => a.replace(/_([a-z])/g, (e, t) => t.toUpperCase()), he = (a) => {
|
|
35
38
|
const e = new Date(a * 1e3), t = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], r = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], i = t[e.getUTCDay()], n = r[e.getUTCMonth()], o = e.getUTCFullYear(), l = e.getUTCDate().toString().padStart(2, "0"), d = e.getUTCHours().toString().padStart(2, "0"), h = e.getUTCMinutes().toString().padStart(2, "0"), u = e.getUTCSeconds().toString().padStart(2, "0");
|
|
36
39
|
return `${i}, ${l} ${n} ${o} ${d}:${h}:${u} GMT`;
|
|
37
|
-
},
|
|
40
|
+
}, ge = (a) => a === "image" ? "images" : a === "post" ? "posts" : a.toLowerCase() + "s", ue = (a) => {
|
|
38
41
|
const [e, t, r] = a.split("_");
|
|
39
42
|
if (!e || !t) return null;
|
|
40
43
|
const i = r === "ids";
|
|
41
44
|
return { propertyName: e.endsWith("s") ? e : e + "s", modelName: t, isList: i };
|
|
42
|
-
},
|
|
45
|
+
}, pe = (a, e, t, r) => {
|
|
43
46
|
const { itemUrlBase: i, itemUrlPath: n, siteUrl: o } = r;
|
|
44
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);
|
|
45
|
-
const l = 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, d = a.storageTransactionId && typeof a.storageTransactionId == "string" && a.storageTransactionId.trim() !== "" && a.storageTransactionId !== "undefined" && a.storageTransactionId !== e ? a.storageTransactionId.trim() : null, h = l || d, u =
|
|
48
|
+
const l = 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, d = a.storageTransactionId && typeof a.storageTransactionId == "string" && a.storageTransactionId.trim() !== "" && a.storageTransactionId !== "undefined" && a.storageTransactionId !== e ? a.storageTransactionId.trim() : null, h = l || d, u = ge(t), g = e && typeof e == "string" && e.trim() !== "" ? e : "unknown";
|
|
46
49
|
let s;
|
|
47
50
|
if (h && h !== e && h.length > 0)
|
|
48
51
|
try {
|
|
49
|
-
s =
|
|
52
|
+
s = b(h);
|
|
50
53
|
} catch (p) {
|
|
51
54
|
console.error("[feed] [setFeedItemDefaults] Error generating Arweave URL:", p), i != null ? s = `${i.replace(/\/$/, "")}/${(n ?? "attestation/view").replace(/^\//, "")}/${g}` : s = `${o.replace(/\/$/, "")}/${u}/${g}`;
|
|
52
55
|
}
|
|
@@ -56,11 +59,11 @@ const M = [
|
|
|
56
59
|
!c || c === "undefined" || typeof c == "string" && c.trim() === "" ? (a.link = s, a.Link = s) : ((!a.link || a.link === "undefined") && (a.link = c), (!a.Link || a.Link === "undefined") && (a.Link = c));
|
|
57
60
|
const f = a.guid || a.Guid;
|
|
58
61
|
if (!f || f === "undefined" || typeof f == "string" && f.trim() === "" ? (a.guid = a.link || s, a.Guid = a.guid) : ((!a.guid || a.guid === "undefined") && (a.guid = f), (!a.Guid || a.Guid === "undefined") && (a.Guid = f)), a.timeCreated && !a.pubDate && !a.PubDate) {
|
|
59
|
-
const p =
|
|
62
|
+
const p = he(a.timeCreated);
|
|
60
63
|
a.pubDate = p, a.PubDate = p;
|
|
61
64
|
} else a.pubDate && !a.PubDate ? a.PubDate = a.pubDate : a.PubDate && !a.pubDate && (a.pubDate = a.PubDate);
|
|
62
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);
|
|
63
|
-
}, B = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(),
|
|
66
|
+
}, B = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), me = /* @__PURE__ */ new Map(), ye = async (a, e) => {
|
|
64
67
|
let t;
|
|
65
68
|
try {
|
|
66
69
|
t = JSON.parse(a.decodedDataJson)[0]?.value ?? {};
|
|
@@ -72,7 +75,7 @@ const M = [
|
|
|
72
75
|
if (!r)
|
|
73
76
|
return;
|
|
74
77
|
const i = a.schemaId;
|
|
75
|
-
|
|
78
|
+
re({
|
|
76
79
|
text: r,
|
|
77
80
|
schemaUid: i
|
|
78
81
|
});
|
|
@@ -81,7 +84,7 @@ const M = [
|
|
|
81
84
|
if (d || h)
|
|
82
85
|
if (n = !0, Array.isArray(t.value)) {
|
|
83
86
|
if (o = !0, h) {
|
|
84
|
-
const f =
|
|
87
|
+
const f = ue(r);
|
|
85
88
|
f && (r = f.propertyName);
|
|
86
89
|
}
|
|
87
90
|
t.value.forEach((f) => {
|
|
@@ -112,7 +115,7 @@ const M = [
|
|
|
112
115
|
attester: o.attester
|
|
113
116
|
});
|
|
114
117
|
}
|
|
115
|
-
const t = await
|
|
118
|
+
const t = await ae({ seedUids: e });
|
|
116
119
|
for (let n = 0; n < t.length; n++) {
|
|
117
120
|
const o = t[n], l = o.refUID;
|
|
118
121
|
q.set(o.id, l);
|
|
@@ -122,12 +125,12 @@ const M = [
|
|
|
122
125
|
const r = [];
|
|
123
126
|
for (const [n, o] of P.entries()) {
|
|
124
127
|
const d = [...o].sort((h, u) => u.timeCreated - h.timeCreated)[0];
|
|
125
|
-
d && (r.push(d.id),
|
|
128
|
+
d && (r.push(d.id), me.set(n, d.id));
|
|
126
129
|
}
|
|
127
|
-
const i = await
|
|
130
|
+
const i = await ne({ versionUids: r });
|
|
128
131
|
for (let n = 0; n < i.length; n++)
|
|
129
|
-
await
|
|
130
|
-
},
|
|
132
|
+
await ye(i[n], a);
|
|
133
|
+
}, we = /* @__PURE__ */ new Set([
|
|
131
134
|
"seedUid",
|
|
132
135
|
"SeedUid",
|
|
133
136
|
"timeCreated",
|
|
@@ -138,13 +141,13 @@ const M = [
|
|
|
138
141
|
"storageTransactionId",
|
|
139
142
|
"storageProviderTransactionId"
|
|
140
143
|
]);
|
|
141
|
-
function
|
|
144
|
+
function Ce(a) {
|
|
142
145
|
const e = Array.from(D.entries()).filter(
|
|
143
146
|
([t]) => B.get(t) === a
|
|
144
147
|
);
|
|
145
148
|
for (const [, t] of e) {
|
|
146
149
|
const r = Object.keys(t).filter(
|
|
147
|
-
(i) => !i.startsWith("_") && !
|
|
150
|
+
(i) => !i.startsWith("_") && !we.has(i)
|
|
148
151
|
);
|
|
149
152
|
for (const i of r) {
|
|
150
153
|
const n = t[i];
|
|
@@ -163,7 +166,7 @@ function we(a) {
|
|
|
163
166
|
const s = D.get(g), c = s?.storageTransactionId ?? s?.storage_transaction_id;
|
|
164
167
|
if (c && typeof c == "string" && c.trim())
|
|
165
168
|
try {
|
|
166
|
-
h.push(
|
|
169
|
+
h.push(b(c)), u = !0;
|
|
167
170
|
} catch {
|
|
168
171
|
h.push(g);
|
|
169
172
|
}
|
|
@@ -184,7 +187,7 @@ function we(a) {
|
|
|
184
187
|
if (d && typeof d == "string" && d.trim())
|
|
185
188
|
try {
|
|
186
189
|
const h = i.endsWith("_id") ? i.replace(/_id$/, "") : i;
|
|
187
|
-
if (t[h] =
|
|
190
|
+
if (t[h] = b(d), h !== i) {
|
|
188
191
|
delete t[i];
|
|
189
192
|
const u = L(i);
|
|
190
193
|
u !== i && delete t[u];
|
|
@@ -196,16 +199,16 @@ function we(a) {
|
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
201
|
const k = async (a) => {
|
|
199
|
-
const e = K(), t =
|
|
202
|
+
const e = K(), t = ee.getEasClient(), r = await te(a);
|
|
200
203
|
await W(r);
|
|
201
|
-
const i = Array.from(x), { itemSeeds: n } = await t.request(
|
|
204
|
+
const i = Array.from(x), { itemSeeds: n } = await t.request(fe, {
|
|
202
205
|
where: {
|
|
203
206
|
id: {
|
|
204
207
|
in: i
|
|
205
208
|
}
|
|
206
209
|
}
|
|
207
210
|
});
|
|
208
|
-
await W(n ?? []),
|
|
211
|
+
await W(n ?? []), Ce(a);
|
|
209
212
|
const o = {
|
|
210
213
|
itemUrlBase: e.itemUrlBase,
|
|
211
214
|
itemUrlPath: e.itemUrlPath,
|
|
@@ -213,11 +216,11 @@ const k = async (a) => {
|
|
|
213
216
|
};
|
|
214
217
|
return Array.from(D.entries()).filter(([d]) => B.get(d) === a).map(([, d]) => {
|
|
215
218
|
const h = d.seedUid || d.SeedUid;
|
|
216
|
-
return
|
|
219
|
+
return pe(d, h, a, o), d;
|
|
217
220
|
});
|
|
218
|
-
}, R = "http://purl.org/dc/elements/1.1/", j = "http://purl.org/rss/1.0/modules/content/",
|
|
219
|
-
function
|
|
220
|
-
return
|
|
221
|
+
}, R = "http://purl.org/dc/elements/1.1/", j = "http://purl.org/rss/1.0/modules/content/", I = "http://search.yahoo.com/mrss/", De = /* @__PURE__ */ new Set(["Title", "Link", "Guid", "PubDate", "SeedUid"]);
|
|
222
|
+
function Ee(a, e) {
|
|
223
|
+
return De.has(a) ? a.charAt(0).toLowerCase() + a.slice(1) in e : !1;
|
|
221
224
|
}
|
|
222
225
|
const z = [
|
|
223
226
|
"title",
|
|
@@ -251,13 +254,13 @@ function O(a) {
|
|
|
251
254
|
}
|
|
252
255
|
return String(a);
|
|
253
256
|
}
|
|
254
|
-
function
|
|
257
|
+
function Se(a) {
|
|
255
258
|
return /[<>&]|]]>/.test(a);
|
|
256
259
|
}
|
|
257
260
|
function w(a, e) {
|
|
258
261
|
const t = String(e);
|
|
259
262
|
if (t !== "")
|
|
260
|
-
if (
|
|
263
|
+
if (Se(t))
|
|
261
264
|
if (t.includes("]]>")) {
|
|
262
265
|
const r = t.split("]]>");
|
|
263
266
|
for (let i = 0; i < r.length; i++)
|
|
@@ -331,31 +334,31 @@ function H(a, e, t, r) {
|
|
|
331
334
|
let d = null;
|
|
332
335
|
for (const [u, g] of Object.entries(o))
|
|
333
336
|
g != null && (u === "value" ? d = String(g) : l[u] = String(g));
|
|
334
|
-
const h = a.ele(
|
|
337
|
+
const h = a.ele(I, n, l);
|
|
335
338
|
d !== null && w(h, d);
|
|
336
339
|
}
|
|
337
340
|
return;
|
|
338
341
|
}
|
|
339
342
|
if (e.startsWith("media:") && typeof t == "string") {
|
|
340
|
-
const n = e.slice(6), o = a.ele(
|
|
343
|
+
const n = e.slice(6), o = a.ele(I, n);
|
|
341
344
|
w(o, t);
|
|
342
345
|
return;
|
|
343
346
|
}
|
|
344
347
|
if (e === "media:group" && Array.isArray(t)) {
|
|
345
348
|
for (const n of t)
|
|
346
349
|
if (n && typeof n == "object") {
|
|
347
|
-
const o = a.ele(
|
|
350
|
+
const o = a.ele(I, "group");
|
|
348
351
|
for (const [l, d] of Object.entries(n))
|
|
349
352
|
if (d != null && l.startsWith("media:")) {
|
|
350
353
|
const h = l.slice(6);
|
|
351
354
|
if (Array.isArray(d)) {
|
|
352
355
|
for (const u of d)
|
|
353
356
|
if (u && typeof u == "object") {
|
|
354
|
-
const g = o.ele(
|
|
357
|
+
const g = o.ele(I, h);
|
|
355
358
|
for (const [s, c] of Object.entries(u))
|
|
356
359
|
c != null && (s === "url" || s === "value" ? w(g, String(c)) : g.att(s, String(c)));
|
|
357
360
|
}
|
|
358
|
-
} else typeof d == "string" && w(o.ele(
|
|
361
|
+
} else typeof d == "string" && w(o.ele(I, h), d);
|
|
359
362
|
}
|
|
360
363
|
}
|
|
361
364
|
return;
|
|
@@ -393,11 +396,11 @@ function H(a, e, t, r) {
|
|
|
393
396
|
const i = a.ele(e);
|
|
394
397
|
w(i, String(t));
|
|
395
398
|
}
|
|
396
|
-
function
|
|
397
|
-
const e =
|
|
399
|
+
function $e(a) {
|
|
400
|
+
const e = le({ version: "1.0", encoding: "UTF-8" }), r = e.ele("rss", { version: "2.0" }).ele("channel", {
|
|
398
401
|
"xmlns:dc": R,
|
|
399
402
|
"xmlns:content": j,
|
|
400
|
-
"xmlns:media":
|
|
403
|
+
"xmlns:media": I
|
|
401
404
|
});
|
|
402
405
|
r.ele("title").txt(a.title), a.link && r.ele("link").txt(a.link), r.ele("description").txt(a.description), a.language && r.ele("language").txt(a.language), a.copyright && r.ele("copyright").txt(a.copyright), a.webMaster && r.ele("webMaster").txt(a.webMaster), a.pubDate && r.ele("pubDate").txt(O(a.pubDate)), a.lastBuildDate && r.ele("lastBuildDate").txt(O(a.lastBuildDate));
|
|
403
406
|
const i = new Set(z);
|
|
@@ -406,7 +409,7 @@ function Se(a) {
|
|
|
406
409
|
for (const h of z)
|
|
407
410
|
h in n && (H(o, h, n[h], n), l.add(h));
|
|
408
411
|
const d = Object.keys(n).filter(
|
|
409
|
-
(h) => !l.has(h) && !i.has(h) && !h.startsWith("_") && !
|
|
412
|
+
(h) => !l.has(h) && !i.has(h) && !h.startsWith("_") && !Ee(h, n)
|
|
410
413
|
).sort();
|
|
411
414
|
for (const h of d)
|
|
412
415
|
H(o, h, n[h], n);
|
|
@@ -414,28 +417,28 @@ function Se(a) {
|
|
|
414
417
|
return e.end({ prettyPrint: !0 });
|
|
415
418
|
}
|
|
416
419
|
function Y(a) {
|
|
417
|
-
return `"${
|
|
420
|
+
return `"${de("md5").update(a).digest("hex").substring(0, 16)}"`;
|
|
418
421
|
}
|
|
419
422
|
function Ie(a, e, t, r) {
|
|
420
423
|
const i = `${a}-${e}-${t}-${r}`;
|
|
421
424
|
return Y(i);
|
|
422
425
|
}
|
|
423
|
-
function
|
|
426
|
+
function Te(a, e, t, r) {
|
|
424
427
|
const i = `${a}-${e}-${t}-${r}`;
|
|
425
428
|
return Y(i);
|
|
426
429
|
}
|
|
427
|
-
function
|
|
430
|
+
function _e(a, e) {
|
|
428
431
|
const t = (r) => r.replace(/^"|"$/g, "");
|
|
429
432
|
return t(a) === t(e);
|
|
430
433
|
}
|
|
431
|
-
function
|
|
434
|
+
function Me(a) {
|
|
432
435
|
return a ? a.split(",").map((e) => e.trim()).filter((e) => e.length > 0) : [];
|
|
433
436
|
}
|
|
434
|
-
function
|
|
435
|
-
const t =
|
|
436
|
-
return t.length === 0 ? !1 : t.includes("*") ? !0 : t.some((r) =>
|
|
437
|
+
function Ae(a, e) {
|
|
438
|
+
const t = Me(a);
|
|
439
|
+
return t.length === 0 ? !1 : t.includes("*") ? !0 : t.some((r) => _e(r, e));
|
|
437
440
|
}
|
|
438
|
-
class
|
|
441
|
+
class Ue {
|
|
439
442
|
feedDataCache = /* @__PURE__ */ new Map();
|
|
440
443
|
feedContentCache = /* @__PURE__ */ new Map();
|
|
441
444
|
imageMetadataCache = /* @__PURE__ */ new Map();
|
|
@@ -483,7 +486,7 @@ class Ae {
|
|
|
483
486
|
* Set cached feed content for a schema and format
|
|
484
487
|
*/
|
|
485
488
|
setFeedContent(e, t, r, i) {
|
|
486
|
-
const n = `${e}:${t}`, o = Math.floor(Date.now() / 1e3), l = o + this.config.ttl, d =
|
|
489
|
+
const n = `${e}:${t}`, o = Math.floor(Date.now() / 1e3), l = o + this.config.ttl, d = Te(e, t, o, r.length), h = {
|
|
487
490
|
content: r,
|
|
488
491
|
contentType: i,
|
|
489
492
|
etag: d,
|
|
@@ -565,7 +568,7 @@ class Ae {
|
|
|
565
568
|
};
|
|
566
569
|
}
|
|
567
570
|
}
|
|
568
|
-
class
|
|
571
|
+
class be {
|
|
569
572
|
cacheDir;
|
|
570
573
|
config;
|
|
571
574
|
constructor(e) {
|
|
@@ -762,7 +765,7 @@ class Ue {
|
|
|
762
765
|
}
|
|
763
766
|
}
|
|
764
767
|
}
|
|
765
|
-
class
|
|
768
|
+
class Fe {
|
|
766
769
|
memoryCache;
|
|
767
770
|
fileCache;
|
|
768
771
|
config;
|
|
@@ -773,7 +776,7 @@ class be {
|
|
|
773
776
|
errors: 0
|
|
774
777
|
};
|
|
775
778
|
constructor(e) {
|
|
776
|
-
this.config = e, this.memoryCache = new
|
|
779
|
+
this.config = e, this.memoryCache = new Ue(e), this.fileCache = new be(e);
|
|
777
780
|
}
|
|
778
781
|
/**
|
|
779
782
|
* Get cached feed data for a schema
|
|
@@ -1107,35 +1110,35 @@ class V {
|
|
|
1107
1110
|
}
|
|
1108
1111
|
}
|
|
1109
1112
|
}
|
|
1110
|
-
let _,
|
|
1111
|
-
function
|
|
1113
|
+
let _, $ = null, A = null;
|
|
1114
|
+
function ve() {
|
|
1112
1115
|
if (!A) {
|
|
1113
1116
|
const a = Z();
|
|
1114
|
-
A = new
|
|
1117
|
+
A = new Fe(a);
|
|
1115
1118
|
}
|
|
1116
1119
|
return A;
|
|
1117
1120
|
}
|
|
1118
|
-
function
|
|
1121
|
+
function Xe() {
|
|
1119
1122
|
A = null;
|
|
1120
1123
|
}
|
|
1121
|
-
const
|
|
1122
|
-
if (
|
|
1123
|
-
return
|
|
1124
|
+
const Pe = async () => {
|
|
1125
|
+
if ($)
|
|
1126
|
+
return $;
|
|
1124
1127
|
if (!_)
|
|
1125
|
-
return
|
|
1128
|
+
return $ = (async () => {
|
|
1126
1129
|
try {
|
|
1127
1130
|
console.log("Initializing Seed Protocol client..."), await T.init({ config: {
|
|
1128
1131
|
endpoints: {
|
|
1129
1132
|
filePaths: "app-files",
|
|
1130
1133
|
files: "/app-files"
|
|
1131
1134
|
},
|
|
1132
|
-
arweaveDomain:
|
|
1133
|
-
}, addresses: [] }), console.log("✅ Seed Protocol client initialized successfully"), _ = T,
|
|
1135
|
+
arweaveDomain: se
|
|
1136
|
+
}, addresses: [] }), console.log("✅ Seed Protocol client initialized successfully"), _ = T, $ = null;
|
|
1134
1137
|
} catch (a) {
|
|
1135
|
-
throw console.error("❌ Failed to initialize Seed Protocol client:", a),
|
|
1138
|
+
throw console.error("❌ Failed to initialize Seed Protocol client:", a), $ = null, a;
|
|
1136
1139
|
}
|
|
1137
|
-
})(),
|
|
1138
|
-
}, G = async () => _ || (
|
|
1140
|
+
})(), $;
|
|
1141
|
+
}, G = async () => _ || ($ ? (await $, _) : (await Pe(), _)), Ke = async () => {
|
|
1139
1142
|
try {
|
|
1140
1143
|
console.log("Tearing down Seed Protocol client..."), typeof T.stop == "function" && (await T.stop(), console.log("✅ Seed Protocol client stopped")), typeof T.unload == "function" && (await T.unload(), console.log("✅ Seed Protocol client unloaded")), console.log("✅ Seed Protocol client teardown complete");
|
|
1141
1144
|
} catch (a) {
|
|
@@ -1178,10 +1181,10 @@ async function J(a, e, t) {
|
|
|
1178
1181
|
return o.get(d) || l;
|
|
1179
1182
|
});
|
|
1180
1183
|
}
|
|
1181
|
-
function
|
|
1184
|
+
function ke(a, e) {
|
|
1182
1185
|
const { schemaName: t, siteUrl: r, itemUrlBase: i, itemUrlPath: n } = e;
|
|
1183
1186
|
return a.map((o) => {
|
|
1184
|
-
const l = o.id || o.seedUid || o.SeedUid || o.storageTransactionId || o.storage_transaction_id, d = i != null ? `${i.replace(/\/$/, "")}/${(n ?? "attestation/view").replace(/^\//, "")}/${l}` : `${r}/${
|
|
1187
|
+
const l = o.id || o.seedUid || o.SeedUid || o.storageTransactionId || o.storage_transaction_id, d = i != null ? `${i.replace(/\/$/, "")}/${(n ?? "attestation/view").replace(/^\//, "")}/${l}` : `${r}/${U(t)}/${l}`, h = o.link || o.Link || o.import_url || o.importUrl || d;
|
|
1185
1188
|
let u;
|
|
1186
1189
|
if (o.pubDate || o.PubDate) {
|
|
1187
1190
|
const s = o.pubDate || o.PubDate;
|
|
@@ -1220,8 +1223,8 @@ function Pe(a, e) {
|
|
|
1220
1223
|
}), g;
|
|
1221
1224
|
});
|
|
1222
1225
|
}
|
|
1223
|
-
const
|
|
1224
|
-
const i =
|
|
1226
|
+
const Le = (a, e, t, r) => {
|
|
1227
|
+
const i = U(e), n = `${m.siteUrl}/${i}/${t}`, o = r ? `${n}?v=${r}` : n, l = `${m.title} - ${je(i)}`, d = /* @__PURE__ */ new Date(), h = K(), u = ke(a, {
|
|
1225
1228
|
schemaName: e,
|
|
1226
1229
|
siteUrl: m.siteUrl,
|
|
1227
1230
|
itemUrlBase: h.itemUrlBase,
|
|
@@ -1270,7 +1273,7 @@ ${c.content.value || c.content}` };
|
|
|
1270
1273
|
return c;
|
|
1271
1274
|
})
|
|
1272
1275
|
};
|
|
1273
|
-
return Promise.resolve(
|
|
1276
|
+
return Promise.resolve(ce(g));
|
|
1274
1277
|
}
|
|
1275
1278
|
case "json": {
|
|
1276
1279
|
const g = {
|
|
@@ -1303,7 +1306,7 @@ ${f.content_html}`;
|
|
|
1303
1306
|
}
|
|
1304
1307
|
return f;
|
|
1305
1308
|
})
|
|
1306
|
-
}, s =
|
|
1309
|
+
}, s = oe(g);
|
|
1307
1310
|
return Promise.resolve(typeof s == "string" ? s : JSON.stringify(s));
|
|
1308
1311
|
}
|
|
1309
1312
|
case "rss":
|
|
@@ -1372,7 +1375,7 @@ ${s.content}`;
|
|
|
1372
1375
|
}
|
|
1373
1376
|
}
|
|
1374
1377
|
if (!c.enclosures && (s.feature_image || s.featureImage)) {
|
|
1375
|
-
const f = s.feature_image || s.featureImage, p = typeof f == "string" && f.startsWith("http") ? f :
|
|
1378
|
+
const f = s.feature_image || s.featureImage, p = typeof f == "string" && f.startsWith("http") ? f : b(f);
|
|
1376
1379
|
c.enclosures = [{
|
|
1377
1380
|
url: p,
|
|
1378
1381
|
type: "image/jpeg"
|
|
@@ -1386,11 +1389,11 @@ ${s.content}`;
|
|
|
1386
1389
|
return (s.seedUid || s.SeedUid) && (c.dc.identifier || (c.dc.identifier = []), c.dc.identifier.push(s.seedUid || s.SeedUid)), (s.storageTransactionId || s.storage_transaction_id) && (c.dc.identifier || (c.dc.identifier = []), c.dc.identifier.push(s.storageTransactionId || s.storage_transaction_id)), (s.import_url || s.importUrl) && (c.dc.source = s.import_url || s.importUrl), (s.seedUid || s.SeedUid) && (c.seedUid = s.seedUid || s.SeedUid), (s.storageTransactionId || s.storage_transaction_id) && (c.storageTransactionId = s.storageTransactionId || s.storage_transaction_id), s.timeCreated && (c.timeCreated = s.timeCreated), c;
|
|
1387
1390
|
})
|
|
1388
1391
|
};
|
|
1389
|
-
return Promise.resolve(
|
|
1392
|
+
return Promise.resolve($e(g));
|
|
1390
1393
|
}
|
|
1391
1394
|
}
|
|
1392
1395
|
};
|
|
1393
|
-
function
|
|
1396
|
+
function xe(a) {
|
|
1394
1397
|
switch (a) {
|
|
1395
1398
|
case "atom":
|
|
1396
1399
|
return "application/atom+xml; charset=utf-8";
|
|
@@ -1401,15 +1404,15 @@ function Le(a) {
|
|
|
1401
1404
|
return "application/rss+xml; charset=utf-8";
|
|
1402
1405
|
}
|
|
1403
1406
|
}
|
|
1404
|
-
function
|
|
1407
|
+
function Re(a) {
|
|
1405
1408
|
const e = a.toLowerCase();
|
|
1406
1409
|
return ["rss", "atom", "json"].includes(e) ? e : null;
|
|
1407
1410
|
}
|
|
1408
|
-
function
|
|
1411
|
+
function je(a) {
|
|
1409
1412
|
return a.charAt(0).toUpperCase() + a.slice(1);
|
|
1410
1413
|
}
|
|
1411
|
-
async function
|
|
1412
|
-
const i =
|
|
1414
|
+
async function qe(a, e, t, r) {
|
|
1415
|
+
const i = Re(e);
|
|
1413
1416
|
if (!i)
|
|
1414
1417
|
return new Response(
|
|
1415
1418
|
JSON.stringify({ error: `Invalid feed format: ${e}` }),
|
|
@@ -1418,14 +1421,14 @@ async function Ke(a, e, t, r) {
|
|
|
1418
1421
|
headers: { "Content-Type": "application/json" }
|
|
1419
1422
|
}
|
|
1420
1423
|
);
|
|
1421
|
-
const n =
|
|
1424
|
+
const n = U.singular(a.toLowerCase()), o = U(n);
|
|
1422
1425
|
console.log(`Schema name: ${n}`), console.log(`Collection name: ${o}`);
|
|
1423
|
-
const l =
|
|
1426
|
+
const l = ve(), d = Z();
|
|
1424
1427
|
try {
|
|
1425
1428
|
if (d.enabled) {
|
|
1426
1429
|
const s = await l.getFeedContent(n, i);
|
|
1427
1430
|
if (s)
|
|
1428
|
-
return t &&
|
|
1431
|
+
return t && Ae(t, s.etag) ? (console.log(`Cache hit with ETag match for ${n}:${i} - returning 304`), new Response(null, {
|
|
1429
1432
|
status: 304,
|
|
1430
1433
|
headers: {
|
|
1431
1434
|
ETag: s.etag,
|
|
@@ -1484,7 +1487,7 @@ async function Ke(a, e, t, r) {
|
|
|
1484
1487
|
f = await J(c, p, l);
|
|
1485
1488
|
}
|
|
1486
1489
|
return f;
|
|
1487
|
-
})(), u = await
|
|
1490
|
+
})(), u = await Le(h, n, i, r), g = xe(i);
|
|
1488
1491
|
if (d.enabled) {
|
|
1489
1492
|
await l.setFeedContent(n, i, u, g);
|
|
1490
1493
|
const s = await l.getFeedContent(n, i), c = s?.etag || "", f = s?.lastModified || Math.floor(Date.now() / 1e3);
|
|
@@ -1540,12 +1543,12 @@ async function Ke(a, e, t, r) {
|
|
|
1540
1543
|
}
|
|
1541
1544
|
}
|
|
1542
1545
|
export {
|
|
1543
|
-
|
|
1546
|
+
Le as createFeed,
|
|
1544
1547
|
G as getClient,
|
|
1545
1548
|
k as getFeedItemsBySchemaName,
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1549
|
+
qe as handleFeedRequest,
|
|
1550
|
+
Pe as initializeSeedClient,
|
|
1551
|
+
Xe as resetCacheManager,
|
|
1552
|
+
Ke as teardownSeedClient
|
|
1550
1553
|
};
|
|
1551
1554
|
//# sourceMappingURL=index.js.map
|