@graview/ship 0.1.0 → 0.1.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 +54 -6
- 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 +162 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +585 -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 +12 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/live.d.ts +150 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +44 -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 +93 -12
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +446 -76
- package/dist/remote.js.map +1 -1
- package/dist/runtime.d.ts +32 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +21 -0
- package/dist/runtime.js.map +1 -0
- package/dist/seat-headers.d.ts +20 -0
- package/dist/seat-headers.d.ts.map +1 -0
- package/dist/seat-headers.js +20 -0
- package/dist/seat-headers.js.map +1 -0
- package/dist/serve.d.ts +15 -107
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +82 -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 +155 -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,21 @@ 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.
|
|
32
46
|
- **Content moves as steps.** The step DSL (`stepsMigration`) has five content steps beside
|
|
33
47
|
the schema ones — `put-node`, `patch-node`, `drop-node`, `put-edge`, `drop-edge` — each
|
|
34
48
|
judged against the stored graph when it runs, so a default that is already there is not
|
|
@@ -54,7 +68,7 @@ so a host in front of it knows what it must keep answering for `openRemote`, `gr
|
|
|
54
68
|
|
|
55
69
|
| Method | Path | Says |
|
|
56
70
|
|---|---|---|
|
|
57
|
-
| GET | `/graview/state` | the graph, the log
|
|
71
|
+
| GET | `/graview/state` | the graph, the log, the stored version and the modules on |
|
|
58
72
|
| POST | `/graview/ops` | calls in, the ops they produced out — or `undo`, batches to take back; 409 with the policy's sentence when refused |
|
|
59
73
|
| GET | `/graview/since?seq=N` | the ops appended after N — everyone else's |
|
|
60
74
|
| GET | `/graview/health` | ship's own report, plus where the data is |
|
|
@@ -62,14 +76,48 @@ so a host in front of it knows what it must keep answering for `openRemote`, `gr
|
|
|
62
76
|
| POST | `/graview/here` | say where you are; answers with who else is, and the ops since `seq` |
|
|
63
77
|
| GET | `/graview/who` | who is here right now |
|
|
64
78
|
| POST | `/graview/leave` | say you have gone |
|
|
79
|
+
| GET | `/graview/live` | the live wire: a WebSocket of hello/welcome, call/undo/ack/refused/conflict, ops and presence; 426 to a plain request |
|
|
65
80
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
81
|
+
Who is asking is the host's to say: `serveStore({ seatOf })` reads its own credential from
|
|
82
|
+
the `Request` and returns the principal every call is judged under, or a promise of it. The framework's clients also send the seat
|
|
83
|
+
as headers (`SEAT_HEADERS`: who, as what, by what name, and for whom), and a store believes
|
|
84
|
+
them only when told to — `serveStore({ trustSeatHeaders: true })`, which `graview serve`
|
|
85
|
+
sets for a server on 127.0.0.1 and says so. A store with neither answers 401 on every route
|
|
86
|
+
but health. Whatever a host asks for rides along: `openRemote({ headers })` sends them with
|
|
87
|
+
every request, and the framework never reads them. A call says what it came through
|
|
88
|
+
(`via`: `web` from `openRemote`, `mcp` and `cli` from the commands), recorded on the op. `openRemote(...).settled()` resolves once every call sent
|
|
70
89
|
so far has been answered — a browser never waits for it; a host that must report the
|
|
71
90
|
server's verdict before it exits does.
|
|
72
91
|
|
|
92
|
+
## The live wire
|
|
93
|
+
|
|
94
|
+
`openRemote({ live: true })` holds a WebSocket to `/graview/live`, and every op is pushed down
|
|
95
|
+
it as it lands. Calls go down it too; while it is down the client polls and posts, reconnects,
|
|
96
|
+
and catches up from the last op it has. Polling stays: it is the wire `curl` can drive.
|
|
97
|
+
|
|
98
|
+
| From | Message | Carries |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| client | `hello` | `seq`, the last op it has (none: the welcome carries the whole state); `protocol` |
|
|
101
|
+
| client | `call` | `cid`, `calls`, `intent`, `batch`, `via`, and `base`: the revision of each field it changes |
|
|
102
|
+
| client | `undo` | `cid`, `batches` to take back |
|
|
103
|
+
| client | `here` / `bye` | a presence, as `/graview/here` takes it; gone |
|
|
104
|
+
| server | `welcome` | `protocol`, `seq` (the server's last), and the `ops` after the client's seq |
|
|
105
|
+
| server | `ack` | `cid`, `batch`, `seq` and the `ops` the call made |
|
|
106
|
+
| server | `refused` / `conflict` | `cid` and the sentence; a conflict names each field, theirs, yours and who wrote theirs |
|
|
107
|
+
| server | `ops` / `presence` | everybody's ops as they land, in seq order; who is here |
|
|
108
|
+
|
|
109
|
+
Seqs mean what `/graview/since?seq=N` means, and `hello` and `welcome` carry `WIRE_PROTOCOL`.
|
|
110
|
+
A host on any runtime attaches a socket with `createStoreHandler(...).connect(request, { send,
|
|
111
|
+
close })`, which reads the seat from the upgrade and answers with the connection to hand each
|
|
112
|
+
message to; `serveStore` does this for Node's upgrade. What a seat may not see holds on the
|
|
113
|
+
socket as on the routes.
|
|
114
|
+
|
|
115
|
+
**A stale write is a conflict, not a loss.** A field's revision is the seq of the op that last
|
|
116
|
+
wrote it (`FieldRevisions`, derived from the log). A call that carries a `base` older than the
|
|
117
|
+
field is refused, before anything is written, naming the field, theirs and yours.
|
|
118
|
+
`openRemote` sends one with every call and hands the refusal to `remote.onConflict(…)`,
|
|
119
|
+
with `conflict.keepTheirs()` and `conflict.useMine()`.
|
|
120
|
+
|
|
73
121
|
## The hosted-store contract
|
|
74
122
|
|
|
75
123
|
A third party stands up their own host — a file store or SQLite, `graview serve`,
|
|
@@ -79,7 +127,7 @@ host of the same API, and it consumes this package the way any customer would.
|
|
|
79
127
|
| Concern | In the framework | In a host (Graview Cloud, or yours) |
|
|
80
128
|
|---|---|---|
|
|
81
129
|
| 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 |
|
|
130
|
+
| The wire | `serveStore`, `createStoreHandler`, `openRemote`, `WIRE` | production TLS, a gateway URL, the runtime it runs in |
|
|
83
131
|
| Who is asking | `Principal` on every `apply`; `seatOf` reads the request | maps users, keys and agents to principals; tenancy; quotas |
|
|
84
132
|
| Seed | read once, on an empty store | the same |
|
|
85
133
|
| 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,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,cAAe,SAAQ,kBAAkB,CAAC,MAAM,CAAC;IAChE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IAChD,6EAA6E;IAC7E,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACzE;AAED,MAAM,WAAW,qBAAqB;IACpC,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,cAAc,CA4CxF;AAaD;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,GAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB,EACX,SAAS,GAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAE9B,GACV,OAAO,CAKT;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,GAAE;IACH,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE;QAAE,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CAChE,GACtB,IAAI,CAKN;AAED,wEAAwE;AACxE,wBAAgB,SAAS,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;KAChC,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,CAAI,GAAW,EAAY,EAAE;QACxC,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,OAAO,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAO,CAAC;IACtD,CAAC,CAAC;IACF,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAE3F,OAAO;QACL,IAAI,EAAE,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,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, 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, RemoteConflict, RemoteOptions, RemoteStore } from "./remote.js";
|
|
26
|
+
export { conflictSentence, LIVE_PATH } from "./live.js";
|
|
27
|
+
export type { LiveClientMessage, LiveServerMessage } 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,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
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,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAChF,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM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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, 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 } 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,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAG7E,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAExD,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","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,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGvD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;CAoB1B,CAAC;AAEF,iGAAiG;AACjG,MAAM,CAAC,MAAM,WAAW,GAAG,wFAAwF,CAAC;AAEpH,MAAM,UAAU,IAAI,CAAC,IAAuB,EAAE,IAAY;IACxD,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9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C7G,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,aAAa,CAAC,IAAY;IACvC,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;IAC9D,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,MAAM,CAAC,gBAA0B,CAAC,CAEtE,CAAC;IACF,uEAAuE;IACvE,2EAA2E;IAC3E,OAAO,mBAAmB,CAAC,EAAE,QAAQ,EAAE,IAAI,QAAQ,CAAC,IAAI,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,KA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C,SAAS,SAAS,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAsC7J,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAoB7F"}
|
package/dist/export.js
CHANGED
|
@@ -1,15 +1,46 @@
|
|
|
1
|
+
import { assertReadable, formatStamp } from "@graview/core";
|
|
2
|
+
/*
|
|
3
|
+
* WHERE EACH OPENED STORE'S ARCHIVE IS (FR-23). `openStore` says, for a
|
|
4
|
+
* store over an adapter that keeps one, so a full export of that store can
|
|
5
|
+
* read what a normal open never loaded.
|
|
6
|
+
*/
|
|
7
|
+
const ARCHIVES = new WeakMap();
|
|
8
|
+
/** Tells `exportBundle` where a store's archive is read from. `openStore` calls it. */
|
|
9
|
+
export function rememberArchive(store, load) {
|
|
10
|
+
ARCHIVES.set(store, load);
|
|
11
|
+
}
|
|
1
12
|
export function exportBundle(app, store, options = {}) {
|
|
2
|
-
|
|
13
|
+
// The persisted log when the caller has one (it holds migration runs and
|
|
14
|
+
// prior sessions); the in-memory log otherwise.
|
|
15
|
+
const log = options.log ?? store.log.all();
|
|
16
|
+
const bundle = (log, horizon) => ({
|
|
3
17
|
format: "graview-bundle",
|
|
4
18
|
bundleVersion: 1,
|
|
5
19
|
app: app.name,
|
|
6
20
|
version: app.version ?? 1,
|
|
7
21
|
exportedAt: (options.now ?? (() => new Date().toISOString()))(),
|
|
22
|
+
...formatStamp(),
|
|
8
23
|
snapshot: store.snapshot(),
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
24
|
+
log,
|
|
25
|
+
...(horizon > 0 ? { horizon } : {}),
|
|
26
|
+
});
|
|
27
|
+
const horizon = log[0]?.seq ?? store.log.horizon;
|
|
28
|
+
if (!options.full)
|
|
29
|
+
return bundle(log, horizon);
|
|
30
|
+
if (horizon === 0)
|
|
31
|
+
return Promise.resolve(bundle(log, 0));
|
|
32
|
+
const archive = ARCHIVES.get(store);
|
|
33
|
+
if (!archive) {
|
|
34
|
+
return Promise.reject(new Error(`This store's log was compacted at seq ${horizon} and its archive is not reachable from here: export the store openStore opened, whose adapter keeps the archive.`));
|
|
35
|
+
}
|
|
36
|
+
return archive().then((archived) => {
|
|
37
|
+
const before = archived.ops.filter((op) => op.seq < horizon);
|
|
38
|
+
const whole = [...before, ...log];
|
|
39
|
+
const gap = whole.findIndex((op, index) => op.seq !== index);
|
|
40
|
+
if (gap >= 0)
|
|
41
|
+
throw new Error(`The archive does not reach back to seq 0 without a gap: seq ${gap} is missing, so this export would not be the whole history.`);
|
|
42
|
+
return bundle(whole, 0);
|
|
43
|
+
});
|
|
13
44
|
}
|
|
14
45
|
/** Refuses a bundle for a different app or a newer format, plainly. */
|
|
15
46
|
export function assertBundle(app, bundle) {
|
|
@@ -19,6 +50,8 @@ export function assertBundle(app, bundle) {
|
|
|
19
50
|
if (bundle.bundleVersion > 1) {
|
|
20
51
|
throw new Error(`Bundle format ${bundle.bundleVersion} is newer than this ship understands (1). Upgrade @graview/ship, then import.`);
|
|
21
52
|
}
|
|
53
|
+
// A snapshot or ops in a newer format than this framework reads: said, never misread (FR-31).
|
|
54
|
+
assertReadable(bundle);
|
|
22
55
|
if (bundle.app !== app.name) {
|
|
23
56
|
throw new Error(`This bundle is for "${bundle.app}", not "${app.name}"`);
|
|
24
57
|
}
|
package/dist/export.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"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8FAA8F;IAC9F,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,CAAC,GAAG,WAAW,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,MAAM,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,wBAAwB,MAAM,CAAC,OAAO,mCAAmC,GAAG,CAAC,OAAO,IAAI,CAAC,IAAI;YAC3F,+BAA+B,CAClC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/file-adapter.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { PersistenceAdapter } from "@graview/core";
|
|
2
|
+
import type { StoredMeta } from "./meta.js";
|
|
2
3
|
/**
|
|
3
4
|
* Persistence a self-hoster can READ: a directory per scope holding
|
|
4
5
|
* `snapshot.json` (the current graph), `log.jsonl` (one operation per line,
|
|
5
|
-
* append-only — history as plain lines a person can grep),
|
|
6
|
-
* (the stored schema version the migration engine compares against)
|
|
6
|
+
* append-only — history as plain lines a person can grep), `meta.json`
|
|
7
|
+
* (the stored schema version the migration engine compares against),
|
|
8
|
+
* `epochs.json` (the base graphs the log folds from, FR-27), and, once the
|
|
9
|
+
* log has been compacted behind an undo horizon (FR-23), `archive/` with
|
|
10
|
+
* the ops and epochs from before it, as `log.jsonl` and `epochs.json` again.
|
|
7
11
|
*
|
|
8
12
|
* Deliberately boring. The core's sqlite adapter exists for scale; this one
|
|
9
13
|
* exists so "where is my data" has an answer anyone can open.
|
|
10
14
|
*/
|
|
11
15
|
export interface FileAdapter extends PersistenceAdapter<string> {
|
|
12
|
-
loadMeta(scope: string):
|
|
13
|
-
|
|
14
|
-
} | null;
|
|
15
|
-
saveMeta(scope: string, meta: {
|
|
16
|
-
version: number;
|
|
17
|
-
}): void;
|
|
16
|
+
loadMeta(scope: string): StoredMeta | null;
|
|
17
|
+
saveMeta(scope: string, meta: StoredMeta): void;
|
|
18
18
|
/**
|
|
19
19
|
* The directory it writes into.
|
|
20
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-adapter.d.ts","sourceRoot":"","sources":["../src/file-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"file-adapter.d.ts","sourceRoot":"","sources":["../src/file-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgC,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,WAAY,SAAQ,kBAAkB,CAAC,MAAM,CAAC;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IAChD;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CA6F3D"}
|