@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.
- package/README.md +145 -0
- package/dist/api.d.ts +9 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/arweaveUrl.d.ts +5 -0
- package/dist/arweaveUrl.d.ts.map +1 -0
- package/dist/assembleChangelog.d.ts +12 -0
- package/dist/assembleChangelog.d.ts.map +1 -0
- package/dist/assembleSeeds.d.ts +8 -0
- package/dist/assembleSeeds.d.ts.map +1 -0
- package/dist/bootstrap-DQZ8ehyx.js +25 -0
- package/dist/bootstrap-DQZ8ehyx.js.map +1 -0
- package/dist/bootstrap.d.ts +9 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/cache/CacheManager.d.ts +37 -0
- package/dist/cache/CacheManager.d.ts.map +1 -0
- package/dist/cache/FileCache.d.ts +21 -0
- package/dist/cache/FileCache.d.ts.map +1 -0
- package/dist/cache/MemoryCache.d.ts +31 -0
- package/dist/cache/MemoryCache.d.ts.map +1 -0
- package/dist/cache/config.d.ts +15 -0
- package/dist/cache/config.d.ts.map +1 -0
- package/dist/cache/etag.d.ts +13 -0
- package/dist/cache/etag.d.ts.map +1 -0
- package/dist/cache/index.d.ts +22 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/types.d.ts +49 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/changelog.d.ts +39 -0
- package/dist/changelog.d.ts.map +1 -0
- package/dist/fieldStorageModel.d.ts +30 -0
- package/dist/fieldStorageModel.d.ts.map +1 -0
- package/dist/hydrateArweaveRichText.d.ts +20 -0
- package/dist/hydrateArweaveRichText.d.ts.map +1 -0
- package/dist/imageRelationEnrichment.d.ts +8 -0
- package/dist/imageRelationEnrichment.d.ts.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1078 -0
- package/dist/index.js.map +1 -0
- package/dist/listRelationKey.d.ts +13 -0
- package/dist/listRelationKey.d.ts.map +1 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node.js +2 -0
- package/dist/parseEasPropertyMetadata.d.ts +31 -0
- package/dist/parseEasPropertyMetadata.d.ts.map +1 -0
- package/dist/parseEasRelationPropertyName.d.ts +11 -0
- package/dist/parseEasRelationPropertyName.d.ts.map +1 -0
- package/dist/source/index.d.ts +5 -0
- package/dist/source/index.d.ts.map +1 -0
- package/dist/source/registry.d.ts +11 -0
- package/dist/source/registry.d.ts.map +1 -0
- package/dist/source/remote.d.ts +9 -0
- package/dist/source/remote.d.ts.map +1 -0
- package/dist/source/resolve.d.ts +17 -0
- package/dist/source/resolve.d.ts.map +1 -0
- package/dist/source/types.d.ts +28 -0
- package/dist/source/types.d.ts.map +1 -0
- package/dist/types.d.ts +90 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# @seedprotocol/query
|
|
2
|
+
|
|
3
|
+
Canonical **Seed JSON** reads from remote EAS or a registered local SQLite/files adapter (Seed → Version → property attestations).
|
|
4
|
+
|
|
5
|
+
Feed generation (`@seedprotocol/feed`) uses this package to assemble items; RSS/Atom/JSON Feed formatting and **HTTP / serialized content** caching stay in feed.
|
|
6
|
+
|
|
7
|
+
SDK `runSyncFromEas` / `syncDbWithEas` persists the same EAS graph into SQLite using shared **`parseEasPropertyMetadata`**, **`parseEasRelationPropertyName`**, and **`pickLatestPropertyAttestationsByRefAndSchema`** — one definition of property decode/canonicalization for reads and sync writes.
|
|
8
|
+
|
|
9
|
+
## Scope
|
|
10
|
+
|
|
11
|
+
- `getSeed(seedUid)` — one seed’s canonical JSON envelope, optional **changelog**
|
|
12
|
+
- `queryBySchema(schemaName, { limit, skip })` — paginated collection (latest-only)
|
|
13
|
+
- `queryBySchemaForMonth` — calendar-month listing (used by feed archives)
|
|
14
|
+
- Resolve mode: **latest Version**, then newest property attestation per `(version, schemaId)`
|
|
15
|
+
- **`source: 'local' | 'remote' | 'auto'`** — pluggable backends (default `'remote'`)
|
|
16
|
+
- **Shared collection + item cache** for **remote** reads (memory → disk)
|
|
17
|
+
|
|
18
|
+
### Published vs authoring
|
|
19
|
+
|
|
20
|
+
| Need | Use |
|
|
21
|
+
|------|-----|
|
|
22
|
+
| Published / canonical Seed JSON | `getSeed` / `queryBySchema` / SDK `getPublishedSeedRecord` |
|
|
23
|
+
| Drafts, edits, liveQuery, publish | SDK `Item` / `getItemData` (local-head) |
|
|
24
|
+
| Populate local DB from EAS | SDK `Client.syncFromEas` / `runSyncFromEas` (shared parse + pickLatest) |
|
|
25
|
+
|
|
26
|
+
The Query API conversion (remote assemble → cache → changelog → local source → sync consolidation) is **complete**. Optional follow-ons (HTTP JSON routes, `auto` freshness TTL) are outside this package’s core read surface.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import {
|
|
32
|
+
initializeQueryPlatform,
|
|
33
|
+
getSeed,
|
|
34
|
+
queryBySchema,
|
|
35
|
+
} from '@seedprotocol/query'
|
|
36
|
+
|
|
37
|
+
await initializeQueryPlatform({ arweaveDomain: 'ar.seedprotocol.io' })
|
|
38
|
+
|
|
39
|
+
const one = await getSeed('0x...')
|
|
40
|
+
console.log(JSON.stringify(one?.data, null, 2))
|
|
41
|
+
|
|
42
|
+
const { items, limit, skip, etag } = await queryBySchema('post', {
|
|
43
|
+
limit: 20,
|
|
44
|
+
skip: 0,
|
|
45
|
+
})
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`SeedRecord` shape:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
{
|
|
52
|
+
seedUid: string
|
|
53
|
+
schemaName: string
|
|
54
|
+
attester?: string
|
|
55
|
+
timeCreated: number
|
|
56
|
+
versionUid: string
|
|
57
|
+
data: Record<string, unknown> // canonical property map + relations
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Options on both APIs: `expandRelations` (default `true`), `hydrateStorage` (default `true`), `cache` (default: follow env; pass `false` to bypass), `source` (default `'remote'`).
|
|
62
|
+
|
|
63
|
+
## Source (`local` / `remote` / `auto`)
|
|
64
|
+
|
|
65
|
+
| `source` | Behavior |
|
|
66
|
+
|----------|----------|
|
|
67
|
+
| `'remote'` (default) | EAS GraphQL + Arweave hydrate; uses query CacheManager when enabled |
|
|
68
|
+
| `'local'` | Requires `registerLocalQuerySource(...)` (SDK registers on client init). Published SQLite snapshot only — not drafts |
|
|
69
|
+
| `'auto'` | Prefer registered local when the seed/collection resolves; otherwise remote. No sync refresh / freshness TTL |
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import {
|
|
73
|
+
registerLocalQuerySource,
|
|
74
|
+
getSeed,
|
|
75
|
+
type QueryDataSource,
|
|
76
|
+
} from '@seedprotocol/query'
|
|
77
|
+
|
|
78
|
+
// SDK apps: Client.init registers automatically via registerSeedQueryLocalSource().
|
|
79
|
+
// Or register a custom adapter:
|
|
80
|
+
registerLocalQuerySource(myLocalSource)
|
|
81
|
+
|
|
82
|
+
const local = await getSeed('0x...', { source: 'local' })
|
|
83
|
+
const either = await getSeed('0x...', { source: 'auto' })
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Unresolved `source: 'local'` without a registered adapter throws. Local / resolved-local `auto` **bypasses** the query disk/memory cache (SQLite is the store).
|
|
87
|
+
|
|
88
|
+
From `@seedprotocol/sdk`:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { getPublishedSeedRecord } from '@seedprotocol/sdk'
|
|
92
|
+
|
|
93
|
+
const published = await getPublishedSeedRecord('0x...', { source: 'local' })
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Authoring UIs keep using `Item` / liveQuery for drafts; published JSON snapshots use query + `source`.
|
|
97
|
+
|
|
98
|
+
## Changelog (`getSeed` only)
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
const withHistory = await getSeed('0x...', {
|
|
102
|
+
include: 'data+changelog', // 'data' | 'data+changelog' | 'changelog'
|
|
103
|
+
changelog: {
|
|
104
|
+
granularity: 'version', // or 'property'
|
|
105
|
+
since: 1700000000, // optional unix seconds
|
|
106
|
+
limit: 20, // optional; keeps newest N after since
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
// withHistory.changelog?: ChangelogEntry[]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- **`include: 'data'`** (default) — same as before; no `changelog` field.
|
|
113
|
+
- **`include: 'data+changelog'`** — latest assembled `data` (expand/hydrate apply) plus history.
|
|
114
|
+
- **`include: 'changelog'`** — envelope + `changelog`; `data` is `{}`.
|
|
115
|
+
- **Version granularity** (default) — consecutive flat Version snapshots with `before` / `after` / `changedKeys`.
|
|
116
|
+
- **Property granularity** — one entry per property attestation change (`previousValue` / `nextValue`).
|
|
117
|
+
- Historical snapshots are **flat** (no relation expand / Arweave hydrate). Collections stay latest-only.
|
|
118
|
+
- Works for `source: 'local'` when versions + attested metadata exist in the DB.
|
|
119
|
+
|
|
120
|
+
## Caching
|
|
121
|
+
|
|
122
|
+
Controlled by the same env vars as feed content cache (ops compatibility):
|
|
123
|
+
|
|
124
|
+
| Variable | Default | Notes |
|
|
125
|
+
|----------|---------|--------|
|
|
126
|
+
| `CACHE_ENABLED` | on in prod; **off** when `NODE_ENV=development` | Set `true`/`false` to force |
|
|
127
|
+
| `CACHE_TTL` | `3600` | Seconds for collection + item entries |
|
|
128
|
+
| `CACHE_DIR` | `./cache` | Collections: `{schema}.json`; items: `items/{seedUid}-{opts}.json` |
|
|
129
|
+
|
|
130
|
+
Behavior:
|
|
131
|
+
|
|
132
|
+
- **Collection cache** — only for **remote** `queryBySchema` with `skip === 0` (working set). Warm hits still fetch the page to detect newer `timeCreated`, then merge/dedupe.
|
|
133
|
+
- **Item cache** — keyed by `seedUid` + options fingerprint (`expandRelations` / `hydrateStorage` / `include` / changelog filters). Default latest-only key remains `e1-h1`. Filled by remote `getSeed` and write-through from collection/month queries.
|
|
134
|
+
- **`cache: false`** — skip all cache reads/writes for that call.
|
|
135
|
+
- **`skip > 0`** — no collection cache; still write-through items when cache is enabled.
|
|
136
|
+
- **Local source** — no query CacheManager (SQLite is authoritative).
|
|
137
|
+
- Refresh lock — concurrent remote `queryBySchema` for the same schema share one in-flight refresh.
|
|
138
|
+
|
|
139
|
+
Feed still owns serialized RSS/Atom/JSON bodies, HTTP `ETag` / 304, and image-metadata probing.
|
|
140
|
+
|
|
141
|
+
## Init
|
|
142
|
+
|
|
143
|
+
Call `initializeQueryPlatform()` once (registers Node EAS + Arweave clients), or rely on `getSeed` / `queryBySchema` which initialize automatically.
|
|
144
|
+
|
|
145
|
+
For local reads, also ensure the SDK client has initialized (registers `registerLocalQuerySource`) or call `registerSeedQueryLocalSource()` / `registerLocalQuerySource` yourself.
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AssembleOptions, GetSeedOptions, GetSeedResult, QueryBySchemaOptions, QueryBySchemaResult, SeedRecord } from './types.js';
|
|
2
|
+
export declare function queryBySchema(schemaName: string, options?: QueryBySchemaOptions): Promise<QueryBySchemaResult>;
|
|
3
|
+
export declare function getSeed(seedUid: string, options?: GetSeedOptions): Promise<GetSeedResult | null>;
|
|
4
|
+
/**
|
|
5
|
+
* Query seeds of a schema created within a calendar month (local timezone bounds).
|
|
6
|
+
* No collection cache; may write-through to item cache when remote.
|
|
7
|
+
*/
|
|
8
|
+
export declare function queryBySchemaForMonth(schemaName: string, year: number, month: number, options?: AssembleOptions): Promise<SeedRecord[]>;
|
|
9
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACX,MAAM,YAAY,CAAA;AAyDnB,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAyE9B;AAED,wBAAsB,OAAO,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAyF/B;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,UAAU,EAAE,CAAC,CAuBvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arweaveUrl.d.ts","sourceRoot":"","sources":["../src/arweaveUrl.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEzE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { QueryDataSource } from './source/types.js';
|
|
2
|
+
import type { ChangelogEntry, GetSeedOptions } from './types.js';
|
|
3
|
+
export type AssembleSeedChangelogResult = {
|
|
4
|
+
latestVersionUid: string;
|
|
5
|
+
changelog: ChangelogEntry[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Build a changelog for one seed from all Versions + property attestations.
|
|
9
|
+
* Snapshots are flat (no relation expand / hydrate).
|
|
10
|
+
*/
|
|
11
|
+
export declare function assembleSeedChangelog(seedUid: string, options?: Pick<GetSeedOptions, 'changelog'>, dataSource?: QueryDataSource): Promise<AssembleSeedChangelogResult>;
|
|
12
|
+
//# sourceMappingURL=assembleChangelog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assembleChangelog.d.ts","sourceRoot":"","sources":["../src/assembleChangelog.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAEV,cAAc,EAEd,cAAc,EACf,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,2BAA2B,GAAG;IACxC,gBAAgB,EAAE,MAAM,CAAA;IACxB,SAAS,EAAE,cAAc,EAAE,CAAA;CAC5B,CAAA;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,EAC3C,UAAU,GAAE,eAA4C,GACvD,OAAO,CAAC,2BAA2B,CAAC,CAmDtC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { QueryDataSource } from './source/types.js';
|
|
2
|
+
import type { AssembleOptions, AttestationLike, SeedRecord } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Assemble canonical SeedRecords from Seed attestations (latest Version + canonical properties).
|
|
5
|
+
* Uses per-call state (safe for concurrent requests).
|
|
6
|
+
*/
|
|
7
|
+
export declare function assembleSeeds(schemaName: string, seeds: AttestationLike[], options?: AssembleOptions, dataSource?: QueryDataSource): Promise<SeedRecord[]>;
|
|
8
|
+
//# sourceMappingURL=assembleSeeds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assembleSeeds.d.ts","sourceRoot":"","sources":["../src/assembleSeeds.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAob9E;;;GAGG;AACH,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,eAAe,EAAE,EACxB,OAAO,CAAC,EAAE,eAAe,EACzB,UAAU,GAAE,eAA4C,GACvD,OAAO,CAAC,UAAU,EAAE,CAAC,CA+BvB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DEFAULT_ARWEAVE_HOST as e, DEFAULT_ARWEAVE_HOST as t, resolveArweaveHostFromEnv as n } from "@seedprotocol/arweave";
|
|
2
|
+
//#region src/bootstrap.ts
|
|
3
|
+
var r = !1;
|
|
4
|
+
function i(t) {
|
|
5
|
+
return t ?? n() ?? e;
|
|
6
|
+
}
|
|
7
|
+
async function a(e) {
|
|
8
|
+
if (r) return;
|
|
9
|
+
let [{ registerNodeEasPlatform: t }, { registerNodeArweavePlatform: n }] = await Promise.all([import("@seedprotocol/eas/node"), import("@seedprotocol/arweave/node")]);
|
|
10
|
+
if (t(), n({ arweaveDomain: i(e?.arweaveDomain) }), e?.arweaveDomain) {
|
|
11
|
+
let { BaseArweaveClient: t } = await import("@seedprotocol/arweave");
|
|
12
|
+
t.setHost(e.arweaveDomain);
|
|
13
|
+
}
|
|
14
|
+
r = !0;
|
|
15
|
+
}
|
|
16
|
+
async function o() {
|
|
17
|
+
r = !1;
|
|
18
|
+
}
|
|
19
|
+
function s() {
|
|
20
|
+
return r;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { o as i, a as n, s as r, t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=bootstrap-DQZ8ehyx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap-DQZ8ehyx.js","names":[],"sources":["../src/bootstrap.ts"],"sourcesContent":["import {\n DEFAULT_ARWEAVE_HOST,\n resolveArweaveHostFromEnv,\n} from '@seedprotocol/arweave'\n\nlet initialized = false\n\nexport type InitializeQueryPlatformOptions = {\n arweaveDomain?: string\n}\n\nfunction resolveQueryArweaveDomain(explicit?: string): string {\n return explicit ?? resolveArweaveHostFromEnv() ?? DEFAULT_ARWEAVE_HOST\n}\n\n/** Register Node EAS + Arweave clients for remote query (no full SDK client). */\nexport async function initializeQueryPlatform(\n options?: InitializeQueryPlatformOptions,\n): Promise<void> {\n if (initialized) return\n const [{ registerNodeEasPlatform }, { registerNodeArweavePlatform }] = await Promise.all([\n import('@seedprotocol/eas/node'),\n import('@seedprotocol/arweave/node'),\n ])\n registerNodeEasPlatform()\n const arweaveDomain = resolveQueryArweaveDomain(options?.arweaveDomain)\n registerNodeArweavePlatform({ arweaveDomain })\n if (options?.arweaveDomain) {\n const { BaseArweaveClient } = await import('@seedprotocol/arweave')\n BaseArweaveClient.setHost(options.arweaveDomain)\n }\n initialized = true\n}\n\nexport async function teardownQueryPlatform(): Promise<void> {\n initialized = false\n}\n\nexport function isQueryPlatformInitialized(): boolean {\n return initialized\n}\n\nexport { DEFAULT_ARWEAVE_HOST } from '@seedprotocol/arweave'\n"],"mappings":";;AAKA,IAAI,IAAc;AAMlB,SAAS,EAA0B,GAA2B;CAC5D,OAAO,KAAY,EAA0B,KAAK;AACpD;AAGA,eAAsB,EACpB,GACe;CACf,IAAI,GAAa;CACjB,IAAM,CAAC,EAAE,8BAA2B,EAAE,oCAAiC,MAAM,QAAQ,IAAI,CACvF,OAAO,2BACP,OAAO,6BACT,CAAC;CAID,IAHA,EAAwB,GAExB,EAA4B,EAAE,eADR,EAA0B,GAAS,aAC3B,EAAc,CAAC,GACzC,GAAS,eAAe;EAC1B,IAAM,EAAE,yBAAsB,MAAM,OAAO;EAC3C,EAAkB,QAAQ,EAAQ,aAAa;CACjD;CACA,IAAc;AAChB;AAEA,eAAsB,IAAuC;CAC3D,IAAc;AAChB;AAEA,SAAgB,IAAsC;CACpD,OAAO;AACT"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type InitializeQueryPlatformOptions = {
|
|
2
|
+
arweaveDomain?: string;
|
|
3
|
+
};
|
|
4
|
+
/** Register Node EAS + Arweave clients for remote query (no full SDK client). */
|
|
5
|
+
export declare function initializeQueryPlatform(options?: InitializeQueryPlatformOptions): Promise<void>;
|
|
6
|
+
export declare function teardownQueryPlatform(): Promise<void>;
|
|
7
|
+
export declare function isQueryPlatformInitialized(): boolean;
|
|
8
|
+
export { DEFAULT_ARWEAVE_HOST } from '@seedprotocol/arweave';
|
|
9
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,8BAA8B,GAAG;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAMD,iFAAiF;AACjF,wBAAsB,uBAAuB,CAC3C,OAAO,CAAC,EAAE,8BAA8B,GACvC,OAAO,CAAC,IAAI,CAAC,CAcf;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3D;AAED,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD;AAED,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { GetSeedResult, SeedRecord } from '../types.js';
|
|
2
|
+
import { MemoryCache } from './MemoryCache.js';
|
|
3
|
+
import type { CachedCollectionData, CachedItemData, QueryCacheConfig, QueryCacheStats } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Unified query cache: memory → disk for collections and items.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CacheManager {
|
|
8
|
+
private memoryCache;
|
|
9
|
+
private fileCache;
|
|
10
|
+
private config;
|
|
11
|
+
private stats;
|
|
12
|
+
constructor(config: QueryCacheConfig);
|
|
13
|
+
get enabled(): boolean;
|
|
14
|
+
getConfig(): QueryCacheConfig;
|
|
15
|
+
getCollection(schemaName: string): Promise<CachedCollectionData | null>;
|
|
16
|
+
setCollection(schemaName: string, items: SeedRecord[]): Promise<CachedCollectionData | null>;
|
|
17
|
+
getItem(seedUid: string, optionsKey: string): Promise<CachedItemData | null>;
|
|
18
|
+
setItem(record: GetSeedResult, optionsKey: string): Promise<CachedItemData | null>;
|
|
19
|
+
writeThroughItems(items: SeedRecord[], optionsKey: string): Promise<void>;
|
|
20
|
+
clearCollection(schemaName: string): Promise<void>;
|
|
21
|
+
clearAll(): Promise<void>;
|
|
22
|
+
withRefreshLock<T>(schemaName: string, fn: () => Promise<T>): Promise<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Merge records by seedUid; new wins. Sort by timeCreated descending.
|
|
25
|
+
*/
|
|
26
|
+
mergeRecords(cachedItems: SeedRecord[], newItems: SeedRecord[]): SeedRecord[];
|
|
27
|
+
/**
|
|
28
|
+
* Keep only records newer than lastProcessedTimestamp.
|
|
29
|
+
*/
|
|
30
|
+
filterNewRecords(items: SeedRecord[], lastProcessedTimestamp: number): SeedRecord[];
|
|
31
|
+
updateConfig(config: Partial<QueryCacheConfig>): void;
|
|
32
|
+
getStats(): QueryCacheStats & {
|
|
33
|
+
memoryStats: ReturnType<MemoryCache['getStats']>;
|
|
34
|
+
};
|
|
35
|
+
resetStats(): void;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=CacheManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheManager.d.ts","sourceRoot":"","sources":["../../src/cache/CacheManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,eAAe,EAChB,MAAM,YAAY,CAAA;AAEnB;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,KAAK,CAKZ;gBAEW,MAAM,EAAE,gBAAgB;IAMpC,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,SAAS,IAAI,gBAAgB;IAIvB,aAAa,CACjB,UAAU,EAAE,MAA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persistent cache for collections and items (Node / best-effort).
|
|
4
|
+
*/
|
|
5
|
+
export declare class FileCache {
|
|
6
|
+
private cacheDir;
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: QueryCacheConfig);
|
|
9
|
+
private ensureCacheDir;
|
|
10
|
+
private ensureItemsDir;
|
|
11
|
+
private collectionPath;
|
|
12
|
+
private itemPath;
|
|
13
|
+
getCollection(schemaName: string): Promise<CachedCollectionData | null>;
|
|
14
|
+
setCollection(schemaName: string, data: CachedCollectionData): Promise<void>;
|
|
15
|
+
getItem(seedUid: string, optionsKey: string): Promise<CachedItemData | null>;
|
|
16
|
+
setItem(data: CachedItemData): Promise<void>;
|
|
17
|
+
clearCollection(schemaName: string): Promise<void>;
|
|
18
|
+
clearItem(seedUid: string, optionsKey: string): Promise<void>;
|
|
19
|
+
clearAll(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=FileCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileCache.d.ts","sourceRoot":"","sources":["../../src/cache/FileCache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAGnB;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,MAAM,CAAkB;gBAEpB,MAAM,EAAE,gBAAgB;YAQtB,cAAc;YAUd,cAAc;IAU5B,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,QAAQ;IAKV,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAsBvE,aAAa,CACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,IAAI,CAAC;IAgBV,OAAO,CACX,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAsB3B,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB5C,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAalD,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa7D,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAuBhC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { GetSeedResult, SeedRecord } from '../types.js';
|
|
2
|
+
import type { CachedCollectionData, CachedItemData, QueryCacheConfig } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* In-memory collection + item cache with TTL and refresh locks.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MemoryCache {
|
|
7
|
+
private collectionCache;
|
|
8
|
+
private itemCache;
|
|
9
|
+
private config;
|
|
10
|
+
private refreshLocks;
|
|
11
|
+
constructor(config: QueryCacheConfig);
|
|
12
|
+
private itemKey;
|
|
13
|
+
getCollection(schemaName: string): CachedCollectionData | null;
|
|
14
|
+
setCollection(schemaName: string, items: SeedRecord[]): CachedCollectionData;
|
|
15
|
+
getItem(seedUid: string, optionsKey: string): CachedItemData | null;
|
|
16
|
+
setItem(record: GetSeedResult, optionsKey: string): CachedItemData;
|
|
17
|
+
clearCollection(schemaName: string): void;
|
|
18
|
+
clearItem(seedUid: string, optionsKey?: string): void;
|
|
19
|
+
clearAll(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Single-flight: concurrent callers for the same schema share one in-flight promise.
|
|
22
|
+
*/
|
|
23
|
+
withRefreshLock<T>(schemaName: string, fn: () => Promise<T>): Promise<T>;
|
|
24
|
+
updateConfig(config: Partial<QueryCacheConfig>): void;
|
|
25
|
+
getStats(): {
|
|
26
|
+
collectionCount: number;
|
|
27
|
+
itemCount: number;
|
|
28
|
+
activeLocks: number;
|
|
29
|
+
};
|
|
30
|
+
}
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A;QACvB,SAAS,EAAE,MAAM,CAAA;QACjB,WAAW,EAAE,MAAM,CAAA;KACpB;CAOF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { QueryCacheConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Load query cache configuration from environment variables.
|
|
4
|
+
*
|
|
5
|
+
* Uses the same CACHE_* vars as feed for ops compatibility:
|
|
6
|
+
* - CACHE_ENABLED
|
|
7
|
+
* - CACHE_TTL (default 3600)
|
|
8
|
+
* - CACHE_DIR (default ./cache)
|
|
9
|
+
* - CACHE_BACKGROUND_REFRESH / CACHE_REFRESH_INTERVAL (unused stubs)
|
|
10
|
+
*
|
|
11
|
+
* In development (NODE_ENV=development), cache is disabled unless
|
|
12
|
+
* CACHE_ENABLED is explicitly true.
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadQueryCacheConfig(): QueryCacheConfig;
|
|
15
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cache/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,IAAI,gBAAgB,CAuCvD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate an ETag from a string value (MD5, first 16 hex chars, quoted).
|
|
3
|
+
*/
|
|
4
|
+
export declare function generateETag(value: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Generate an ETag for a collection working set.
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateCollectionETag(schemaName: string, lastProcessedTimestamp: number, itemCount: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Generate an ETag for a single SeedRecord.
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateItemETag(seedUid: string, versionUid: string, timeCreated: number, optionsKey: string): string;
|
|
13
|
+
//# sourceMappingURL=etag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"etag.d.ts","sourceRoot":"","sources":["../../src/cache/etag.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGlD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,EAClB,sBAAsB,EAAE,MAAM,EAC9B,SAAS,EAAE,MAAM,GAChB,MAAM,CAIR;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,MAAM,CAIR"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CacheManager } from './CacheManager.js';
|
|
2
|
+
import { loadQueryCacheConfig } from './config.js';
|
|
3
|
+
export { CacheManager } from './CacheManager.js';
|
|
4
|
+
export { MemoryCache } from './MemoryCache.js';
|
|
5
|
+
export { FileCache } from './FileCache.js';
|
|
6
|
+
export { loadQueryCacheConfig } from './config.js';
|
|
7
|
+
export { generateETag, generateCollectionETag, generateItemETag, } from './etag.js';
|
|
8
|
+
export { buildAssembleOptionsKey, sanitizeSeedUidForPath, } from './types.js';
|
|
9
|
+
export type { CachedCollectionData, CachedItemData, QueryCacheConfig, QueryCacheStats, } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get the singleton query CacheManager (lazy-init from env).
|
|
12
|
+
*/
|
|
13
|
+
export declare function getQueryCacheManager(): CacheManager;
|
|
14
|
+
/**
|
|
15
|
+
* Reset singleton (tests / config reload).
|
|
16
|
+
*/
|
|
17
|
+
export declare function resetQueryCacheManager(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Create a CacheManager with an explicit config (tests).
|
|
20
|
+
*/
|
|
21
|
+
export declare function createQueryCacheManager(config?: Partial<ReturnType<typeof loadQueryCacheConfig>>): CacheManager;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,YAAY,CAAA;AACnB,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAA;AAInB;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,CAKnD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,GACxD,YAAY,CAKd"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ChangelogInclude, GetSeedOptions, GetSeedResult, SeedRecord } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Cached collection working set for a schema (skip=0 page).
|
|
4
|
+
*/
|
|
5
|
+
export type CachedCollectionData = {
|
|
6
|
+
items: SeedRecord[];
|
|
7
|
+
lastProcessedTimestamp: number;
|
|
8
|
+
lastProcessedItemId: string;
|
|
9
|
+
lastUpdated: number;
|
|
10
|
+
etag: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Cached single-seed assembly result (may include changelog).
|
|
14
|
+
*/
|
|
15
|
+
export type CachedItemData = {
|
|
16
|
+
record: GetSeedResult;
|
|
17
|
+
lastUpdated: number;
|
|
18
|
+
etag: string;
|
|
19
|
+
/** Fingerprint of assemble options used when caching. */
|
|
20
|
+
optionsKey: string;
|
|
21
|
+
};
|
|
22
|
+
export type QueryCacheConfig = {
|
|
23
|
+
ttl: number;
|
|
24
|
+
cacheDir: string;
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
backgroundRefresh: boolean;
|
|
27
|
+
refreshInterval: number;
|
|
28
|
+
};
|
|
29
|
+
export type QueryCacheStats = {
|
|
30
|
+
hits: number;
|
|
31
|
+
misses: number;
|
|
32
|
+
refreshes: number;
|
|
33
|
+
errors: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Build a stable key for assemble options that affect cached payloads.
|
|
37
|
+
* Default latest-only (`include: 'data'`) keeps Phase 2 key `e1-h1`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildAssembleOptionsKey(options?: {
|
|
40
|
+
expandRelations?: boolean;
|
|
41
|
+
hydrateStorage?: boolean;
|
|
42
|
+
include?: ChangelogInclude;
|
|
43
|
+
changelog?: GetSeedOptions['changelog'];
|
|
44
|
+
}): string;
|
|
45
|
+
/**
|
|
46
|
+
* Sanitize seedUid for use as a filename segment.
|
|
47
|
+
*/
|
|
48
|
+
export declare function sanitizeSeedUidForPath(seedUid: string): string;
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cache/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,UAAU,EACX,MAAM,aAAa,CAAA;AAEpB;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,sBAAsB,EAAE,MAAM,CAAA;IAC9B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,aAAa,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAQD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE;IAChD,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,OAAO,CAAC,EAAE,gBAAgB,CAAA;IAC1B,SAAS,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAA;CACxC,GAAG,MAAM,CAkBT;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AttestationLike, ChangelogEntry, ChangelogOptions, PropertyChangelogEntry, VersionChangelogEntry } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Stable-ish deep equality for changelog value comparison.
|
|
4
|
+
*/
|
|
5
|
+
export declare function changelogValuesEqual(a: unknown, b: unknown): boolean;
|
|
6
|
+
export type DecodedProperty = {
|
|
7
|
+
propertyName: string;
|
|
8
|
+
value: string | string[];
|
|
9
|
+
camelName?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Decode a single property attestation into name + value (no relation expand).
|
|
13
|
+
* Returns null when metadata cannot be parsed.
|
|
14
|
+
*/
|
|
15
|
+
export declare function decodePropertyAttestation(property: AttestationLike): DecodedProperty | null;
|
|
16
|
+
/**
|
|
17
|
+
* Build a flat property map from canonical property attestations for one Version.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildFlatSnapshotFromProperties(properties: AttestationLike[]): Record<string, unknown>;
|
|
20
|
+
export type VersionSnapshot = {
|
|
21
|
+
versionUid: string;
|
|
22
|
+
at: number;
|
|
23
|
+
data: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Diff consecutive version snapshots (ascending by `at`).
|
|
27
|
+
* First version: `before = {}`, all keys in `after` are changed.
|
|
28
|
+
*/
|
|
29
|
+
export declare function diffVersionSnapshots(sortedSnapshots: VersionSnapshot[]): VersionChangelogEntry[];
|
|
30
|
+
/**
|
|
31
|
+
* Per-attestation property diffs across all versions (ordered by timeCreated asc).
|
|
32
|
+
*/
|
|
33
|
+
export declare function diffPropertyAttestations(properties: AttestationLike[]): PropertyChangelogEntry[];
|
|
34
|
+
/**
|
|
35
|
+
* Filter by `since` (inclusive), then keep the newest `limit` entries (newest-first).
|
|
36
|
+
* Returned array is newest-first when limit is applied; otherwise chronological (asc).
|
|
37
|
+
*/
|
|
38
|
+
export declare function applyChangelogFilters(entries: ChangelogEntry[], options?: ChangelogOptions): ChangelogEntry[];
|
|
39
|
+
//# sourceMappingURL=changelog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../src/changelog.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,YAAY,CAAA;AAMnB;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAWpE;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,eAAe,GACxB,eAAe,GAAG,IAAI,CA+CxB;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,eAAe,EAAE,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B,CAAA;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,eAAe,EAAE,GACjC,qBAAqB,EAAE,CA0BzB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,eAAe,EAAE,GAC5B,sBAAsB,EAAE,CAyC1B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,cAAc,EAAE,EACzB,OAAO,CAAC,EAAE,gBAAgB,GACzB,cAAc,EAAE,CAiBlB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Related Seed schema names (lowercased) used as primary rich-body sources. */
|
|
2
|
+
export declare const RICH_BODY_STORAGE_SCHEMAS: Set<string>;
|
|
3
|
+
/** @deprecated Alias for {@link RICH_BODY_STORAGE_SCHEMAS} (feed key compatibility). */
|
|
4
|
+
export declare const FEED_RICH_BODY_STORAGE_SCHEMAS: Set<string>;
|
|
5
|
+
export type FieldStorageModels = Record<string, string>;
|
|
6
|
+
export type ListElementStorageModels = Record<string, string[]>;
|
|
7
|
+
/** @deprecated Use {@link FieldStorageModels} */
|
|
8
|
+
export type FeedFieldStorageModels = FieldStorageModels;
|
|
9
|
+
/** @deprecated Use {@link ListElementStorageModels} */
|
|
10
|
+
export type FeedListElementStorageModels = ListElementStorageModels;
|
|
11
|
+
export declare function isRichBodyStorageSchema(schemaName: string): boolean;
|
|
12
|
+
/** @deprecated Use {@link isRichBodyStorageSchema} */
|
|
13
|
+
export declare const isFeedRichBodyStorageSchema: typeof isRichBodyStorageSchema;
|
|
14
|
+
/** html < file < json for tie-breaking among rich body fields. */
|
|
15
|
+
export declare function richBodyModelPriority(schemaName: string): number;
|
|
16
|
+
/** @deprecated Use {@link richBodyModelPriority} */
|
|
17
|
+
export declare const feedRichBodyModelPriority: typeof richBodyModelPriority;
|
|
18
|
+
export declare function getFieldStorageModels(item: Record<string, unknown>): FieldStorageModels | undefined;
|
|
19
|
+
/** @deprecated Use {@link getFieldStorageModels} */
|
|
20
|
+
export declare const getFeedFieldStorageModels: typeof getFieldStorageModels;
|
|
21
|
+
export declare function getListElementStorageModels(item: Record<string, unknown>): ListElementStorageModels | undefined;
|
|
22
|
+
/** @deprecated Use {@link getListElementStorageModels} */
|
|
23
|
+
export declare const getFeedListElementStorageModels: typeof getListElementStorageModels;
|
|
24
|
+
export declare function setFieldStorageModel(item: Record<string, unknown>, fieldKey: string, schemaName: string): void;
|
|
25
|
+
/** @deprecated Use {@link setFieldStorageModel} */
|
|
26
|
+
export declare const setFeedFieldStorageModel: typeof setFieldStorageModel;
|
|
27
|
+
export declare function setListElementStorageModels(item: Record<string, unknown>, outputKey: string, models: string[]): void;
|
|
28
|
+
/** @deprecated Use {@link setListElementStorageModels} */
|
|
29
|
+
export declare const setFeedListElementStorageModels: typeof setListElementStorageModels;
|
|
30
|
+
//# sourceMappingURL=field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,MAAM,GACjB,IAAI,CAQN;AAED,mDAAmD;AACnD,eAAO,MAAM,wBAAwB,6BAAuB,CAAA;AAE5D,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EAAE,GACf,IAAI,CAON;AAED,0DAA0D;AAC1D,eAAO,MAAM,+BAA+B,oCAA8B,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type HydrateStorageOptions = {
|
|
2
|
+
/** Prefer local file body when available; fall back to Arweave gateway fetch. */
|
|
3
|
+
readStorageBody?: (ref: {
|
|
4
|
+
propertyName: string;
|
|
5
|
+
value: unknown;
|
|
6
|
+
localPathHint?: string;
|
|
7
|
+
}) => Promise<string | null>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* True for a single-path gateway URL whose path looks like an Arweave transaction id.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isArweaveTransactionGatewayUrl(raw: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* After relation URL resolution, Html/File fields may be gateway URLs (or local paths).
|
|
15
|
+
* Replace those with the UTF-8 body when `hydrateStorage` is enabled.
|
|
16
|
+
*/
|
|
17
|
+
export declare function hydrateArweaveRichTextInItems(items: Record<string, unknown>[], options?: HydrateStorageOptions): Promise<void>;
|
|
18
|
+
/** @deprecated Use {@link hydrateArweaveRichTextInItems} */
|
|
19
|
+
export declare const hydrateArweaveRichTextInFeedItems: typeof hydrateArweaveRichTextInItems;
|
|
20
|
+
//# sourceMappingURL=hydrateArweaveRichText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrateArweaveRichText.d.ts","sourceRoot":"","sources":["../src/hydrateArweaveRichText.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,qBAAqB,GAAG;IAClC,iFAAiF;IACjF,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE;QACtB,YAAY,EAAE,MAAM,CAAA;QACpB,KAAK,EAAE,OAAO,CAAA;QACd,aAAa,CAAC,EAAE,MAAM,CAAA;KACvB,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;CAC7B,CAAA;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAenE;AAkDD;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAChC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED,4DAA4D;AAC5D,eAAO,MAAM,iCAAiC,sCAAgC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds `arweaveUrl` to an assembled Image seed clone when `storageTransactionId`
|
|
3
|
+
* (or snake_case) is present.
|
|
4
|
+
*/
|
|
5
|
+
export declare function enrichImageSeedClone(clone: Record<string, unknown>): void;
|
|
6
|
+
/** @deprecated Use {@link enrichImageSeedClone} */
|
|
7
|
+
export declare const enrichImageSeedCloneForFeed: typeof enrichImageSeedClone;
|
|
8
|
+
//# sourceMappingURL=imageRelationEnrichment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageRelationEnrichment.d.ts","sourceRoot":"","sources":["../src/imageRelationEnrichment.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAWzE;AAED,mDAAmD;AACnD,eAAO,MAAM,2BAA2B,6BAAuB,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { initializeQueryPlatform, teardownQueryPlatform, isQueryPlatformInitialized, DEFAULT_ARWEAVE_HOST, } from './bootstrap.js';
|
|
2
|
+
export type { InitializeQueryPlatformOptions } from './bootstrap.js';
|
|
3
|
+
export { assembleSeeds } from './assembleSeeds.js';
|
|
4
|
+
export { assembleSeedChangelog } from './assembleChangelog.js';
|
|
5
|
+
export { getSeed, queryBySchema, queryBySchemaForMonth } from './api.js';
|
|
6
|
+
export { registerLocalQuerySource, clearLocalQuerySource, getRegisteredLocalQuerySource, hasLocalQuerySource, createRemoteQueryDataSource, getRemoteQueryDataSource, resolveQuerySource, normalizeSourceMode, } from './source/index.js';
|
|
7
|
+
export type { QueryDataSource, ResolvedQuerySource } from './source/index.js';
|
|
8
|
+
export { buildFlatSnapshotFromProperties, diffVersionSnapshots, diffPropertyAttestations, applyChangelogFilters, decodePropertyAttestation, changelogValuesEqual, } from './changelog.js';
|
|
9
|
+
export type { SeedRecord, AssembleOptions, QuerySourceMode, GetSeedOptions, GetSeedResult, ChangelogInclude, ChangelogOptions, ChangelogEntry, VersionChangelogEntry, PropertyChangelogEntry, QueryBySchemaOptions, QueryBySchemaResult, AttestationLike, } from './types.js';
|
|
10
|
+
export { getQueryCacheManager, resetQueryCacheManager, createQueryCacheManager, loadQueryCacheConfig, CacheManager, buildAssembleOptionsKey, } from './cache/index.js';
|
|
11
|
+
export type { CachedCollectionData, CachedItemData, QueryCacheConfig, QueryCacheStats, } from './cache/index.js';
|
|
12
|
+
export { getArweaveUrlForTransaction } from './arweaveUrl.js';
|
|
13
|
+
export { publicListRelationPropertyKey, stripListRelationStorageAliasesForPublicKey, tryCoerceJsonStringArray, } from './listRelationKey.js';
|
|
14
|
+
export { parseEasPropertyMetadata, parseEasPropertyMetadataForFeed, } from './parseEasPropertyMetadata.js';
|
|
15
|
+
export type { EasPropertyMetadata, EasPropertyMetadataForFeed, ParseEasPropertyMetadataResult, ParseEasPropertyMetadataForFeedResult, } from './parseEasPropertyMetadata.js';
|
|
16
|
+
export { parseEasRelationPropertyName } from './parseEasRelationPropertyName.js';
|
|
17
|
+
export type { ParsedEasRelationPropertyName } from './parseEasRelationPropertyName.js';
|
|
18
|
+
export { RICH_BODY_STORAGE_SCHEMAS, FEED_RICH_BODY_STORAGE_SCHEMAS, isRichBodyStorageSchema, isFeedRichBodyStorageSchema, richBodyModelPriority, feedRichBodyModelPriority, getFieldStorageModels, getFeedFieldStorageModels, getListElementStorageModels, getFeedListElementStorageModels, setFieldStorageModel, setFeedFieldStorageModel, setListElementStorageModels, setFeedListElementStorageModels, } from './fieldStorageModel.js';
|
|
19
|
+
export type { FieldStorageModels, FeedFieldStorageModels, ListElementStorageModels, FeedListElementStorageModels, } from './fieldStorageModel.js';
|
|
20
|
+
export { enrichImageSeedClone, enrichImageSeedCloneForFeed, } from './imageRelationEnrichment.js';
|
|
21
|
+
export { hydrateArweaveRichTextInItems, hydrateArweaveRichTextInFeedItems, isArweaveTransactionGatewayUrl, } from './hydrateArweaveRichText.js';
|
|
22
|
+
export type { HydrateStorageOptions } from './hydrateArweaveRichText.js';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|