@graview/ship 0.1.0 → 0.1.3
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 +165 -9
- package/dist/browser-adapter.d.ts +9 -9
- package/dist/browser-adapter.d.ts.map +1 -1
- package/dist/browser-adapter.js +6 -3
- package/dist/browser-adapter.js.map +1 -1
- package/dist/browser.d.ts +10 -6
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +4 -2
- package/dist/browser.js.map +1 -1
- package/dist/cli.d.ts +17 -7
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +41 -7
- package/dist/cli.js.map +1 -1
- package/dist/export.d.ts +27 -2
- package/dist/export.d.ts.map +1 -1
- package/dist/export.js +38 -5
- package/dist/export.js.map +1 -1
- package/dist/file-adapter.d.ts +8 -8
- package/dist/file-adapter.d.ts.map +1 -1
- package/dist/file-adapter.js +58 -8
- package/dist/file-adapter.js.map +1 -1
- package/dist/handler.d.ts +271 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +581 -0
- package/dist/handler.js.map +1 -0
- package/dist/health.d.ts +9 -0
- package/dist/health.d.ts.map +1 -1
- package/dist/health.js +5 -1
- package/dist/health.js.map +1 -1
- package/dist/index.d.ts +14 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/live-protocol.d.ts +208 -0
- package/dist/live-protocol.d.ts.map +1 -0
- package/dist/live-protocol.js +380 -0
- package/dist/live-protocol.js.map +1 -0
- package/dist/live.d.ts +266 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +74 -0
- package/dist/live.js.map +1 -0
- package/dist/meta.d.ts +13 -0
- package/dist/meta.d.ts.map +1 -0
- package/dist/meta.js +2 -0
- package/dist/meta.js.map +1 -0
- package/dist/open-store.d.ts +56 -7
- package/dist/open-store.d.ts.map +1 -1
- package/dist/open-store.js +141 -12
- package/dist/open-store.js.map +1 -1
- package/dist/remote.d.ts +237 -13
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +1033 -88
- package/dist/remote.js.map +1 -1
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +22 -0
- package/dist/runtime.js.map +1 -0
- package/dist/seat-headers.d.ts +26 -0
- package/dist/seat-headers.d.ts.map +1 -0
- package/dist/seat-headers.js +26 -0
- package/dist/seat-headers.js.map +1 -0
- package/dist/serve.d.ts +16 -106
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +95 -217
- package/dist/serve.js.map +1 -1
- package/dist/source-edit.d.ts.map +1 -1
- package/dist/source-edit.js +6 -1
- package/dist/source-edit.js.map +1 -1
- package/dist/steps.d.ts +43 -0
- package/dist/steps.d.ts.map +1 -1
- package/dist/steps.js +69 -0
- package/dist/steps.js.map +1 -1
- package/dist/websocket.d.ts +14 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +163 -0
- package/dist/websocket.js.map +1 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@ declaration plus one persistence adapter is a running deployment.
|
|
|
6
6
|
- **`openStore({ app, adapter })`** — load what was stored, migrate it forward, fold it into
|
|
7
7
|
a live `Store`, and keep the adapter current (every diff appends its operations and
|
|
8
8
|
rewrites the snapshot).
|
|
9
|
+
- **`createSqlAdapter({ sql })`** (from `@graview/core`) — persistence over one synchronous
|
|
10
|
+
`exec(sql, ...params)`: a Durable Object's `ctx.storage.sql` as it is, or better-sqlite3
|
|
11
|
+
through `sqlFromDatabase(db)`. The core's sqlite adapter is this adapter over better-sqlite3,
|
|
12
|
+
so the same tests hold for both.
|
|
9
13
|
- **`createFileAdapter(root)`** — persistence a person can read: `snapshot.json`,
|
|
10
14
|
append-only `log.jsonl`, `meta.json` with the stored schema version. The core's sqlite
|
|
11
15
|
adapter is the scale answer; this is the "where is my data" answer.
|
|
@@ -24,11 +28,22 @@ declaration plus one persistence adapter is a running deployment.
|
|
|
24
28
|
`graview check` refuses a chain with gaps or multi-version jumps before deploy time.
|
|
25
29
|
- **`exportBundle` / `assertBundle`** — the anti-lock-in shape: graph + attributed history +
|
|
26
30
|
version in one JSON bundle, re-importable into any deployment of the same declaration.
|
|
31
|
+
- **A long-lived log compacts.** `opened.compact({ keepDays, keepOps })` makes the graph at
|
|
32
|
+
an undo horizon a checkpoint and has the adapter archive the ops before it (the file
|
|
33
|
+
adapter writes them to `archive/`). The next open loads the checkpoint and the tail, undo
|
|
34
|
+
stops at the horizon and says so, and `exportBundle(app, store, { full: true })` still
|
|
35
|
+
carries every op. The browser adapter keeps no epochs, so it keeps no checkpoint either.
|
|
27
36
|
- **`health(store)`** — coherence, not liveness: dangling edges, standing, sizes.
|
|
28
37
|
- **`serveStore` / `openRemote`** — the store behind HTTP, and the other end of the wire. A
|
|
29
38
|
client sends CALLS, never primitives; the server applies them through an ordinary `Store`
|
|
30
39
|
under the seat the request carries, so the policy refuses on the server exactly what it
|
|
31
40
|
refuses in a browser. `graview serve <entry>` is the command.
|
|
41
|
+
- **`createStoreHandler`** — the same routes as one function from a `Request` to a
|
|
42
|
+
`Response`, for any runtime: a Cloudflare Worker or Durable Object, Deno, Bun. `serveStore`
|
|
43
|
+
is a thin `node:http` wrapper around it. Import it from `@graview/ship/runtime`, the entry
|
|
44
|
+
that reaches no `node:` builtin: the store, migrations, the handler and `openRemote`, without
|
|
45
|
+
the file adapter or the page's localStorage. A host that opens, migrates and heals its own
|
|
46
|
+
`Store` hands it over instead of an adapter: `createStoreHandler({ app, store, seatOf, flush })`.
|
|
32
47
|
- **Content moves as steps.** The step DSL (`stepsMigration`) has five content steps beside
|
|
33
48
|
the schema ones — `put-node`, `patch-node`, `drop-node`, `put-edge`, `drop-edge` — each
|
|
34
49
|
judged against the stored graph when it runs, so a default that is already there is not
|
|
@@ -54,22 +69,163 @@ so a host in front of it knows what it must keep answering for `openRemote`, `gr
|
|
|
54
69
|
|
|
55
70
|
| Method | Path | Says |
|
|
56
71
|
|---|---|---|
|
|
57
|
-
| GET | `/graview/state` | the graph, the log
|
|
58
|
-
| POST | `/graview/ops` | calls in, the ops they produced out — or `undo`, batches to take back; 409 with the policy's sentence when refused |
|
|
72
|
+
| GET | `/graview/state` | the graph, the log, the stored version and the modules on |
|
|
73
|
+
| POST | `/graview/ops` | calls in, the ops they produced out — or `undo`, batches to take back; a `batch` already in the log is answered with the ops it made; 409 with the policy's sentence and a `reason` when refused, 429 with `Retry-After` when the host is busy |
|
|
59
74
|
| GET | `/graview/since?seq=N` | the ops appended after N — everyone else's |
|
|
60
75
|
| GET | `/graview/health` | ship's own report, plus where the data is |
|
|
61
76
|
| GET | `/graview/export` | the whole store as one bundle, the way out |
|
|
62
|
-
| POST | `/graview/here` | say where you are; answers with who else is,
|
|
77
|
+
| POST | `/graview/here` | say where you are; answers with who else is, the ops since `seq`, and the `participant` key you are held under |
|
|
63
78
|
| GET | `/graview/who` | who is here right now |
|
|
64
|
-
| POST | `/graview/leave` | say you have gone |
|
|
79
|
+
| POST | `/graview/leave` | say you have gone — only ever yourself |
|
|
80
|
+
| GET | `/graview/live` | the live wire: a WebSocket of hello/welcome, call/undo/ack/refused/conflict/busy, ops and presence, declaration and reload; 426 to a plain request |
|
|
65
81
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
82
|
+
Who is asking is the host's to say: `serveStore({ seatOf })` reads its own credential from
|
|
83
|
+
the `Request` and returns the principal every call is judged under, or a promise of it. The framework's clients also send the seat
|
|
84
|
+
as headers (`SEAT_HEADERS`: who, as what, by what name, and for whom), and a store believes
|
|
85
|
+
them only when told to — `serveStore({ trustSeatHeaders: true })`, which `graview serve`
|
|
86
|
+
sets for a server on 127.0.0.1 and says so. A store with neither answers 401 on every route
|
|
87
|
+
but health. Whatever a host asks for rides along: `openRemote({ headers })` sends them with
|
|
88
|
+
every request, and the framework never reads them. What a call came through (`via`: `web`,
|
|
89
|
+
`api`, `mcp:Claude`), recorded on the op, is the host's word too: `viaOf(request, seat)` says
|
|
90
|
+
it, or `SEAT_HEADERS.via` where the seat headers are trusted (`openRemote({ via })` sends it,
|
|
91
|
+
`mcp` and `cli` from the commands). A `via` in a call's body or message is never read; without
|
|
92
|
+
either, a socket's calls are `web` and an HTTP call's `api`. `openRemote(...).settled()` resolves once every call sent
|
|
70
93
|
so far has been answered — a browser never waits for it; a host that must report the
|
|
71
94
|
server's verdict before it exits does.
|
|
72
95
|
|
|
96
|
+
## The live wire
|
|
97
|
+
|
|
98
|
+
`openRemote({ live: true })` holds a WebSocket to `/graview/live`, and every op is pushed down
|
|
99
|
+
it as it lands. Calls go down it too; while it is down the client polls and posts, reconnects,
|
|
100
|
+
and catches up from the last op it has. Polling stays: it is the wire `curl` can drive.
|
|
101
|
+
|
|
102
|
+
**A host can watch it.** `remote.status()` is `connecting`, `online` or `offline`
|
|
103
|
+
(`RemoteStatus`), and `remote.onStatus(listener)` is told each time it changes — an offline
|
|
104
|
+
banner's switch. It is offline while a socket that was welcomed is down and nothing has been
|
|
105
|
+
heard since, or when a poll or a call does not reach the server (a network failure, or a 502,
|
|
106
|
+
503 or 504 from a gateway); online once a welcome or any answer lands, a refusal included. A
|
|
107
|
+
call made while the server is away is not taken back: it stays shown, `remote.pending()`
|
|
108
|
+
counts it, and it goes again the moment the server is reached. `remote.counters()`
|
|
109
|
+
(`RemoteCounters`) counts `reconnects`, `rebases` (the server's ops landing under pending
|
|
110
|
+
calls), `conflicts` and `resyncs`, for a beacon. Three options shape it: `backoff`, a function
|
|
111
|
+
of the attempt in milliseconds or `{ min, max, factor }` for the jittered default (250, 10000,
|
|
112
|
+
2); `presenceEveryMs`, how often an unchanged presence is said again down the socket; and
|
|
113
|
+
`visible`, a predicate — while it answers false no presence is said, and in a page it reads
|
|
114
|
+
`document.visibilityState` unless given.
|
|
115
|
+
|
|
116
|
+
| From | Message | Carries |
|
|
117
|
+
|---|---|---|
|
|
118
|
+
| client | `hello` | `seq`, the last op it has (none: the welcome carries the whole state); `protocol`; `wire` (`LIVE_WIRE`); `build`, the host's build the page runs |
|
|
119
|
+
| client | `call` | `cid`, `calls`, `intent`, `batch`, and `base`: the revision of each field it changes |
|
|
120
|
+
| client | `undo` | `cid`, `batches` to take back |
|
|
121
|
+
| client | `here` / `bye` | a presence, as `/graview/here` takes it; gone |
|
|
122
|
+
| server | `welcome` | `protocol`, `wire`, `version` (the declaration it serves), `build`, `participant` (this socket's own key, built from its seat), `seq` (the server's last), and the `ops` after the client's seq |
|
|
123
|
+
| server | `ack` | `cid`, `batch`, `seq` and the `ops` the call made |
|
|
124
|
+
| server | `refused` / `conflict` | `cid` and the sentence; a refusal's `reason` and, when the policy knows who could, `wouldNeed`; a conflict names each field, theirs, yours and who wrote theirs |
|
|
125
|
+
| server | `busy` | `cid` and `retryAfter` in milliseconds: not now, and not refused — the client sends the call again after the wait |
|
|
126
|
+
| server | `ops` / `presence` | everybody's ops as they land, in seq order; who is here |
|
|
127
|
+
| server | `declaration` | `version`: the declaration changed, and the socket is served again after a new hello |
|
|
128
|
+
| server | `reload` | `reason` and `protocol`, the lowest served: the hello's protocol is no longer served |
|
|
129
|
+
|
|
130
|
+
Seqs mean what `/graview/since?seq=N` means, and `hello` and `welcome` carry `WIRE_PROTOCOL`.
|
|
131
|
+
A host on any runtime attaches a socket with `createStoreHandler(...).connect(request, { send,
|
|
132
|
+
close })`, which reads the seat from the upgrade and answers with the connection to hand each
|
|
133
|
+
message to; `serveStore` does this for Node's upgrade. What a seat may not see holds on the
|
|
134
|
+
socket as on the routes.
|
|
135
|
+
|
|
136
|
+
A host that hibernates — a Durable Object wakes on a message with no closure left — holds
|
|
137
|
+
each socket's state itself. `liveProtocol({ store })` (from `@graview/ship/runtime`) is the
|
|
138
|
+
same protocol as functions over the store and one plain-JSON `LiveSocketState` per socket,
|
|
139
|
+
`{ seat, via, cursor?, participant?, held? }`, the thing `serializeAttachment` keeps:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
const live = liveProtocol({ store, version: app.version, flush });
|
|
143
|
+
// On the upgrade: the seat and channel, read once (handler.seatFor(request) does this with seatOf and viaOf).
|
|
144
|
+
ws.serializeAttachment(live.open(seat, "web"));
|
|
145
|
+
// On each message, after any wake:
|
|
146
|
+
const peer = { ...ws.deserializeAttachment(), send: (text) => ws.send(text) };
|
|
147
|
+
const { landed, presence } = await live.receive(peer, text, whoIsHere);
|
|
148
|
+
const { send, ...state } = peer;
|
|
149
|
+
ws.serializeAttachment(state);
|
|
150
|
+
if (landed) live.publish(landed, otherPeers); // each as its own seat sees them, from its own cursor
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`connect()` is this protocol with the state in memory, so there is one implementation.
|
|
154
|
+
|
|
155
|
+
**Who is here is the server's to say.** A presence carries its `kind`, a display `name`
|
|
156
|
+
and, for an agent, `onBehalfOf` (the person's id) and `onBehalfOfName`, all built from the
|
|
157
|
+
seat by `presenceFrom`; a client's own claim of any of them, or of another key, is not read.
|
|
158
|
+
A socket's key is built at `hello` and said back as `welcome.participant`, and
|
|
159
|
+
`openRemote(...).participant()` hands it on, so a client leaves itself out of who is here.
|
|
160
|
+
Somebody without a socket — an agent acting over MCP or an RPC, a polling tab — is announced:
|
|
161
|
+
`handler.announce(visitorPresence(seat), ttlMs)` tells every socket and poll at once and
|
|
162
|
+
stands until `until`. The handler does this itself for every op an agent seat lands in its
|
|
163
|
+
store (`POST /graview/ops`, an MCP handler over the same store, the host's own loop), for
|
|
164
|
+
`VISITOR_PRESENCE_TTL_MS`; `createStoreHandler({ announceAgents: false })` turns it off and a
|
|
165
|
+
number sets the time. A hibernating host keeps `who` itself, with `announcePresence(who,
|
|
166
|
+
visitorPresence(seat), ttlMs)`, and hands it to `receive` and `tell`; a visitor past its
|
|
167
|
+
`until` is never told. Each seat is told as it may see: an agent acting for a person the
|
|
168
|
+
seat may not see is shown without `onBehalfOf` or the name. The Shell draws it as "Claude,
|
|
169
|
+
for Ada" (`presenceName`).
|
|
170
|
+
|
|
171
|
+
**The declaration changes under open tabs.** A host that adds a field calls
|
|
172
|
+
`handler.declarationChanged({ app })` — over an adapter the handler opens the store again
|
|
173
|
+
with `openStore`, which migrates it; over a store the host holds it is handed
|
|
174
|
+
`{ app, store, flush?, migrated? }`. Every socket is told `declaration`; a sleeping host
|
|
175
|
+
makes a `liveProtocol` over the new store and calls `declared(peers)`. `openRemote` asks its
|
|
176
|
+
`resolveApp(version)` for the app at that version (a TS app imports it; a document-declared
|
|
177
|
+
app fetches and compiles its document), opens a new remote store on the server's migrated
|
|
178
|
+
state and hands it to `remote.onDeclaration((next, version) => …)`. The calls still on the
|
|
179
|
+
way are offered again there under the batch they were sent in, so one the server already
|
|
180
|
+
made is not made twice, and one that no longer fits is refused in words on
|
|
181
|
+
`next.onRefusal`. No page reloads. A polling client learns it the same way: every answer a
|
|
182
|
+
poll reads (`/graview/state`, `/graview/since`, `/graview/here`, the `/graview/ops` answer)
|
|
183
|
+
says the declaration `version` and the host's `build`, and `openRemote` compares it on each.
|
|
184
|
+
|
|
185
|
+
**Version skew.** A host says its `build` (an opaque string) in every welcome; a page that
|
|
186
|
+
said another in its hello keeps working and `remote.onBuild(…)` is told once. A host with
|
|
187
|
+
`minProtocol` answers an older protocol's hello with `reload`: `openRemote` writes every
|
|
188
|
+
call not yet answered to its `carry` (`{ storage, key }`, `sessionStorage` in a page),
|
|
189
|
+
calls `reloadPage`, and the next `openRemote` with the same `carry` offers them again.
|
|
190
|
+
Two codecs on one path are told apart by `hello.wire`, and by the WebSocket subprotocol
|
|
191
|
+
`LIVE_SUBPROTOCOL` (`graview.ship.1`): `serveStore` answers it, a Worker answers its upgrade
|
|
192
|
+
with `liveSubprotocol(request)`, and `openRemote` sends it with `subprotocol: true` or hands
|
|
193
|
+
it to its `socket` factory. `WIRE_PROTOCOL` stays 1: every message and field is additive.
|
|
194
|
+
|
|
195
|
+
**A stale write is a conflict, not a loss.** A field's revision is the seq of the op that last
|
|
196
|
+
wrote it (`FieldRevisions`, derived from the log). A call that carries a `base` older than the
|
|
197
|
+
field is refused, before anything is written, naming the field, theirs and yours.
|
|
198
|
+
`openRemote` sends one with every call and hands the refusal to `remote.onConflict(…)`,
|
|
199
|
+
with `conflict.keepTheirs()` and `conflict.useMine()`.
|
|
200
|
+
|
|
201
|
+
**A refusal says why** (FR-46). Every `refused` on the socket, and every refusing answer of
|
|
202
|
+
`POST /graview/ops` (409, or 413 at a host's cap), carries a `reason` from a closed set,
|
|
203
|
+
`REFUSAL_REASONS`, which never changes meaning:
|
|
204
|
+
|
|
205
|
+
| `reason` | What it means |
|
|
206
|
+
|---|---|
|
|
207
|
+
| `forbidden` | the seat may not: the policy, a sight, an agent's declared acts, a module turned off; `wouldNeed` names the roles that could, when the policy knows them |
|
|
208
|
+
| `missing` | what the call names is not there: a record, or a batch to take back |
|
|
209
|
+
| `invalid` | the call as asked does not fit: its arguments, the kind, a rule, a call before `hello` |
|
|
210
|
+
| `limit` | the host's hard cap: the call can never succeed as asked, however long the caller waits |
|
|
211
|
+
|
|
212
|
+
`openRemote`'s `remote.onRefusal((sentence, refusal) => …)` is handed the reason beside the
|
|
213
|
+
sentence, and `remote.send` throws a `RemoteRefusedError` carrying it. The routes' other
|
|
214
|
+
refusing answers say one too: 401 `forbidden`, 404 `missing`, 400 `invalid`.
|
|
215
|
+
|
|
216
|
+
**Busy is not refused** (FR-45). A host's `limit` option — on `createStoreHandler`, `serveStore`
|
|
217
|
+
and `liveProtocol` — is asked of every change before it is judged, with the seat, the channel,
|
|
218
|
+
the size in bytes and the calls. It answers nothing, `{ retryAfter }` or `{ refuse }`:
|
|
219
|
+
|
|
220
|
+
- **busy** — `{ retryAfter }` in milliseconds, for a rate or a queue: "not now". The socket says
|
|
221
|
+
`busy` and HTTP answers 429 with `Retry-After`. Nothing is judged and nothing is refused:
|
|
222
|
+
`openRemote` keeps the change shown and pending and sends it again after the wait. Every later
|
|
223
|
+
call on that socket is busy too until the held one comes again, and HTTP posts go one at a
|
|
224
|
+
time, so a burst lands in the order it was made.
|
|
225
|
+
- **refused, `limit`** — `{ refuse }`, a sentence, for a hard cap such as a message over the
|
|
226
|
+
size a host takes: it would be refused however long the client waited, so it is refused now
|
|
227
|
+
and taken back.
|
|
228
|
+
|
|
73
229
|
## The hosted-store contract
|
|
74
230
|
|
|
75
231
|
A third party stands up their own host — a file store or SQLite, `graview serve`,
|
|
@@ -79,7 +235,7 @@ host of the same API, and it consumes this package the way any customer would.
|
|
|
79
235
|
| Concern | In the framework | In a host (Graview Cloud, or yours) |
|
|
80
236
|
|---|---|---|
|
|
81
237
|
| Op log + snapshot + migrate on open | `openStore` | runs it on the server, per deployment |
|
|
82
|
-
| The wire | `serveStore`, `openRemote`, `WIRE` | production TLS, a gateway URL |
|
|
238
|
+
| The wire | `serveStore`, `createStoreHandler`, `openRemote`, `WIRE` | production TLS, a gateway URL, the runtime it runs in |
|
|
83
239
|
| Who is asking | `Principal` on every `apply`; `seatOf` reads the request | maps users, keys and agents to principals; tenancy; quotas |
|
|
84
240
|
| Seed | read once, on an empty store | the same |
|
|
85
241
|
| Default content moving | `seedSteps`, `applySteps`, `graview sync-seed` | when to run it, and for whom |
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PersistenceAdapter } from "@graview/core";
|
|
2
|
+
import type { StoredMeta } from "./meta.js";
|
|
2
3
|
/**
|
|
3
4
|
* The slice of `Storage` this adapter needs — `localStorage` in a browser,
|
|
4
5
|
* a `Map` dressed as one in a test or a node rehearsal. Declared here rather
|
|
@@ -10,12 +11,8 @@ export interface StorageLike {
|
|
|
10
11
|
removeItem(key: string): void;
|
|
11
12
|
}
|
|
12
13
|
export interface BrowserAdapter extends PersistenceAdapter<string> {
|
|
13
|
-
loadMeta(scope: string):
|
|
14
|
-
|
|
15
|
-
} | null;
|
|
16
|
-
saveMeta(scope: string, meta: {
|
|
17
|
-
version: number;
|
|
18
|
-
}): void;
|
|
14
|
+
loadMeta(scope: string): StoredMeta | null;
|
|
15
|
+
saveMeta(scope: string, meta: StoredMeta): void;
|
|
19
16
|
/** The storage keys this scope occupies — for a person or a test to look. */
|
|
20
17
|
keysFor(scope: string): {
|
|
21
18
|
snapshot: string;
|
|
@@ -30,10 +27,13 @@ export interface BrowserAdapterOptions {
|
|
|
30
27
|
readonly prefix?: string;
|
|
31
28
|
}
|
|
32
29
|
/**
|
|
33
|
-
* Persistence in the browser itself: the SAME
|
|
30
|
+
* Persistence in the browser itself: the SAME things the file adapter
|
|
34
31
|
* writes — the snapshot, the append-only log, the stored schema version —
|
|
35
|
-
* as three `localStorage` entries per scope.
|
|
36
|
-
*
|
|
32
|
+
* as three `localStorage` entries per scope. Not the epochs (FR-27): each
|
|
33
|
+
* keeps a whole copy of the graph as its base, and a second copy in a few
|
|
34
|
+
* megabytes ran a two-thousand-talk programme out of room; a page's store
|
|
35
|
+
* is verified by the host it is served from, not in the page. It slots into `openStore` unchanged, migrations included, so a
|
|
36
|
+
* sample app that remembers is the
|
|
37
37
|
* same lifecycle as a deployment that does, minus the server.
|
|
38
38
|
*
|
|
39
39
|
* `localStorage` is synchronous and small (a few megabytes an origin), which
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-adapter.d.ts","sourceRoot":"","sources":["../src/browser-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"browser-adapter.d.ts","sourceRoot":"","sources":["../src/browser-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,UAAU,CAAC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,CACvB,QAAQ,GAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB,GACV,MAAM,CAIR"}
|
package/dist/browser-adapter.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Persistence in the browser itself: the SAME
|
|
2
|
+
* Persistence in the browser itself: the SAME things the file adapter
|
|
3
3
|
* writes — the snapshot, the append-only log, the stored schema version —
|
|
4
|
-
* as three `localStorage` entries per scope.
|
|
5
|
-
*
|
|
4
|
+
* as three `localStorage` entries per scope. Not the epochs (FR-27): each
|
|
5
|
+
* keeps a whole copy of the graph as its base, and a second copy in a few
|
|
6
|
+
* megabytes ran a two-thousand-talk programme out of room; a page's store
|
|
7
|
+
* is verified by the host it is served from, not in the page. It slots into `openStore` unchanged, migrations included, so a
|
|
8
|
+
* sample app that remembers is the
|
|
6
9
|
* same lifecycle as a deployment that does, minus the server.
|
|
7
10
|
*
|
|
8
11
|
* `localStorage` is synchronous and small (a few megabytes an origin), which
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-adapter.js","sourceRoot":"","sources":["../src/browser-adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser-adapter.js","sourceRoot":"","sources":["../src/browser-adapter.ts"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAiC,EAAE;IACtE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC;IAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC;QAClC,QAAQ,EAAE,GAAG,MAAM,IAAI,KAAK,WAAW;QACvC,GAAG,EAAE,GAAG,MAAM,IAAI,KAAK,MAAM;QAC7B,IAAI,EAAE,GAAG,MAAM,IAAI,KAAK,OAAO;KACh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AAC,CAAC;IACvC,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG;QAAE,OAAO;IAClD,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AACrD,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,SAAS,CACvB,WAAuC,UAAwD;KAC5F,QAAQ;IAEX,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC"}
|
package/dist/browser.d.ts
CHANGED
|
@@ -6,21 +6,25 @@
|
|
|
6
6
|
export { browserStartsFresh, createBrowserAdapter, forgetFreshParam, freshHref, } from "./browser-adapter.js";
|
|
7
7
|
export type { BrowserAdapter, BrowserAdapterOptions, StorageLike } from "./browser-adapter.js";
|
|
8
8
|
export { migrateSnapshot, pendingMigrations } from "./migrations.js";
|
|
9
|
-
export { primitivesFor, sayStep, stepsMigration } from "./steps.js";
|
|
10
|
-
export type { MigrationStep } from "./steps.js";
|
|
9
|
+
export { countSteps, primitivesFor, sayStep, stepsMigration } from "./steps.js";
|
|
10
|
+
export type { MigrationStep, StepCount } from "./steps.js";
|
|
11
11
|
export type { MigrationRun } from "./migrations.js";
|
|
12
12
|
export { openStore } from "./open-store.js";
|
|
13
|
-
export type { OpenStoreOptions, OpenedStore } from "./open-store.js";
|
|
13
|
+
export type { Compaction, OpenStoreOptions, OpenedStore } from "./open-store.js";
|
|
14
14
|
export { applyToSnapshot } from "./snapshot.js";
|
|
15
15
|
export type { GraphSnapshot } from "./snapshot.js";
|
|
16
16
|
export { assertBundle, exportBundle } from "./export.js";
|
|
17
|
-
export type { AppBundle } from "./export.js";
|
|
17
|
+
export type { AppBundle, ExportOptions } from "./export.js";
|
|
18
|
+
export type { StoredMeta } from "./meta.js";
|
|
18
19
|
export { health } from "./health.js";
|
|
19
20
|
export type { HealthReport } from "./health.js";
|
|
20
|
-
export { openRemote } from "./remote.js";
|
|
21
|
+
export { openRemote, RemoteRefusedError, seatHeaders } from "./remote.js";
|
|
22
|
+
export { SEAT_HEADERS } from "./seat-headers.js";
|
|
21
23
|
export { createBroadcastPresence, presenceChannelName } from "./presence.js";
|
|
22
24
|
export type { BroadcastPresenceOptions, ChannelLike } from "./presence.js";
|
|
23
|
-
export type { RemoteOptions, RemoteStore } from "./remote.js";
|
|
25
|
+
export type { LiveSocketLike, RemoteBackoff, RemoteConflict, RemoteCounters, RemoteOptions, RemoteRefusal, RemoteStatus, RemoteStore } from "./remote.js";
|
|
26
|
+
export { conflictSentence, LIVE_PATH, LIVE_SUBPROTOCOL, LIVE_WIRE, REFUSAL_REASONS } from "./live.js";
|
|
27
|
+
export type { LiveClientMessage, LiveServerMessage, RefusalReason, WireRefusal } from "./live.js";
|
|
24
28
|
export { assertPhotoFits, photosUsed, storageBytes, PhotoTooLarge, PHOTO_BUDGET_BYTES, PHOTO_MAX_BYTES, } from "./photos.js";
|
|
25
29
|
export type { PhotoBudget, PhotoField } from "./photos.js";
|
|
26
30
|
//# sourceMappingURL=browser.d.ts.map
|
package/dist/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,iBAAiB,E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CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC7E,YAAY,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3E,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1J,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACtG,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAClG,OAAO,EACL,eAAe,EACf,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/browser.js
CHANGED
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { browserStartsFresh, createBrowserAdapter, forgetFreshParam, freshHref, } from "./browser-adapter.js";
|
|
7
7
|
export { migrateSnapshot, pendingMigrations } from "./migrations.js";
|
|
8
|
-
export { primitivesFor, sayStep, stepsMigration } from "./steps.js";
|
|
8
|
+
export { countSteps, primitivesFor, sayStep, stepsMigration } from "./steps.js";
|
|
9
9
|
export { openStore } from "./open-store.js";
|
|
10
10
|
export { applyToSnapshot } from "./snapshot.js";
|
|
11
11
|
export { assertBundle, exportBundle } from "./export.js";
|
|
12
12
|
export { health } from "./health.js";
|
|
13
|
-
export { openRemote } from "./remote.js";
|
|
13
|
+
export { openRemote, RemoteRefusedError, seatHeaders } from "./remote.js";
|
|
14
|
+
export { SEAT_HEADERS } from "./seat-headers.js";
|
|
14
15
|
export { createBroadcastPresence, presenceChannelName } from "./presence.js";
|
|
16
|
+
export { conflictSentence, LIVE_PATH, LIVE_SUBPROTOCOL, LIVE_WIRE, REFUSAL_REASONS } from "./live.js";
|
|
15
17
|
export { assertPhotoFits, photosUsed, storageBytes, PhotoTooLarge, PHOTO_BUDGET_BYTES, PHOTO_MAX_BYTES, } from "./photos.js";
|
|
16
18
|
//# sourceMappingURL=browser.js.map
|
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGhF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAG7E,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEtG,OAAO,EACL,eAAe,EACf,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,eAAe,GAChB,MAAM,aAAa,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PersistenceAdapter } from "@graview/core";
|
|
2
2
|
import type { GraphSnapshot } from "./snapshot.js";
|
|
3
|
+
import type { StoredMeta } from "./meta.js";
|
|
3
4
|
/**
|
|
4
5
|
* `graview serve` — the store behind HTTP, and the data in a folder you can
|
|
5
6
|
* open.
|
|
@@ -10,18 +11,14 @@ import type { GraphSnapshot } from "./snapshot.js";
|
|
|
10
11
|
* `meta.json` carrying the stored version. `--sqlite` swaps the adapter and
|
|
11
12
|
* changes nothing else, which is the actual claim about adapters.
|
|
12
13
|
*/
|
|
13
|
-
export declare const SERVE_USAGE = " graview serve <entry> [--data <dir>] [--port <n>] [--seed <file>] [--sqlite <file>]\n Serves the app's store over HTTP. The op log is the wire: a client
|
|
14
|
+
export declare const SERVE_USAGE = " graview serve <entry> [--data <dir>] [--port <n>] [--seed <file>] [--sqlite <file>]\n [--host <address>] [--trust-seat-headers]\n Serves the app's store over HTTP, and live over a WebSocket at\n /graview/live. The op log is the wire: a client sends calls, the\n store judges them under the caller's own seat, and the ops come back,\n pushed to every socket as they land. Data lives in <dir> (default\n ./data) as readable JSON, or in a SQLite file with --sqlite. It listens on 127.0.0.1 and\n believes the seat a request names in its headers, because only this\n machine can reach it; on any other --host it will not start unless\n --trust-seat-headers says the network in front of it can be trusted.\n\n graview sync-seed <entry> --seed <file> [--data <dir> | --sqlite <file>]\n [--apply] [--prune] [--json]\n Diffs the bootstrap seed against the live store and says, as content\n steps, what would bring the store in step with it: records put,\n fields patched, ties made. Prints and exits by default; --apply lands\n the steps as one logged, undoable operation; --prune also drops what\n the seed no longer has. The seed itself is only ever read at first\n install \u2014 this is how default content moves afterwards, in place of\n deleting the store.\n";
|
|
14
15
|
/** The same store, whichever command asked: parsed from the flags every store command shares. */
|
|
15
16
|
export declare const STORE_FLAGS = "--data <dir> (default ./data) | --sqlite <file>, and --seed <file> for a first install";
|
|
16
17
|
export declare function flag(argv: readonly string[], name: string): string | undefined;
|
|
17
18
|
export interface StoreBackend {
|
|
18
19
|
readonly adapter: PersistenceAdapter<string> & {
|
|
19
|
-
loadMeta?(scope: string):
|
|
20
|
-
|
|
21
|
-
} | null;
|
|
22
|
-
saveMeta?(scope: string, meta: {
|
|
23
|
-
version: number;
|
|
24
|
-
}): void;
|
|
20
|
+
loadMeta?(scope: string): StoredMeta | null;
|
|
21
|
+
saveMeta?(scope: string, meta: StoredMeta): void;
|
|
25
22
|
};
|
|
26
23
|
/** Where the data is, in words a person can open. */
|
|
27
24
|
readonly where: string;
|
|
@@ -34,6 +31,19 @@ export interface StoreBackend {
|
|
|
34
31
|
* to mean different things by the same words.
|
|
35
32
|
*/
|
|
36
33
|
export declare function backendFrom(argv: readonly string[], cwd?: string): Promise<StoreBackend>;
|
|
34
|
+
/**
|
|
35
|
+
* WHETHER `graview serve` BELIEVES A SEAT HEADER (FR-06). Seat headers are
|
|
36
|
+
* how the framework's own clients say who they are, and anyone who can
|
|
37
|
+
* reach the server can send them. On loopback that is only this machine,
|
|
38
|
+
* so they are believed and the command says so; anywhere else it refuses
|
|
39
|
+
* to start unless told the network in front of it is trusted.
|
|
40
|
+
*/
|
|
41
|
+
export declare function seatTrust(host: string, trustFlag: boolean): {
|
|
42
|
+
readonly trust: boolean;
|
|
43
|
+
readonly says: string;
|
|
44
|
+
} | {
|
|
45
|
+
readonly refuse: string;
|
|
46
|
+
};
|
|
37
47
|
export declare function serve(argv: readonly string[]): Promise<number>;
|
|
38
48
|
/**
|
|
39
49
|
* `graview sync-seed` — default content moves without a wipe.
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAc,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAc,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAKpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,42CAoBvB,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,WAAW,2FAA2F,CAAC;AAEpH,wBAAgB,IAAI,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI9E;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAAG;QAC7C,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;QAC5C,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;KAClD,CAAC;IACF,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,SAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAUrG;AAsBD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAQ5I;AAED,wBAAsB,KAAK,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAmCpE;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAkDvE"}
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
-
import { loadApp } from "@graview/core/cli";
|
|
3
|
+
import { entryArg, loadApp } from "@graview/core/cli";
|
|
4
4
|
import { createFileAdapter } from "./file-adapter.js";
|
|
5
|
+
import { LIVE_PATH } from "./live.js";
|
|
5
6
|
import { openStore } from "./open-store.js";
|
|
6
7
|
import { serveStore } from "./serve.js";
|
|
7
8
|
import { sayStep } from "./steps.js";
|
|
@@ -17,10 +18,15 @@ import { applySteps, seedSteps } from "./sync-seed.js";
|
|
|
17
18
|
* changes nothing else, which is the actual claim about adapters.
|
|
18
19
|
*/
|
|
19
20
|
export const SERVE_USAGE = ` graview serve <entry> [--data <dir>] [--port <n>] [--seed <file>] [--sqlite <file>]
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
[--host <address>] [--trust-seat-headers]
|
|
22
|
+
Serves the app's store over HTTP, and live over a WebSocket at
|
|
23
|
+
/graview/live. The op log is the wire: a client sends calls, the
|
|
24
|
+
store judges them under the caller's own seat, and the ops come back,
|
|
25
|
+
pushed to every socket as they land. Data lives in <dir> (default
|
|
26
|
+
./data) as readable JSON, or in a SQLite file with --sqlite. It listens on 127.0.0.1 and
|
|
27
|
+
believes the seat a request names in its headers, because only this
|
|
28
|
+
machine can reach it; on any other --host it will not start unless
|
|
29
|
+
--trust-seat-headers says the network in front of it can be trusted.
|
|
24
30
|
|
|
25
31
|
graview sync-seed <entry> --seed <file> [--data <dir> | --sqlite <file>]
|
|
26
32
|
[--apply] [--prune] [--json]
|
|
@@ -66,28 +72,56 @@ function readSeed(file) {
|
|
|
66
72
|
}
|
|
67
73
|
/** The entry module, or the reason it is not one — said before anything is opened. */
|
|
68
74
|
async function entryOf(argv, command, usage) {
|
|
69
|
-
const entry = argv
|
|
70
|
-
if (!entry
|
|
75
|
+
const entry = entryArg(argv, 0);
|
|
76
|
+
if (!entry) {
|
|
71
77
|
process.stderr.write(`graview ${command}: an entry module is required\n\n${usage}`);
|
|
72
78
|
return 2;
|
|
73
79
|
}
|
|
74
80
|
return loadApp(entry);
|
|
75
81
|
}
|
|
82
|
+
const LOOPBACK = new Set(["127.0.0.1", "::1", "localhost"]);
|
|
83
|
+
/**
|
|
84
|
+
* WHETHER `graview serve` BELIEVES A SEAT HEADER (FR-06). Seat headers are
|
|
85
|
+
* how the framework's own clients say who they are, and anyone who can
|
|
86
|
+
* reach the server can send them. On loopback that is only this machine,
|
|
87
|
+
* so they are believed and the command says so; anywhere else it refuses
|
|
88
|
+
* to start unless told the network in front of it is trusted.
|
|
89
|
+
*/
|
|
90
|
+
export function seatTrust(host, trustFlag) {
|
|
91
|
+
if (LOOPBACK.has(host))
|
|
92
|
+
return { trust: true, says: `believes seat headers: listening on ${host}, which only this machine reaches` };
|
|
93
|
+
if (trustFlag)
|
|
94
|
+
return { trust: true, says: `believes seat headers on ${host}, because --trust-seat-headers says the network in front of it is trusted` };
|
|
95
|
+
return {
|
|
96
|
+
refuse: `graview serve: refusing to listen on ${host} while believing seat headers — anyone who can reach it could claim any seat.\n` +
|
|
97
|
+
` Serve on 127.0.0.1 (the default), put a host that authenticates in front with its own seatOf, or say --trust-seat-headers.\n`,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
76
100
|
export async function serve(argv) {
|
|
77
101
|
const app = await entryOf(argv, "serve", SERVE_USAGE);
|
|
78
102
|
if (typeof app === "number")
|
|
79
103
|
return app;
|
|
80
104
|
const port = Number(flag(argv, "--port") ?? 5196);
|
|
105
|
+
const host = flag(argv, "--host") ?? "127.0.0.1";
|
|
106
|
+
const trust = seatTrust(host, argv.includes("--trust-seat-headers"));
|
|
107
|
+
if ("refuse" in trust) {
|
|
108
|
+
process.stderr.write(trust.refuse);
|
|
109
|
+
return 1;
|
|
110
|
+
}
|
|
81
111
|
const backend = await backendFrom(argv);
|
|
82
112
|
const served = await serveStore({
|
|
83
113
|
app: app,
|
|
84
114
|
adapter: backend.adapter,
|
|
85
115
|
...(backend.seed ? { seed: backend.seed } : {}),
|
|
86
116
|
port,
|
|
117
|
+
host,
|
|
118
|
+
trustSeatHeaders: trust.trust,
|
|
87
119
|
where: backend.where,
|
|
88
120
|
});
|
|
89
121
|
process.stdout.write(`graview serve: ${app.name} on ${served.url}\n` +
|
|
122
|
+
` live: ${served.url.replace(/^http/, "ws")}${LIVE_PATH}\n` +
|
|
90
123
|
` data: ${backend.where} (${backend.adapter.name})\n` +
|
|
124
|
+
` ${trust.says}\n` +
|
|
91
125
|
` ${served.store.graph.allNodes().length} nodes, ${served.opened.store.log.all().length} operations` +
|
|
92
126
|
`${served.opened.migrated.length > 0 ? `, migrated: ${served.opened.migrated.map((op) => op.intent).join("; ")}` : ""}\n`);
|
|
93
127
|
const stop = () => {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","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AAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;AACnF,CAAC"}
|
package/dist/export.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AnySchema, type FormatStamp, type GraviewApp, type LogArchive, type Operation, type Store } from "@graview/core";
|
|
2
2
|
import type { GraphSnapshot } from "./snapshot.js";
|
|
3
3
|
/**
|
|
4
4
|
* THE ANTI-LOCK-IN CLAIM, as a data shape. Everything a deployment is —
|
|
@@ -13,13 +13,38 @@ export interface AppBundle {
|
|
|
13
13
|
readonly app: string;
|
|
14
14
|
readonly version: number;
|
|
15
15
|
readonly exportedAt: string;
|
|
16
|
+
/** The framework that wrote it, and the formats of its snapshot and ops (FR-31). Absent: 0.1.0, format 1. */
|
|
17
|
+
readonly framework?: string;
|
|
18
|
+
readonly formats?: FormatStamp["formats"];
|
|
16
19
|
readonly snapshot: GraphSnapshot;
|
|
17
20
|
readonly log: readonly Operation[];
|
|
21
|
+
/**
|
|
22
|
+
* The seq `log` begins at, when the store was compacted behind an undo
|
|
23
|
+
* horizon and the export left the archive out (FR-23). Absent, the log
|
|
24
|
+
* is the whole history from seq 0: an export with `full: true` always is.
|
|
25
|
+
*/
|
|
26
|
+
readonly horizon?: number;
|
|
18
27
|
}
|
|
19
|
-
export
|
|
28
|
+
export interface ExportOptions {
|
|
29
|
+
/** The persisted log, when the caller has one; the store's own otherwise. */
|
|
20
30
|
readonly log?: readonly Operation[];
|
|
21
31
|
readonly now?: () => string;
|
|
32
|
+
}
|
|
33
|
+
/** Tells `exportBundle` where a store's archive is read from. `openStore` calls it. */
|
|
34
|
+
export declare function rememberArchive(store: object, load: () => Promise<LogArchive>): void;
|
|
35
|
+
/**
|
|
36
|
+
* The bundle of a store. With `full: true` it is the WHOLE history (FR-23):
|
|
37
|
+
* the ops a compaction archived, read from the adapter `openStore` opened
|
|
38
|
+
* the store on, in front of the ops the store holds — a promise, since the
|
|
39
|
+
* archive is read when asked for. Without it, the log is what the store
|
|
40
|
+
* holds, and a compacted store's bundle says where it begins (`horizon`).
|
|
41
|
+
*/
|
|
42
|
+
export declare function exportBundle<S extends AnySchema>(app: GraviewApp<S>, store: Store<S>, options?: ExportOptions & {
|
|
43
|
+
readonly full?: false;
|
|
22
44
|
}): AppBundle;
|
|
45
|
+
export declare function exportBundle<S extends AnySchema>(app: GraviewApp<S>, store: Store<S>, options: ExportOptions & {
|
|
46
|
+
readonly full: true;
|
|
47
|
+
}): Promise<AppBundle>;
|
|
23
48
|
/** Refuses a bundle for a different app or a newer format, plainly. */
|
|
24
49
|
export declare function assertBundle<S extends AnySchema>(app: GraviewApp<S>, bundle: AppBundle): void;
|
|
25
50
|
//# sourceMappingURL=export.d.ts.map
|
package/dist/export.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAC5J,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,6GAA6G;IAC7G,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,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