@seedprotocol/query 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.
Files changed (61) hide show
  1. package/README.md +145 -0
  2. package/dist/api.d.ts +9 -0
  3. package/dist/api.d.ts.map +1 -0
  4. package/dist/arweaveUrl.d.ts +5 -0
  5. package/dist/arweaveUrl.d.ts.map +1 -0
  6. package/dist/assembleChangelog.d.ts +12 -0
  7. package/dist/assembleChangelog.d.ts.map +1 -0
  8. package/dist/assembleSeeds.d.ts +8 -0
  9. package/dist/assembleSeeds.d.ts.map +1 -0
  10. package/dist/bootstrap-DQZ8ehyx.js +25 -0
  11. package/dist/bootstrap-DQZ8ehyx.js.map +1 -0
  12. package/dist/bootstrap.d.ts +9 -0
  13. package/dist/bootstrap.d.ts.map +1 -0
  14. package/dist/cache/CacheManager.d.ts +37 -0
  15. package/dist/cache/CacheManager.d.ts.map +1 -0
  16. package/dist/cache/FileCache.d.ts +21 -0
  17. package/dist/cache/FileCache.d.ts.map +1 -0
  18. package/dist/cache/MemoryCache.d.ts +31 -0
  19. package/dist/cache/MemoryCache.d.ts.map +1 -0
  20. package/dist/cache/config.d.ts +15 -0
  21. package/dist/cache/config.d.ts.map +1 -0
  22. package/dist/cache/etag.d.ts +13 -0
  23. package/dist/cache/etag.d.ts.map +1 -0
  24. package/dist/cache/index.d.ts +22 -0
  25. package/dist/cache/index.d.ts.map +1 -0
  26. package/dist/cache/types.d.ts +49 -0
  27. package/dist/cache/types.d.ts.map +1 -0
  28. package/dist/changelog.d.ts +39 -0
  29. package/dist/changelog.d.ts.map +1 -0
  30. package/dist/fieldStorageModel.d.ts +30 -0
  31. package/dist/fieldStorageModel.d.ts.map +1 -0
  32. package/dist/hydrateArweaveRichText.d.ts +20 -0
  33. package/dist/hydrateArweaveRichText.d.ts.map +1 -0
  34. package/dist/imageRelationEnrichment.d.ts +8 -0
  35. package/dist/imageRelationEnrichment.d.ts.map +1 -0
  36. package/dist/index.d.ts +23 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +1078 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/listRelationKey.d.ts +13 -0
  41. package/dist/listRelationKey.d.ts.map +1 -0
  42. package/dist/node/index.d.ts +3 -0
  43. package/dist/node/index.d.ts.map +1 -0
  44. package/dist/node.js +2 -0
  45. package/dist/parseEasPropertyMetadata.d.ts +31 -0
  46. package/dist/parseEasPropertyMetadata.d.ts.map +1 -0
  47. package/dist/parseEasRelationPropertyName.d.ts +11 -0
  48. package/dist/parseEasRelationPropertyName.d.ts.map +1 -0
  49. package/dist/source/index.d.ts +5 -0
  50. package/dist/source/index.d.ts.map +1 -0
  51. package/dist/source/registry.d.ts +11 -0
  52. package/dist/source/registry.d.ts.map +1 -0
  53. package/dist/source/remote.d.ts +9 -0
  54. package/dist/source/remote.d.ts.map +1 -0
  55. package/dist/source/resolve.d.ts +17 -0
  56. package/dist/source/resolve.d.ts.map +1 -0
  57. package/dist/source/types.d.ts +28 -0
  58. package/dist/source/types.d.ts.map +1 -0
  59. package/dist/types.d.ts +90 -0
  60. package/dist/types.d.ts.map +1 -0
  61. package/package.json +57 -0
