@freqhole/reliquary 0.2.1 → 0.2.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 (2) hide show
  1. package/README.md +134 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # reliquary
2
+
3
+ everything media blob storage for the freqhole world of apps: content-addressed blob stores
4
+ (sqlite-native and indexeddb/opfs-browser), iroh-blobs wrappers (fs store lifecycle, gc
5
+ protection, verified transfer), the snatch engine (proactive blob replication), the ensure
6
+ protocol (ask a peer to stage a blob), blob acl gating, media helpers, and shared browser
7
+ utils. rust crate `reliquary` + npm package `@freqhole/reliquary`.
8
+
9
+ ## architecture
10
+
11
+ blake3 is the canonical content address everywhere (sha256 kept only as a legacy secondary
12
+ index). iroh p2p is a transport, not the architecture - the store contracts and transfer
13
+ flows are transport-injected. this library never owns an http server: range serving stays in
14
+ the consuming app.
15
+
16
+ ```mermaid
17
+ graph LR
18
+ subgraph app
19
+ A[your app]
20
+ end
21
+ subgraph rust
22
+ B[BlobStore trait<br/>SqliteBlobStore]
23
+ N[StorageNode<br/>iroh-blobs fs store + gc + downloader]
24
+ SN[SnatchEngine<br/>proactive replication]
25
+ EN[ensure protocol<br/>ALPN freqhole/1]
26
+ G[AccessGate<br/>transfer acl seam]
27
+ end
28
+ subgraph browser ts
29
+ TB[./blobs idb records +<br/>opfs/cache bytes]
30
+ TT[./transfer snatch/serve/prefetch]
31
+ TE[./ensure client + responder]
32
+ TW[./worker hashing + opfs io]
33
+ end
34
+ A --> B & N & SN
35
+ SN --> N
36
+ EN --> B
37
+ G -.gates.-> N
38
+ A --> TB & TT & TE
39
+ TT --> TW
40
+ B --- DB[(reliquary.db<br/>own sqlite file)]
41
+ ```
42
+
43
+ ## structure
44
+
45
+ ```
46
+ rust/ crate: reliquary
47
+ src/
48
+ blobz.rs BlobStore trait + sqlite impl (blake3 pk, soft delete, derived blobs)
49
+ node.rs StorageNode: fs store lifecycle, init_local/attach_endpoint, gc protect
50
+ snatch.rs SnatchEngine over BlobRefSource + PeerProbeTransport traits
51
+ ensure.rs EnsureBlobHandler + PeerMessage wire types (ALPN "freqhole/1")
52
+ gate.rs AccessGate seam for the iroh-blobs verified-transfer ALPN
53
+ hash.rs streaming blake3 helpers
54
+ media/ image resize/webp (feature: media), pdf/video thumbs (feature: thumbnails)
55
+ chunked_import.rs, identity.rs, db.rs
56
+ testing.rs fixtures (feature: test-utils)
57
+ examples/ runnable walkthroughs (see below)
58
+ migrations/ reliquary.db's own migration set
59
+ ts/ npm: @freqhole/reliquary
60
+ src/{blobs,transfer,ensure,worker,automerge,utils,solid,testing}
61
+ docs/ storage-traits.md (the BlobStore contract design)
62
+ ```
63
+
64
+ ## rust: getting started
65
+
66
+ ```rust
67
+ use reliquary::{BlobStore, NewBlobMeta};
68
+ use reliquary::testing::make_blobz_store;
69
+
70
+ let (store, _tmp) = make_blobz_store().await;
71
+ let record = store.insert(bytes, NewBlobMeta {
72
+ filename: Some("example.txt".into()),
73
+ mime: Some("text/plain".into()),
74
+ ..Default::default()
75
+ }).await?;
76
+ let bytes_back = store.read_bytes(&record.blake3).await?;
77
+ ```
78
+
79
+ features (all default except `thumbnails`/`test-utils`): `blobz`, `node`, `snatch`,
80
+ `ensure`, `gate`, `media`, `chunked_import`, `identity`.
81
+
82
+ ```bash
83
+ cargo run --example blob-round-trip --features test-utils # BlobStore contract, no network
84
+ cargo run --example blob-acl-gate --features test-utils # AccessGate over transfer events
85
+ cargo run --example snatch-engine --features test-utils # replication engine w/ mock transport
86
+ cargo run --example two-peer-blob-transfer --features test-utils # real iroh, two endpoints
87
+ ```
88
+
89
+ ## ts: getting started
90
+
91
+ framework-free core subpaths; `solid-js` / `@automerge/automerge-repo` are optional peer
92
+ deps used only by `./solid` / `./automerge`.
93
+
94
+ | subpath | what |
95
+ | ------------- | --------------------------------------------------------------------------------------------------------- |
96
+ | `./blobs` | idb record store + opfs/cache-api bytes, blake3 canonical (`createBlobStore`) |
97
+ | `./transfer` | `snatchBlob`/`snatchBlobToDisk` (pause/resume, per-peer strategy fallthrough), `BlobServer`, `Prefetcher` |
98
+ | `./ensure` | ensure-blob client + responder over any bi-stream (`DEFAULT_ENSURE_ALPN = "freqhole/1"`) |
99
+ | `./worker` | blob worker (hashing, opfs io, chunked upload) + client facade |
100
+ | `./automerge` | IrohNetworkAdapter + acl change-stripping wrapper |
101
+ | `./utils` | image-utils, hash, tagged log |
102
+ | `./solid` | createTransferProgress, createBlobUrl, createDocStore (optional) |
103
+ | `./testing` | mock streams/nodes, wav + deterministic-bytes fixtures, idb harness |
104
+
105
+ ```ts
106
+ import { createBlobStore } from "@freqhole/reliquary/blobs";
107
+ const store = createBlobStore({
108
+ dbName: "myapp-blobs",
109
+ allowCacheFallback: false,
110
+ });
111
+ ```
112
+
113
+ vite consumers: worker-bundled midden resolution needs a `resolveId` plugin in BOTH
114
+ `plugins` and `worker.plugins` (see skein/loam's `vite.config.ts`) - a plain
115
+ `resolve.alias` silently fails at runtime only.
116
+
117
+ ## developer quick start
118
+
119
+ ```bash
120
+ # rust (no DATABASE_URL needed - queries are runtime-checked)
121
+ cargo test --workspace --all-features
122
+ cargo fmt --all --check && cargo clippy --workspace --all-targets
123
+
124
+ # ts
125
+ cd ts && npm i
126
+ npm run typecheck && npm test && npm run build
127
+ ```
128
+
129
+ the crate owns its own sqlite db (`reliquary.db`) at runtime, separate from any consuming
130
+ app's db. consumers today: skein (hub daemon + tauri + loam, full cutover), tomb/grimoire
131
+ (hash; storage seam in progress), playlistz (transfer/blobs adoption planned).
132
+
133
+ see [docs/storage-traits.md](docs/storage-traits.md) for the BlobStore contract design; the
134
+ canonical refactor plan lives in tomb/docs/xl-refactor/.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freqhole/reliquary",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "freqhole media blob storage domain: content-addressed blobs, transfer, worker, solid helpers",
@@ -51,7 +51,7 @@
51
51
  }
52
52
  },
53
53
  "scripts": {
54
- "build": "tsc -p tsconfig.json",
54
+ "build": "cp ../README.md ./README.md && tsc -p tsconfig.json",
55
55
  "typecheck": "tsc --noEmit",
56
56
  "test": "vitest run"
57
57
  },