package/dist/index.js ADDED
@@ -0,0 +1,1078 @@
1
+ import { i as e, n as t, r as n, t as r } from "./bootstrap-DQZ8ehyx.js";
2
+ import { BaseArweaveClient as i, isKnownArweaveGatewayHostname as a } from "@seedprotocol/arweave";
3
+ import { EasClient as o, GET_SEEDS as s, getItemPropertiesFromEas as c, getItemVersionsFromEas as l, getSeedsBySchemaName as u, pickLatestPropertyAttestationsByRefAndSchema as d, setSchemaUidForSchemaDefinition as f, withExcludeRevokedFilter as p } from "@seedprotocol/eas";
4
+ import m from "pluralize";
5
+ import { promises as h } from "fs";
6
+ import { join as g } from "path";
7
+ import { createHash as ee } from "crypto";
8
+ //#region src/arweaveUrl.ts
9
+ function _(e) {
10
+ return `https://${i.getHost()}/${e}`;
11
+ }
12
+ //#endregion
13
+ //#region src/listRelationKey.ts
14
+ var te = /^(.+?)([A-Z][a-zA-Z]+)Ids$/;
15
+ function v(e) {
16
+ let t = te.exec(e);
17
+ if (t) {
18
+ let e = t[1];
19
+ if (e) return m(e);
20
+ }
21
+ if (e.endsWith("_ids")) {
22
+ let t = e.slice(0, -4), n = t.split("_").filter(Boolean);
23
+ if (n.length >= 2) {
24
+ let e = n[0];
25
+ return e.endsWith("s") ? e : m(e);
26
+ }
27
+ return m(t);
28
+ }
29
+ return e;
30
+ }
31
+ function y(e, t) {
32
+ for (let n of Object.keys(e)) n !== t && v(n) === t && delete e[n];
33
+ }
34
+ function b(e) {
35
+ if (Array.isArray(e) || typeof e != "string") return e;
36
+ let t = e.trim();
37
+ if (!t.startsWith("[")) return e;
38
+ try {
39
+ let e = JSON.parse(t);
40
+ if (Array.isArray(e)) return e;
41
+ } catch {}
42
+ return e;
43
+ }
44
+ //#endregion
45
+ //#region src/imageRelationEnrichment.ts
46
+ function x(e) {
47
+ let t = e.storageTransactionId ?? e.storage_transaction_id;
48
+ if (t && typeof t == "string" && t.trim()) try {
49
+ e.arweaveUrl = _(t.trim());
50
+ } catch {}
51
+ }
52
+ var ne = x, S = new Set([
53
+ "html",
54
+ "file",
55
+ "json"
56
+ ]), re = S, C = "_feedFieldStorageModels", ie = "_feedListElementStorageModels";
57
+ function w(e) {
58
+ return e.trim().toLowerCase();
59
+ }
60
+ function T(e) {
61
+ return S.has(w(e));
62
+ }
63
+ var ae = T;
64
+ function E(e) {
65
+ let t = w(e);
66
+ return t === "html" ? 0 : t === "file" ? 1 : t === "json" ? 2 : 99;
67
+ }
68
+ var oe = E;
69
+ function D(e) {
70
+ let t = e[C];
71
+ if (typeof t == "object" && t && !Array.isArray(t)) return t;
72
+ }
73
+ var se = D;
74
+ function O(e) {
75
+ let t = e[ie];
76
+ if (typeof t == "object" && t && !Array.isArray(t)) return t;
77
+ }
78
+ var ce = O;
79
+ function k(e, t, n) {
80
+ let r = w(n), i = D(e);
81
+ i || (i = {}, e[C] = i), i[t] = r;
82
+ }
83
+ var le = k;
84
+ function A(e, t, n) {
85
+ let r = O(e);
86
+ r || (r = {}, e[ie] = r), r[t] = n.map(w);
87
+ }
88
+ var ue = A, de = [
89
+ "html",
90
+ "Html",
91
+ "body",
92
+ "Body",
93
+ "content",
94
+ "Content"
95
+ ], fe = 8e6;
96
+ function pe(e) {
97
+ let t = e.trim();
98
+ if (!t.startsWith("http://") && !t.startsWith("https://")) return !1;
99
+ try {
100
+ let e = new URL(t), n = e.hostname.toLowerCase();
101
+ if (n !== i.getHost().toLowerCase() && !a(n)) return !1;
102
+ let r = e.pathname.replace(/^\//, "").split("/").filter(Boolean);
103
+ if (r.length !== 1) return !1;
104
+ let o = r[0];
105
+ return /^[A-Za-z0-9_-]{43}$/.test(o);
106
+ } catch {
107
+ return !1;
108
+ }
109
+ }
110
+ async function me(e) {
111
+ try {
112
+ let t = await fetch(e, {
113
+ headers: { Accept: "text/html, text/plain, text/markdown, application/json, */*" },
114
+ signal: AbortSignal.timeout(15e3)
115
+ });
116
+ if (!t.ok) return null;
117
+ let n = t.headers.get("content-type") ?? "";
118
+ if (/^(image|video|audio)\//i.test(n)) return null;
119
+ let r = await t.arrayBuffer();
120
+ if (r.byteLength > fe) return null;
121
+ let i = new TextDecoder("utf-8", { fatal: !1 }).decode(r);
122
+ return i.length === 0 || i.includes("\0") ? null : i;
123
+ } catch {
124
+ return null;
125
+ }
126
+ }
127
+ async function he(e, t, n) {
128
+ if (n) try {
129
+ let r = await n({
130
+ propertyName: e,
131
+ value: t
132
+ });
133
+ if (r != null && r.length > 0) return r;
134
+ } catch {}
135
+ return pe(t) ? me(t) : null;
136
+ }
137
+ async function ge(e, t, n) {
138
+ let r = e[t];
139
+ if (typeof r != "string" || r.trim() === "") return;
140
+ let i = await he(t, r, n);
141
+ i !== null && (e[t] = i);
142
+ }
143
+ async function j(e, t) {
144
+ let n = t?.readStorageBody;
145
+ for (let t of e) {
146
+ let e = new Set([...de]), r = D(t);
147
+ if (r) for (let [t, n] of Object.entries(r)) T(n) && e.add(t);
148
+ for (let r of e) await ge(t, r, n);
149
+ let i = O(t);
150
+ if (i) for (let [e, r] of Object.entries(i)) {
151
+ let i = t[e];
152
+ if (!Array.isArray(i)) continue;
153
+ let a = Math.min(r.length, i.length);
154
+ for (let t = 0; t < a; t++) {
155
+ if (!T(r[t])) continue;
156
+ let a = i[t];
157
+ if (typeof a != "string") continue;
158
+ let o = await he(e, a, n);
159
+ o !== null && (i[t] = o);
160
+ }
161
+ }
162
+ }
163
+ }
164
+ var _e = j;
165
+ //#endregion
166
+ //#region src/parseEasPropertyMetadata.ts
167
+ function M(e) {
168
+ let t = typeof e == "string" ? e.trim() : "";
169
+ if (!t) return {
170
+ ok: !1,
171
+ reason: "empty"
172
+ };
173
+ let n;
174
+ try {
175
+ n = JSON.parse(t);
176
+ } catch (e) {
177
+ return {
178
+ ok: !1,
179
+ reason: "parse",
180
+ error: e
181
+ };
182
+ }
183
+ return !Array.isArray(n) || n.length === 0 || !n[0]?.value ? {
184
+ ok: !1,
185
+ reason: "shape"
186
+ } : {
187
+ ok: !0,
188
+ metadata: n[0].value
189
+ };
190
+ }
191
+ var ve = M;
192
+ //#endregion
193
+ //#region src/parseEasRelationPropertyName.ts
194
+ function N(e) {
195
+ let [t, n, r] = e.split("_");
196
+ if (!t || !n) return null;
197
+ let i = r === "ids";
198
+ return {
199
+ propertyName: t.endsWith("s") ? t : t + "s",
200
+ modelName: n,
201
+ isList: i
202
+ };
203
+ }
204
+ //#endregion
205
+ //#region src/source/remote.ts
206
+ function ye(e, t) {
207
+ let n = new Date(e, t - 1, 1), r = new Date(e, t, 0, 23, 59, 59);
208
+ return {
209
+ startTs: Math.floor(n.getTime() / 1e3),
210
+ endTs: Math.floor(r.getTime() / 1e3) + 1
211
+ };
212
+ }
213
+ function P() {
214
+ return {
215
+ kind: "remote",
216
+ async getSeedByUid(e) {
217
+ let { itemSeeds: t } = await o.getEasClient().request(s, {
218
+ where: p({ id: { equals: e } }),
219
+ take: 1,
220
+ skip: 0
221
+ });
222
+ return (t ?? [])[0] ?? null;
223
+ },
224
+ async listSeedsBySchemaName(e, t) {
225
+ return await u(e, t.limit, t.skip);
226
+ },
227
+ async listSeedsBySchemaNameForMonth(e, t, n) {
228
+ let { startTs: r, endTs: i } = ye(t, n), a = p({ AND: [{ schema: { is: { schemaNames: { some: { name: { equals: e } } } } } }, { timeCreated: {
229
+ gte: r,
230
+ lt: i
231
+ } }] }), { itemSeeds: c } = await o.getEasClient().request(s, {
232
+ where: a,
233
+ take: 1e3,
234
+ skip: 0
235
+ });
236
+ return c ?? [];
237
+ },
238
+ async getVersionsForSeed(e) {
239
+ return await l({ seedUids: [e] });
240
+ },
241
+ async getVersionsForSeeds(e) {
242
+ return e.length === 0 ? [] : await l({ seedUids: e });
243
+ },
244
+ async getPropertiesForVersionUids(e) {
245
+ return e.length === 0 ? [] : await c({ versionUids: e });
246
+ },
247
+ async getSeedsByUids(e) {
248
+ if (e.length === 0) return [];
249
+ let { itemSeeds: t } = await o.getEasClient().request(s, {
250
+ where: p({ id: { in: e } }),
251
+ take: e.length || 1,
252
+ skip: 0
253
+ });
254
+ return t ?? [];
255
+ }
256
+ };
257
+ }
258
+ var F = null;
259
+ function I() {
260
+ return F ||= P(), F;
261
+ }
262
+ //#endregion
263
+ //#region src/assembleSeeds.ts
264
+ var L = "image", R = ["0x0000000000000000000000000000000000000000000000000000000000000020"], be = new Set([
265
+ "seedUid",
266
+ "SeedUid",
267
+ "timeCreated",
268
+ "attester",
269
+ "Attester",
270
+ "storage_transaction_id",
271
+ "storage_provider_transaction_id",
272
+ "storageTransactionId",
273
+ "storageProviderTransactionId",
274
+ "versionUid"
275
+ ]), z = (e) => e.replace(/_([a-z])/g, (e, t) => t.toUpperCase());
276
+ function xe() {
277
+ return {
278
+ seedUidToModelType: /* @__PURE__ */ new Map(),
279
+ relatedSeedUids: /* @__PURE__ */ new Set(),
280
+ versionUidToSeedUid: /* @__PURE__ */ new Map(),
281
+ assembledItems: /* @__PURE__ */ new Map(),
282
+ versionsBySeedUid: /* @__PURE__ */ new Map(),
283
+ latestVersionUidsBySeedUid: /* @__PURE__ */ new Map()
284
+ };
285
+ }
286
+ function B(e, t) {
287
+ !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);
288
+ }
289
+ async function Se(e, t) {
290
+ let n = M(t.decodedDataJson);
291
+ if (!n.ok) {
292
+ let { id: e, refUID: r, schemaId: i } = t;
293
+ n.reason === "empty" ? console.warn("[query] [processItemProperty] empty decodedDataJson for property:", e, r, i) : n.reason === "parse" ? console.warn("[query] [processItemProperty] failed to parse decodedDataJson for property:", e, r, i, n.error) : console.warn("[query] [processItemProperty] invalid decodedDataJson structure for property:", e, r, i);
294
+ return;
295
+ }
296
+ let r = n.metadata, i = r.name;
297
+ if (!i) return;
298
+ let a = t.schemaId;
299
+ f({
300
+ text: i,
301
+ schemaUid: a
302
+ });
303
+ let o = !1, s = !1, c = r.type, l = (c === "bytes32" || c === "bytes32[]") && i !== "storage_transaction_id" && i !== "storage_provider_transaction_id", u = !l && (i.endsWith("_id") || i.endsWith("_ids")) && i !== "storage_transaction_id" && i !== "storage_provider_transaction_id";
304
+ if (l || u) if (o = !0, Array.isArray(r.value)) {
305
+ if (s = !0, u) {
306
+ let e = N(i);
307
+ e && (i = e.propertyName);
308
+ }
309
+ r.value.forEach((t) => {
310
+ R.includes(t) || e.relatedSeedUids.add(t);
311
+ });
312
+ } else R.includes(r.value) || e.relatedSeedUids.add(r.value);
313
+ let d = r.value;
314
+ o && s && Array.isArray(d) ? d = d.map((e) => String(e)) : typeof d != "string" && (d = JSON.stringify(d));
315
+ let p = e.versionUidToSeedUid.get(t.refUID);
316
+ if (!p) return;
317
+ let m = e.assembledItems.get(p) || {};
318
+ m[i] = d;
319
+ let h = z(i);
320
+ h !== i && (m[h] = d), e.assembledItems.set(p, m);
321
+ }
322
+ async function Ce(e, t, n) {
323
+ let r = [];
324
+ for (let n = 0; n < t.length; n++) {
325
+ let i = t[n];
326
+ if (!i) continue;
327
+ r.push(i.id);
328
+ let a = i.schema?.schemaNames?.[0]?.name ?? "unknown";
329
+ e.seedUidToModelType.set(i.id, a), e.assembledItems.has(i.id) || e.assembledItems.set(i.id, {
330
+ seedUid: i.id,
331
+ timeCreated: i.timeCreated,
332
+ attester: i.attester
333
+ });
334
+ }
335
+ if (r.length === 0) return;
336
+ let i = await n.getVersionsForSeeds(r);
337
+ for (let t = 0; t < i.length; t++) {
338
+ let n = i[t], r = n.refUID;
339
+ e.versionUidToSeedUid.set(n.id, r);
340
+ let a = e.versionsBySeedUid.get(r) || [];
341
+ e.versionsBySeedUid.set(r, [...a, n]);
342
+ }
343
+ let a = [];
344
+ for (let [t, n] of e.versionsBySeedUid.entries()) {
345
+ if (e.latestVersionUidsBySeedUid.has(t)) continue;
346
+ let r = [...n].sort((e, t) => t.timeCreated - e.timeCreated)[0];
347
+ r && (a.push(r.id), e.latestVersionUidsBySeedUid.set(t, r.id));
348
+ }
349
+ if (a.length === 0) return;
350
+ let o = d(await n.getPropertiesForVersionUids(a));
351
+ for (let t = 0; t < o.length; t++) await Se(e, o[t]);
352
+ }
353
+ function we(e, t) {
354
+ let n = Array.from(e.assembledItems.entries()).filter(([n]) => e.seedUidToModelType.get(n) === t);
355
+ for (let [, t] of n) {
356
+ let n = Object.keys(t).filter((e) => !e.startsWith("_") && !be.has(e));
357
+ for (let r of n) {
358
+ let n = t[r], i = b(n);
359
+ if (i !== n && Array.isArray(i) && (t[r] = i, n = i), Array.isArray(n)) {
360
+ let i = n;
361
+ if (!i.some((t) => typeof t == "string" && !R.includes(t) && e.assembledItems.has(t))) continue;
362
+ let a = [], o = [], s = !1;
363
+ for (let t of i) {
364
+ if (typeof t != "string" || R.includes(t)) {
365
+ a.push(String(t)), o.push("unknown");
366
+ continue;
367
+ }
368
+ let n = e.seedUidToModelType.get(t) ?? "unknown";
369
+ if (n === L) {
370
+ a.push(t), o.push(L);
371
+ continue;
372
+ }
373
+ let r = e.assembledItems.get(t), i = r?.storageTransactionId ?? r?.storage_transaction_id;
374
+ if (i && typeof i == "string" && i.trim()) try {
375
+ a.push(_(i)), o.push(n), s = !0;
376
+ } catch {
377
+ a.push(t), o.push(n);
378
+ }
379
+ else a.push(t), o.push(n);
380
+ }
381
+ if (s) {
382
+ let e = v(r);
383
+ if (t[e] = a, A(t, e, o), y(t, e), e !== r) {
384
+ delete t[r];
385
+ let e = z(r);
386
+ e !== r && delete t[e];
387
+ }
388
+ }
389
+ } else if (typeof n == "string") {
390
+ if (R.includes(n) || !e.assembledItems.has(n)) continue;
391
+ let i = e.assembledItems.get(n);
392
+ if (e.seedUidToModelType.get(n) === L) continue;
393
+ let a = i?.storageTransactionId ?? i?.storage_transaction_id;
394
+ if (a && typeof a == "string" && a.trim()) try {
395
+ let i = r.endsWith("_id") ? r.replace(/_id$/, "") : r;
396
+ t[i] = _(a);
397
+ let o = e.seedUidToModelType.get(n) ?? "unknown";
398
+ k(t, i, o);
399
+ let s = z(i);
400
+ if (s !== i && k(t, s, o), i !== r) {
401
+ delete t[r];
402
+ let e = z(r);
403
+ e !== r && delete t[e];
404
+ }
405
+ } catch {}
406
+ }
407
+ }
408
+ }
409
+ }
410
+ function Te(e, t, n) {
411
+ if (!n) return;
412
+ let r = Array.from(e.assembledItems.entries()).filter(([n]) => e.seedUidToModelType.get(n) === t);
413
+ for (let [, t] of r) {
414
+ let n = Object.keys(t).filter((e) => !e.startsWith("_") && !be.has(e));
415
+ for (let r of n) {
416
+ let n = t[r], i = b(n);
417
+ i !== n && Array.isArray(i) && (t[r] = i, n = i);
418
+ let a = Array.isArray(n), o = a ? n : [n], s = [], c = !1;
419
+ for (let t of o) {
420
+ if (typeof t != "string" || R.includes(t)) {
421
+ s.push(t);
422
+ continue;
423
+ }
424
+ let n = e.assembledItems.get(t);
425
+ if (!n) {
426
+ s.push(t);
427
+ continue;
428
+ }
429
+ let r = n?.storageTransactionId ?? n?.storage_transaction_id;
430
+ if (e.seedUidToModelType.get(t) === L) {
431
+ let e = { ...n };
432
+ B(e, t), e.schemaName = L, x(e), s.push(e), c = !0;
433
+ continue;
434
+ }
435
+ if (r && typeof r == "string" && r.trim()) {
436
+ s.push(t);
437
+ continue;
438
+ }
439
+ let i = { ...n };
440
+ B(i, t), s.push(i), c = !0;
441
+ }
442
+ if (c) {
443
+ let e = a ? v(r) : r.endsWith("_id") ? r.replace(/_id$/, "") : r;
444
+ if (t[e] = a ? s : s[0], y(t, e), e !== r) {
445
+ delete t[r];
446
+ let e = z(r);
447
+ e !== r && delete t[e];
448
+ }
449
+ }
450
+ }
451
+ }
452
+ }
453
+ function Ee(e, t) {
454
+ return Array.from(e.assembledItems.entries()).filter(([n]) => e.seedUidToModelType.get(n) === t).map(([n, r]) => {
455
+ let i = e.latestVersionUidsBySeedUid.get(n) ?? "";
456
+ i && (r.versionUid = i), B(r, n);
457
+ let a = typeof r.timeCreated == "number" ? r.timeCreated : 0;
458
+ return {
459
+ seedUid: n,
460
+ schemaName: t,
461
+ attester: typeof r.attester == "string" ? r.attester : typeof r.Attester == "string" ? r.Attester : void 0,
462
+ timeCreated: a,
463
+ versionUid: i,
464
+ data: r
465
+ };
466
+ });
467
+ }
468
+ async function V(e, t, n, r = I()) {
469
+ let i = n?.expandRelations !== !1, a = n?.hydrateStorage !== !1, o = xe();
470
+ await Ce(o, t, r);
471
+ let s = Array.from(o.relatedSeedUids).filter((e) => !o.assembledItems.has(e));
472
+ s.length > 0 && await Ce(o, await r.getSeedsByUids(s), r), we(o, e), Te(o, e, i);
473
+ let c = Ee(o, e);
474
+ return a && await j(c.map((e) => e.data), r.readStorageBody ? { readStorageBody: r.readStorageBody.bind(r) } : void 0), c;
475
+ }
476
+ //#endregion
477
+ //#region src/changelog.ts
478
+ var De = (e) => e.replace(/_([a-z])/g, (e, t) => t.toUpperCase());
479
+ function H(e, t) {
480
+ if (Object.is(e, t)) return !0;
481
+ if (e === void 0 || t === void 0) return !1;
482
+ if (e === null || t === null) return e === t;
483
+ if (typeof e != typeof t || typeof e != "object") return !1;
484
+ try {
485
+ return JSON.stringify(e) === JSON.stringify(t);
486
+ } catch {
487
+ return !1;
488
+ }
489
+ }
490
+ function U(e) {
491
+ let t = M(e.decodedDataJson);
492
+ if (!t.ok) return null;
493
+ let n = t.metadata, r = n.name;
494
+ if (!r) return null;
495
+ let i = n.type, a = (i === "bytes32" || i === "bytes32[]") && r !== "storage_transaction_id" && r !== "storage_provider_transaction_id", o = !a && (r.endsWith("_id") || r.endsWith("_ids")) && r !== "storage_transaction_id" && r !== "storage_provider_transaction_id", s = !1, c = !1;
496
+ if ((a || o) && (s = !0, Array.isArray(n.value) && (c = !0, o))) {
497
+ let e = N(r);
498
+ e?.isList && (r = e.propertyName);
499
+ }
500
+ let l = n.value;
501
+ s && c && Array.isArray(l) ? l = l.map((e) => String(e)) : typeof l != "string" && (l = JSON.stringify(l));
502
+ let u = De(r);
503
+ return {
504
+ propertyName: r,
505
+ value: l,
506
+ camelName: u === r ? void 0 : u
507
+ };
508
+ }
509
+ function Oe(e) {
510
+ let t = {};
511
+ for (let n of e) {
512
+ let e = U(n);
513
+ e && (t[e.propertyName] = e.value, e.camelName && (t[e.camelName] = e.value));
514
+ }
515
+ return t;
516
+ }
517
+ function ke(e) {
518
+ let t = [], n = {};
519
+ for (let r of e) {
520
+ let e = r.data, i = new Set([...Object.keys(n), ...Object.keys(e)]), a = [];
521
+ for (let t of i) H(n[t], e[t]) || a.push(t);
522
+ a.sort(), t.push({
523
+ type: "version",
524
+ at: r.at,
525
+ versionUid: r.versionUid,
526
+ before: { ...n },
527
+ after: { ...e },
528
+ changedKeys: a
529
+ }), n = e;
530
+ }
531
+ return t;
532
+ }
533
+ function Ae(e) {
534
+ let t = [...e].sort((e, t) => e.timeCreated === t.timeCreated ? e.id.localeCompare(t.id) : e.timeCreated - t.timeCreated), n = /* @__PURE__ */ new Map(), r = [];
535
+ for (let e of t) {
536
+ let t = U(e);
537
+ if (!t) continue;
538
+ let i = [t.propertyName];
539
+ t.camelName && i.push(t.camelName);
540
+ let a = n.has(t.propertyName) ? n.get(t.propertyName) : void 0, o = t.value;
541
+ H(a, o) || r.push({
542
+ type: "property",
543
+ at: e.timeCreated,
544
+ versionUid: e.refUID,
545
+ property: t.propertyName,
546
+ attestationUid: e.id,
547
+ previousValue: a,
548
+ nextValue: o
549
+ }), n.set(t.propertyName, o), t.camelName && n.set(t.camelName, o);
550
+ }
551
+ return r;
552
+ }
553
+ function je(e, t) {
554
+ let n = e;
555
+ if (typeof t?.since == "number") {
556
+ let e = t.since;
557
+ n = n.filter((t) => t.at >= e);
558
+ }
559
+ return typeof t?.limit == "number" && t.limit >= 0 && (n = [...n].sort((e, t) => t.at === e.at ? 0 : t.at - e.at).slice(0, t.limit).reverse()), n;
560
+ }
561
+ //#endregion
562
+ //#region src/assembleChangelog.ts
563
+ async function Me(e, t, n = I()) {
564
+ let r = t?.changelog ?? {}, i = r.granularity ?? "version", a = [...await n.getVersionsForSeed(e)].sort((e, t) => e.timeCreated - t.timeCreated);
565
+ if (a.length === 0) return {
566
+ latestVersionUid: "",
567
+ changelog: []
568
+ };
569
+ let o = a[a.length - 1].id, s = a.map((e) => e.id), c = await n.getPropertiesForVersionUids(s), l;
570
+ if (i === "property") l = Ae(c);
571
+ else {
572
+ let e = /* @__PURE__ */ new Map();
573
+ for (let t of c) {
574
+ let n = e.get(t.refUID) ?? [];
575
+ n.push(t), e.set(t.refUID, n);
576
+ }
577
+ let t = [];
578
+ for (let n of a) {
579
+ let r = d(e.get(n.id) ?? []);
580
+ t.push({
581
+ versionUid: n.id,
582
+ at: n.timeCreated,
583
+ data: Oe(r)
584
+ });
585
+ }
586
+ l = ke(t);
587
+ }
588
+ return {
589
+ latestVersionUid: o,
590
+ changelog: je(l, r)
591
+ };
592
+ }
593
+ //#endregion
594
+ //#region src/cache/types.ts
595
+ function Ne(e) {
596
+ return !e || e === "data" ? "" : e === "data+changelog" ? "i1" : "i2";
597
+ }
598
+ function W(e) {
599
+ let t = e?.expandRelations !== !1, n = e?.hydrateStorage !== !1, r = `e${+!!t}-h${+!!n}`, i = Ne(e?.include);
600
+ return i ? `${r}-${i}-${e?.changelog?.granularity === "property" ? "gp" : "gv"}-${typeof e?.changelog?.since == "number" ? `s${e.changelog.since}` : "s0"}-${typeof e?.changelog?.limit == "number" ? `l${e.changelog.limit}` : "l0"}` : r;
601
+ }
602
+ function Pe(e) {
603
+ return e.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 120);
604
+ }
605
+ //#endregion
606
+ //#region src/cache/FileCache.ts
607
+ var Fe = class {
608
+ cacheDir;
609
+ config;
610
+ constructor(e) {
611
+ this.cacheDir = e.cacheDir, this.config = e, this.ensureCacheDir().catch((e) => {
612
+ console.error("Failed to create query cache directory:", e);
613
+ });
614
+ }
615
+ async ensureCacheDir() {
616
+ try {
617
+ await h.mkdir(this.cacheDir, { recursive: !0 });
618
+ } catch (e) {
619
+ if (e.code !== "EEXIST") throw e;
620
+ }
621
+ }
622
+ async ensureItemsDir() {
623
+ try {
624
+ await h.mkdir(g(this.cacheDir, "items"), { recursive: !0 });
625
+ } catch (e) {
626
+ if (e.code !== "EEXIST") throw e;
627
+ }
628
+ }
629
+ collectionPath(e) {
630
+ return g(this.cacheDir, `${e}.json`);
631
+ }
632
+ itemPath(e, t) {
633
+ let n = Pe(e);
634
+ return g(this.cacheDir, "items", `${n}-${t}.json`);
635
+ }
636
+ async getCollection(e) {
637
+ try {
638
+ let t = await h.readFile(this.collectionPath(e), "utf-8"), n = JSON.parse(t);
639
+ return Math.floor(Date.now() / 1e3) - n.lastUpdated > this.config.ttl ? (await this.clearCollection(e), null) : n;
640
+ } catch (t) {
641
+ return t.code === "ENOENT" || console.error(`Error reading query collection cache for ${e}:`, t), null;
642
+ }
643
+ }
644
+ async setCollection(e, t) {
645
+ try {
646
+ await this.ensureCacheDir(), await h.writeFile(this.collectionPath(e), JSON.stringify(t, null, 2), "utf-8");
647
+ } catch (t) {
648
+ console.error(`Error writing query collection cache for ${e}:`, t);
649
+ }
650
+ }
651
+ async getItem(e, t) {
652
+ try {
653
+ let n = await h.readFile(this.itemPath(e, t), "utf-8"), r = JSON.parse(n);
654
+ return Math.floor(Date.now() / 1e3) - r.lastUpdated > this.config.ttl ? (await this.clearItem(e, t), null) : r;
655
+ } catch (t) {
656
+ return t.code === "ENOENT" || console.error(`Error reading query item cache for ${e}:`, t), null;
657
+ }
658
+ }
659
+ async setItem(e) {
660
+ try {
661
+ await this.ensureItemsDir(), await h.writeFile(this.itemPath(e.record.seedUid, e.optionsKey), JSON.stringify(e, null, 2), "utf-8");
662
+ } catch (t) {
663
+ console.error(`Error writing query item cache for ${e.record.seedUid}:`, t);
664
+ }
665
+ }
666
+ async clearCollection(e) {
667
+ try {
668
+ await h.unlink(this.collectionPath(e));
669
+ } catch (t) {
670
+ t.code !== "ENOENT" && console.error(`Error clearing query collection cache for ${e}:`, t);
671
+ }
672
+ }
673
+ async clearItem(e, t) {
674
+ try {
675
+ await h.unlink(this.itemPath(e, t));
676
+ } catch (t) {
677
+ t.code !== "ENOENT" && console.error(`Error clearing query item cache for ${e}:`, t);
678
+ }
679
+ }
680
+ async clearAll() {
681
+ try {
682
+ let e = await h.readdir(this.cacheDir);
683
+ for (let t of e) t.endsWith(".json") && await h.unlink(g(this.cacheDir, t));
684
+ let t = g(this.cacheDir, "items");
685
+ try {
686
+ let e = await h.readdir(t);
687
+ for (let n of e) n.endsWith(".json") && await h.unlink(g(t, n));
688
+ } catch {}
689
+ } catch (e) {
690
+ console.error("Error clearing all query caches:", e);
691
+ }
692
+ }
693
+ };
694
+ //#endregion
695
+ //#region src/cache/etag.ts
696
+ function Ie(e) {
697
+ return `"${ee("md5").update(e).digest("hex").substring(0, 16)}"`;
698
+ }
699
+ function Le(e, t, n) {
700
+ return Ie(`${e}-data-${t}-${n}`);
701
+ }
702
+ function Re(e, t, n, r) {
703
+ return Ie(`${e}-${t}-${n}-${r}`);
704
+ }
705
+ //#endregion
706
+ //#region src/cache/MemoryCache.ts
707
+ var ze = class {
708
+ collectionCache = /* @__PURE__ */ new Map();
709
+ itemCache = /* @__PURE__ */ new Map();
710
+ config;
711
+ refreshLocks = /* @__PURE__ */ new Map();
712
+ constructor(e) {
713
+ this.config = e;
714
+ }
715
+ itemKey(e, t) {
716
+ return `${e}:${t}`;
717
+ }
718
+ getCollection(e) {
719
+ let t = this.collectionCache.get(e);
720
+ return t ? Math.floor(Date.now() / 1e3) - t.lastUpdated > this.config.ttl ? (this.collectionCache.delete(e), null) : t : null;
721
+ }
722
+ setCollection(e, t) {
723
+ let n = Math.floor(Date.now() / 1e3), r = 0, i = "";
724
+ for (let e of t) e.timeCreated && e.timeCreated > r && (r = e.timeCreated, i = e.seedUid);
725
+ r === 0 && (r = n);
726
+ let a = Le(e, r, t.length), o = {
727
+ items: t.map((e) => ({
728
+ ...e,
729
+ data: { ...e.data }
730
+ })),
731
+ lastProcessedTimestamp: r,
732
+ lastProcessedItemId: i,
733
+ lastUpdated: n,
734
+ etag: a
735
+ };
736
+ return this.collectionCache.set(e, o), o;
737
+ }
738
+ getItem(e, t) {
739
+ let n = this.itemCache.get(this.itemKey(e, t));
740
+ return n ? Math.floor(Date.now() / 1e3) - n.lastUpdated > this.config.ttl ? (this.itemCache.delete(this.itemKey(e, t)), null) : n : null;
741
+ }
742
+ setItem(e, t) {
743
+ let n = Math.floor(Date.now() / 1e3), r = Re(e.seedUid, e.versionUid, e.timeCreated, t), i = {
744
+ ...e,
745
+ data: { ...e.data }
746
+ };
747
+ e.changelog && (i.changelog = [...e.changelog]);
748
+ let a = {
749
+ record: i,
750
+ lastUpdated: n,
751
+ etag: r,
752
+ optionsKey: t
753
+ };
754
+ return this.itemCache.set(this.itemKey(e.seedUid, t), a), a;
755
+ }
756
+ clearCollection(e) {
757
+ this.collectionCache.delete(e);
758
+ }
759
+ clearItem(e, t) {
760
+ if (t) {
761
+ this.itemCache.delete(this.itemKey(e, t));
762
+ return;
763
+ }
764
+ for (let t of this.itemCache.keys()) t.startsWith(`${e}:`) && this.itemCache.delete(t);
765
+ }
766
+ clearAll() {
767
+ this.collectionCache.clear(), this.itemCache.clear();
768
+ }
769
+ async withRefreshLock(e, t) {
770
+ let n = this.refreshLocks.get(e);
771
+ if (n) return n;
772
+ let r = (async () => {
773
+ try {
774
+ return await t();
775
+ } finally {
776
+ this.refreshLocks.delete(e);
777
+ }
778
+ })();
779
+ return this.refreshLocks.set(e, r), r;
780
+ }
781
+ updateConfig(e) {
782
+ this.config = {
783
+ ...this.config,
784
+ ...e
785
+ };
786
+ }
787
+ getStats() {
788
+ return {
789
+ collectionCount: this.collectionCache.size,
790
+ itemCount: this.itemCache.size,
791
+ activeLocks: this.refreshLocks.size
792
+ };
793
+ }
794
+ }, G = class {
795
+ memoryCache;
796
+ fileCache;
797
+ config;
798
+ stats = {
799
+ hits: 0,
800
+ misses: 0,
801
+ refreshes: 0,
802
+ errors: 0
803
+ };
804
+ constructor(e) {
805
+ this.config = e, this.memoryCache = new ze(e), this.fileCache = new Fe(e);
806
+ }
807
+ get enabled() {
808
+ return this.config.enabled;
809
+ }
810
+ getConfig() {
811
+ return { ...this.config };
812
+ }
813
+ async getCollection(e) {
814
+ if (!this.config.enabled) return null;
815
+ try {
816
+ let t = this.memoryCache.getCollection(e);
817
+ return t ? (this.stats.hits++, t) : (t = await this.fileCache.getCollection(e), t ? (this.memoryCache.setCollection(e, t.items), this.stats.hits++, t) : (this.stats.misses++, null));
818
+ } catch (t) {
819
+ return console.error(`Error getting query collection cache for ${e}:`, t), this.stats.errors++, null;
820
+ }
821
+ }
822
+ async setCollection(e, t) {
823
+ if (!this.config.enabled) return null;
824
+ try {
825
+ let n = this.memoryCache.setCollection(e, t);
826
+ return await this.fileCache.setCollection(e, n), n;
827
+ } catch (t) {
828
+ return console.error(`Error setting query collection cache for ${e}:`, t), this.stats.errors++, null;
829
+ }
830
+ }
831
+ async getItem(e, t) {
832
+ if (!this.config.enabled) return null;
833
+ try {
834
+ let n = this.memoryCache.getItem(e, t);
835
+ return n ? (this.stats.hits++, n) : (n = await this.fileCache.getItem(e, t), n ? (this.memoryCache.setItem(n.record, t), this.stats.hits++, n) : (this.stats.misses++, null));
836
+ } catch (t) {
837
+ return console.error(`Error getting query item cache for ${e}:`, t), this.stats.errors++, null;
838
+ }
839
+ }
840
+ async setItem(e, t) {
841
+ if (!this.config.enabled) return null;
842
+ try {
843
+ let n = this.memoryCache.setItem(e, t);
844
+ return await this.fileCache.setItem(n), n;
845
+ } catch (t) {
846
+ return console.error(`Error setting query item cache for ${e.seedUid}:`, t), this.stats.errors++, null;
847
+ }
848
+ }
849
+ async writeThroughItems(e, t) {
850
+ if (this.config.enabled) for (let n of e) await this.setItem(n, t);
851
+ }
852
+ async clearCollection(e) {
853
+ this.memoryCache.clearCollection(e), await this.fileCache.clearCollection(e);
854
+ }
855
+ async clearAll() {
856
+ this.memoryCache.clearAll(), await this.fileCache.clearAll();
857
+ }
858
+ async withRefreshLock(e, t) {
859
+ return this.memoryCache.withRefreshLock(e, t);
860
+ }
861
+ mergeRecords(e, t) {
862
+ let n = /* @__PURE__ */ new Map();
863
+ for (let t of e) t.seedUid && n.set(t.seedUid, t);
864
+ for (let e of t) e.seedUid ? n.set(e.seedUid, e) : n.set(`temp-${Date.now()}-${Math.random()}`, e);
865
+ let r = Array.from(n.values());
866
+ return r.sort((e, t) => (t.timeCreated || 0) - (e.timeCreated || 0)), r;
867
+ }
868
+ filterNewRecords(e, t) {
869
+ return e.filter((e) => e.timeCreated && e.timeCreated > t);
870
+ }
871
+ updateConfig(e) {
872
+ this.config = {
873
+ ...this.config,
874
+ ...e
875
+ }, this.memoryCache.updateConfig(this.config);
876
+ }
877
+ getStats() {
878
+ return {
879
+ ...this.stats,
880
+ memoryStats: this.memoryCache.getStats()
881
+ };
882
+ }
883
+ resetStats() {
884
+ this.stats = {
885
+ hits: 0,
886
+ misses: 0,
887
+ refreshes: 0,
888
+ errors: 0
889
+ };
890
+ }
891
+ };
892
+ //#endregion
893
+ //#region src/cache/config.ts
894
+ function K() {
895
+ let e = parseInt(process.env.CACHE_TTL || "3600", 10), t = process.env.CACHE_DIR || "./cache", n = process.env.CACHE_ENABLED === "false" || process.env.CACHE_ENABLED === "0" || process.env.CACHE_ENABLED === "no" || process.env.CACHE_ENABLED === "off", r = process.env.CACHE_ENABLED === "true" || process.env.CACHE_ENABLED === "1" || process.env.CACHE_ENABLED === "yes", i = process.env.NODE_ENV === "development", a;
896
+ a = n ? !1 : r ? !0 : !i;
897
+ let o = process.env.CACHE_BACKGROUND_REFRESH === "true", s = parseInt(process.env.CACHE_REFRESH_INTERVAL || "300", 10);
898
+ return {
899
+ ttl: e,
900
+ cacheDir: t,
901
+ enabled: a,
902
+ backgroundRefresh: o,
903
+ refreshInterval: s
904
+ };
905
+ }
906
+ //#endregion
907
+ //#region src/cache/index.ts
908
+ var q = null;
909
+ function J() {
910
+ return q ||= new G(K()), q;
911
+ }
912
+ function Be() {
913
+ q = null;
914
+ }
915
+ function Ve(e) {
916
+ return new G({
917
+ ...K(),
918
+ ...e
919
+ });
920
+ }
921
+ //#endregion
922
+ //#region src/source/registry.ts
923
+ var Y = null;
924
+ function He(e) {
925
+ if (e.kind !== "local") throw Error("[query] registerLocalQuerySource expects a source with kind: \"local\"");
926
+ Y = e;
927
+ }
928
+ function Ue() {
929
+ Y = null;
930
+ }
931
+ function We() {
932
+ return Y;
933
+ }
934
+ function Ge() {
935
+ return Y != null;
936
+ }
937
+ //#endregion
938
+ //#region src/source/resolve.ts
939
+ function X(e = "remote") {
940
+ if (e === "remote") return {
941
+ mode: "remote",
942
+ dataSource: I(),
943
+ useQueryCache: !0
944
+ };
945
+ let t = We();
946
+ if (e === "local") {
947
+ if (!t) throw Error("[query] source: \"local\" requires registerLocalQuerySource(...) (e.g. SDK DB ready)");
948
+ return {
949
+ mode: "local",
950
+ dataSource: t,
951
+ useQueryCache: !1
952
+ };
953
+ }
954
+ return t ? {
955
+ mode: "auto",
956
+ dataSource: t,
957
+ useQueryCache: !1
958
+ } : {
959
+ mode: "auto",
960
+ dataSource: I(),
961
+ useQueryCache: !0
962
+ };
963
+ }
964
+ function Z(e) {
965
+ return e ?? "remote";
966
+ }
967
+ //#endregion
968
+ //#region src/api.ts
969
+ function Q(e, t) {
970
+ return !t || e?.cache === !1 ? !1 : J().enabled;
971
+ }
972
+ function Ke(e) {
973
+ return e === "data+changelog" || e === "changelog";
974
+ }
975
+ function qe(e) {
976
+ return e !== "changelog";
977
+ }
978
+ async function $(e, t, n, r, i) {
979
+ return V(e, await i.listSeedsBySchemaName(e, {
980
+ limit: t,
981
+ skip: n
982
+ }), r, i);
983
+ }
984
+ async function Je(e, t, n) {
985
+ let r = await n(t);
986
+ if (e !== "auto" || t.kind !== "local") return {
987
+ items: r,
988
+ dataSource: t,
989
+ useQueryCache: t.kind === "remote"
990
+ };
991
+ if (r.length > 0) return {
992
+ items: r,
993
+ dataSource: t,
994
+ useQueryCache: !1
995
+ };
996
+ let i = I();
997
+ return {
998
+ items: await n(i),
999
+ dataSource: i,
1000
+ useQueryCache: !0
1001
+ };
1002
+ }
1003
+ async function Ye(e, n) {
1004
+ await t();
1005
+ let r = n?.limit ?? 100, i = n?.skip ?? 0, a = Z(n?.source), o = X(a), s = W(n), c = (t) => $(e, r, i, n, t);
1006
+ if (Q(n, o.useQueryCache) && i === 0 && o.dataSource.kind === "remote") {
1007
+ let t = J();
1008
+ return t.withRefreshLock(e, async () => {
1009
+ let a = await t.getCollection(e), c, l;
1010
+ if (a) {
1011
+ let i = await $(e, r, 0, n, o.dataSource), s = t.filterNewRecords(i, a.lastProcessedTimestamp);
1012
+ c = s.length > 0 ? t.mergeRecords(a.items, s).slice(0, r) : a.items.slice(0, r);
1013
+ } else c = await $(e, r, 0, n, o.dataSource);
1014
+ return l = (await t.setCollection(e, c))?.etag, await t.writeThroughItems(c, s), {
1015
+ items: c,
1016
+ limit: r,
1017
+ skip: i,
1018
+ etag: l
1019
+ };
1020
+ });
1021
+ }
1022
+ let { items: l, dataSource: u, useQueryCache: d } = await Je(a, o.dataSource, (e) => c(e));
1023
+ return Q(n, d) && u.kind === "remote" && await J().writeThroughItems(l, s), {
1024
+ items: l,
1025
+ limit: r,
1026
+ skip: i
1027
+ };
1028
+ }
1029
+ async function Xe(e, n) {
1030
+ if (await t(), !e || typeof e != "string" || e.trim() === "") return null;
1031
+ let r = e.trim(), i = n?.include ?? "data", a = Z(n?.source), o = X(a), s = W(n), c = o.dataSource, l = o.useQueryCache;
1032
+ if (Q(n, l) && c.kind === "remote") {
1033
+ let e = await J().getItem(r, s);
1034
+ if (e) return e.record;
1035
+ }
1036
+ let u = await c.getSeedByUid(r);
1037
+ if (!u && a === "auto" && c.kind === "local" && (c = I(), l = !0, u = await c.getSeedByUid(r), Q(n, l))) {
1038
+ let e = await J().getItem(r, s);
1039
+ if (e) return e.record;
1040
+ }
1041
+ if (!u) return null;
1042
+ let d = u.schema?.schemaNames?.[0]?.name;
1043
+ if (!d) return null;
1044
+ let f = null;
1045
+ if (!Ke(i)) f = (await V(d, [u], n, c))[0] ?? null;
1046
+ else {
1047
+ let { latestVersionUid: e, changelog: t } = await Me(r, n, c);
1048
+ if (qe(i)) {
1049
+ let e = (await V(d, [u], n, c))[0];
1050
+ f = e ? {
1051
+ ...e,
1052
+ changelog: t
1053
+ } : null;
1054
+ } else f = {
1055
+ seedUid: r,
1056
+ schemaName: d,
1057
+ attester: u.attester,
1058
+ timeCreated: u.timeCreated,
1059
+ versionUid: e,
1060
+ data: {},
1061
+ changelog: t
1062
+ };
1063
+ }
1064
+ return f && Q(n, l) && c.kind === "remote" && await J().setItem(f, s), f;
1065
+ }
1066
+ async function Ze(e, n, r, i) {
1067
+ await t();
1068
+ let a = Z(i?.source), { items: o, dataSource: s, useQueryCache: c } = await Je(a, X(a).dataSource, async (t) => V(e, await t.listSeedsBySchemaNameForMonth(e, n, r), i, t));
1069
+ if (Q(i, c) && s.kind === "remote") {
1070
+ let e = W(i);
1071
+ await J().writeThroughItems(o, e);
1072
+ }
1073
+ return o;
1074
+ }
1075
+ //#endregion
1076
+ export { G as CacheManager, r as DEFAULT_ARWEAVE_HOST, re as FEED_RICH_BODY_STORAGE_SCHEMAS, S as RICH_BODY_STORAGE_SCHEMAS, je as applyChangelogFilters, Me as assembleSeedChangelog, V as assembleSeeds, W as buildAssembleOptionsKey, Oe as buildFlatSnapshotFromProperties, H as changelogValuesEqual, Ue as clearLocalQuerySource, Ve as createQueryCacheManager, P as createRemoteQueryDataSource, U as decodePropertyAttestation, Ae as diffPropertyAttestations, ke as diffVersionSnapshots, x as enrichImageSeedClone, ne as enrichImageSeedCloneForFeed, oe as feedRichBodyModelPriority, _ as getArweaveUrlForTransaction, se as getFeedFieldStorageModels, ce as getFeedListElementStorageModels, D as getFieldStorageModels, O as getListElementStorageModels, J as getQueryCacheManager, We as getRegisteredLocalQuerySource, I as getRemoteQueryDataSource, Xe as getSeed, Ge as hasLocalQuerySource, _e as hydrateArweaveRichTextInFeedItems, j as hydrateArweaveRichTextInItems, t as initializeQueryPlatform, pe as isArweaveTransactionGatewayUrl, ae as isFeedRichBodyStorageSchema, n as isQueryPlatformInitialized, T as isRichBodyStorageSchema, K as loadQueryCacheConfig, Z as normalizeSourceMode, M as parseEasPropertyMetadata, ve as parseEasPropertyMetadataForFeed, N as parseEasRelationPropertyName, v as publicListRelationPropertyKey, Ye as queryBySchema, Ze as queryBySchemaForMonth, He as registerLocalQuerySource, Be as resetQueryCacheManager, X as resolveQuerySource, E as richBodyModelPriority, le as setFeedFieldStorageModel, ue as setFeedListElementStorageModels, k as setFieldStorageModel, A as setListElementStorageModels, y as stripListRelationStorageAliasesForPublicKey, e as teardownQueryPlatform, b as tryCoerceJsonStringArray };
1077
+
1078
+ //# sourceMappingURL=index.js.map