@graview/ship 0.1.3 → 0.1.5
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 +221 -19
- package/dist/handler.d.ts +66 -9
- package/dist/handler.d.ts.map +1 -1
- package/dist/handler.js +129 -82
- package/dist/handler.js.map +1 -1
- package/dist/health.d.ts +12 -1
- package/dist/health.d.ts.map +1 -1
- package/dist/health.js +15 -4
- package/dist/health.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/live-protocol.d.ts +268 -25
- package/dist/live-protocol.d.ts.map +1 -1
- package/dist/live-protocol.js +675 -100
- package/dist/live-protocol.js.map +1 -1
- package/dist/live.d.ts +39 -8
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js.map +1 -1
- package/dist/remote.d.ts +41 -9
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +206 -57
- package/dist/remote.js.map +1 -1
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +1 -0
- package/dist/serve.js.map +1 -1
- package/package.json +3 -3
package/dist/live-protocol.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type AnySchema, type Author, type FieldConflict, type MutationCall, type Operation, type Presence, type Principal, type Store } from "@graview/core";
|
|
2
|
-
import { type Limit } from "./live.js";
|
|
1
|
+
import { type AnySchema, type Author, type FieldConflict, type MutationCall, type Operation, type PlannedChange, type Presence, type Principal, type Store, type WireRefusal } from "@graview/core";
|
|
2
|
+
import { type Limit, type LimitAnswer, type LimitAsked } from "./live.js";
|
|
3
3
|
/**
|
|
4
4
|
* THE LIVE WIRE AS FUNCTIONS OVER STATE THE HOST HOLDS (FR-41, FR-42).
|
|
5
5
|
*
|
|
@@ -26,8 +26,14 @@ import { type Limit } from "./live.js";
|
|
|
26
26
|
* hibernating host can promise.
|
|
27
27
|
*/
|
|
28
28
|
export interface LiveSocketState {
|
|
29
|
-
/**
|
|
30
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Who this socket is: read once, from its upgrade, by the host's `seatOf`
|
|
31
|
+
* — the principal itself, or a host's key for it (a string), which the
|
|
32
|
+
* protocol's `seatOf` resolves on every message. A key keeps the state
|
|
33
|
+
* small: a seat with fifty roles is most of a Durable Object's 2,048-byte
|
|
34
|
+
* attachment on its own.
|
|
35
|
+
*/
|
|
36
|
+
readonly seat: Principal | string;
|
|
31
37
|
/** What its calls come through, recorded on every op they make: the host's word, never the client's (FR-52). */
|
|
32
38
|
readonly via: string;
|
|
33
39
|
/** The last seq this socket has been sent. Absent until it says hello: a call before that is refused. */
|
|
@@ -40,6 +46,13 @@ export interface LiveSocketState {
|
|
|
40
46
|
participant?: string;
|
|
41
47
|
/** The build its hello said it runs (FR-44): the client's word, kept for the host to count, never judged. */
|
|
42
48
|
build?: string;
|
|
49
|
+
/**
|
|
50
|
+
* THE HOST'S BUILD THIS SOCKET IS SERVED BY (FR-44), said at `open` —
|
|
51
|
+
* for a host that learns it per upgrade, as a worker carrying the socket
|
|
52
|
+
* says which shell it serves. Said in the welcome over the protocol's
|
|
53
|
+
* own `build`.
|
|
54
|
+
*/
|
|
55
|
+
readonly hostBuild?: string;
|
|
43
56
|
/**
|
|
44
57
|
* The call this socket was told is busy (FR-45), and when (epoch ms) it
|
|
45
58
|
* may come again. Every other call is busy too until it does, so nothing
|
|
@@ -50,9 +63,25 @@ export interface LiveSocketState {
|
|
|
50
63
|
readonly until: number;
|
|
51
64
|
};
|
|
52
65
|
}
|
|
53
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* A SOCKET AS A HOST'S JUDGEMENT IS HANDED IT (`build`, `viaOf`): its
|
|
68
|
+
* seat resolved to the principal, its channel, and the host's build it
|
|
69
|
+
* was opened under.
|
|
70
|
+
*/
|
|
71
|
+
export interface ServedSocket {
|
|
72
|
+
readonly seat: Principal;
|
|
73
|
+
readonly via: string;
|
|
74
|
+
readonly hostBuild?: string;
|
|
75
|
+
}
|
|
76
|
+
/** A socket as the protocol is handed it: its state, a way to send it text, and — when the host can — a way to close it. */
|
|
54
77
|
export interface LivePeer extends LiveSocketState {
|
|
55
78
|
send(text: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* Closes the socket. Called only when the socket's seat key is one the
|
|
81
|
+
* host no longer resolves, after it is told so (`{ t: "error", reopen:
|
|
82
|
+
* true }`), with code 4000: a client of any release then opens a new one.
|
|
83
|
+
*/
|
|
84
|
+
close?(code?: number, reason?: string): void;
|
|
56
85
|
}
|
|
57
86
|
/** What one message did, for the host to keep and pass on. */
|
|
58
87
|
export interface LiveReceived {
|
|
@@ -70,14 +99,96 @@ export interface LiveReceived {
|
|
|
70
99
|
export interface LiveProtocolOptions<S extends AnySchema> {
|
|
71
100
|
/** The store the wire serves: the host's own (FR-42). */
|
|
72
101
|
readonly store: Store<S>;
|
|
73
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* THE DECLARATION'S VERSION (FR-43): the host's own monotonic number for
|
|
104
|
+
* the declaration it serves — `app.version`, or a host's document version
|
|
105
|
+
* (Graview Cloud's `documentVersion`) — said in every welcome, in the
|
|
106
|
+
* state, on every route's answer, and in the `declaration` push. A client
|
|
107
|
+
* hands it to its `resolveApp(version)` to get the app at that version,
|
|
108
|
+
* so it names one declaration and only ever grows. A `declaration` push,
|
|
109
|
+
* or a welcome, with the number the client already serves is ignored:
|
|
110
|
+
* nothing reopens. 1 when unsaid.
|
|
111
|
+
*/
|
|
74
112
|
readonly version?: number;
|
|
75
113
|
/** What opening the store migrated, said in a welcome's state. */
|
|
76
114
|
readonly migrated?: readonly string[];
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
115
|
+
/**
|
|
116
|
+
* MAKES WHAT LANDED DURABLE: an ack, and a post's answer, wait for it.
|
|
117
|
+
* Handed every op the protocol landed that is not durable yet, in seq
|
|
118
|
+
* order — the ones that just landed, after any a failed flush left — so
|
|
119
|
+
* a host that writes ops (a ledger) writes exactly these. Flushes run one
|
|
120
|
+
* at a time. One that rejects is not silence: the client is refused
|
|
121
|
+
* `unavailable` in words and keeps the change, the socket's cursor does
|
|
122
|
+
* not move, and the ops stay in the store but are held back from every
|
|
123
|
+
* socket until a later flush holds them — the change sent again, or the
|
|
124
|
+
* next one, which is handed them first. So a change sent again after a
|
|
125
|
+
* failed flush is never made twice, and never acked before it is durable.
|
|
126
|
+
* A flush may be handed an op again after it rejected: one it already
|
|
127
|
+
* holds, it skips.
|
|
128
|
+
*/
|
|
129
|
+
readonly flush?: (landed: readonly Operation[]) => Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* The host's build, an opaque string said in every welcome (FR-44): a
|
|
132
|
+
* client on another one is told once and keeps working. One string for
|
|
133
|
+
* every socket, or a function of the socket for a host whose build
|
|
134
|
+
* differs per upgrade; a socket opened with its own (`open(seat, via,
|
|
135
|
+
* { build })`) is welcomed with that. A route answers with its request's
|
|
136
|
+
* `build`, else this.
|
|
137
|
+
*/
|
|
138
|
+
readonly build?: string | ((peer: ServedSocket) => string | undefined);
|
|
139
|
+
/**
|
|
140
|
+
* THE KEY A WITHHELD OP'S OPAQUE BATCH IS MINTED UNDER. A withheld op is
|
|
141
|
+
* served under `withheld:<16 hex>`, a keyed hash of its batch, so a seat
|
|
142
|
+
* cannot tell which session made a change it may not see. Without one,
|
|
143
|
+
* a key is drawn once per store held — the same opaque batch on every
|
|
144
|
+
* route and socket over that store, until a host that wakes holds a new
|
|
145
|
+
* one; a host that wants it the same across wakes gives a secret of its
|
|
146
|
+
* own, never sent to a client.
|
|
147
|
+
*/
|
|
148
|
+
readonly withheldKey?: string;
|
|
149
|
+
/**
|
|
150
|
+
* THE LOWEST HOST PROTOCOL SERVED (FR-44): the host's own number for its
|
|
151
|
+
* half of the wire — its routing, its auth, its shell — beside ship's
|
|
152
|
+
* `WIRE_PROTOCOL`, which a host does not move. A hello whose
|
|
153
|
+
* `hostProtocol` is below it (absent is 0) is answered `reload` with
|
|
154
|
+
* `hostProtocol` and nothing else, so the page reloads onto a build that
|
|
155
|
+
* speaks it, carrying its unsent calls (`openRemote({ hostProtocol })`).
|
|
156
|
+
*/
|
|
157
|
+
readonly minHostProtocol?: number;
|
|
158
|
+
/**
|
|
159
|
+
* WHAT A CHANGE CAME THROUGH, WHEN THE CLIENT CLAIMS IT (FR-52). A call
|
|
160
|
+
* or an undo may carry `via` — `openRemote` sends the one a call was
|
|
161
|
+
* applied with, as a guest view's `view:<name>` — and this judges it:
|
|
162
|
+
* handed the socket (or the route's `WireAsked`) and the claim, it
|
|
163
|
+
* answers the via to record. Asked of every change, with `claimed`
|
|
164
|
+
* undefined when there is none; answering nothing records the host's
|
|
165
|
+
* own. Absent, a claim is never read: what a change came through is the
|
|
166
|
+
* host's word, and a browser could otherwise record its edit as Claude's.
|
|
167
|
+
*/
|
|
168
|
+
readonly viaOf?: (peer: ServedSocket, claimed: string | undefined) => string | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* THE SEAT A HOST'S KEY NAMES. A socket opened with a key —
|
|
171
|
+
* `open("user:6b3f…", "web")` — keeps only the key in its state, and is
|
|
172
|
+
* judged on every message as the principal this answers. Keep what it
|
|
173
|
+
* reads somewhere a wake does not empty (a Durable Object's storage, not
|
|
174
|
+
* a map in memory), and make the key from the seat, never its session:
|
|
175
|
+
* every tab of one seat holds one key, and `publish` makes one view of
|
|
176
|
+
* it. Answering nothing, the host has lost the seat: the socket is told
|
|
177
|
+
* to open again (`{ t: "error", reopen: true }`), closed when the peer
|
|
178
|
+
* can be, and served nothing more; `openRemote` opens a new socket, whose
|
|
179
|
+
* upgrade the host reads the seat from again. Called at most once per
|
|
180
|
+
* key in one `publish` or `tell`.
|
|
181
|
+
*/
|
|
182
|
+
readonly seatOf?: (key: string) => Principal | undefined;
|
|
183
|
+
/**
|
|
184
|
+
* A REFUSAL IN THE HOST'S WORDS (FR-46). Handed what the store threw, the
|
|
185
|
+
* calls that were refused and the socket (or the route's asker), it
|
|
186
|
+
* answers the refusal to send — reason, sentence, `wouldNeed` — or
|
|
187
|
+
* nothing for ship's own: invalid arguments said field by field in the
|
|
188
|
+
* form's words, an act the app does not have named as the seat named it
|
|
189
|
+
* and no other, and the policy's sentence as the policy said it.
|
|
190
|
+
*/
|
|
191
|
+
readonly refusal?: (error: unknown, calls: readonly MutationCall[], peer: ServedSocket) => WireRefusal | undefined;
|
|
81
192
|
/**
|
|
82
193
|
* THE LOWEST PROTOCOL SERVED (FR-44). A hello on an older one is answered
|
|
83
194
|
* `reload` and nothing else: its calls are refused until it says hello
|
|
@@ -90,11 +201,31 @@ export interface LiveProtocolOptions<S extends AnySchema> {
|
|
|
90
201
|
* (`{ refuse }`, reason `limit`), or nothing.
|
|
91
202
|
*/
|
|
92
203
|
readonly limit?: Limit;
|
|
204
|
+
/**
|
|
205
|
+
* THE HOST'S CAPS ON WHAT A CHANGE WOULD DO. `limit` is asked before a
|
|
206
|
+
* change is compiled, so it cannot count what the change would do; this
|
|
207
|
+
* is asked after — the calls (or the undo) compiled and applied by the
|
|
208
|
+
* store, nothing kept yet — with `limit`'s `asked` and the store's own
|
|
209
|
+
* plan (`PlannedChange`: the ops and primitives, the records and links
|
|
210
|
+
* added, removed and changed, how many records the store would hold).
|
|
211
|
+
* Its answers mean what `limit`'s do: `{ refuse }` is refused `limit`
|
|
212
|
+
* (413 over HTTP), `{ retryAfter }` busy (429), `{ unavailable }`
|
|
213
|
+
* refused `unavailable` (503); and a change it answers is not kept,
|
|
214
|
+
* flushed or sent to anybody. Answering nothing keeps it. Synchronous:
|
|
215
|
+
* the store waits on it with the change applied.
|
|
216
|
+
*/
|
|
217
|
+
readonly admit?: (asked: LimitAsked, planned: PlannedChange) => LimitAnswer | undefined;
|
|
93
218
|
}
|
|
94
219
|
export interface LiveProtocol<S extends AnySchema> {
|
|
95
220
|
readonly store: Store<S>;
|
|
96
|
-
/**
|
|
97
|
-
|
|
221
|
+
/**
|
|
222
|
+
* The state a socket starts with: its seat and its channel, and no
|
|
223
|
+
* cursor until it says hello — and the host's `build` for this socket,
|
|
224
|
+
* when the host learns it per upgrade.
|
|
225
|
+
*/
|
|
226
|
+
open(seat: Principal | string, via: string, options?: {
|
|
227
|
+
readonly build?: string;
|
|
228
|
+
}): LiveSocketState;
|
|
98
229
|
/**
|
|
99
230
|
* Hand it one message the client sent. It answers down `peer.send`,
|
|
100
231
|
* moves `peer.cursor` (and `peer.participant`) as it goes, and says what
|
|
@@ -105,17 +236,60 @@ export interface LiveProtocol<S extends AnySchema> {
|
|
|
105
236
|
* the one before has resolved. A host that publishes while a receive
|
|
106
237
|
* awaits its flush reads the cursor off the same peer object, or
|
|
107
238
|
* leaves the receiving socket out: its ops reach it in the ack.
|
|
239
|
+
*
|
|
240
|
+
* `landed` is what became durable: the call's ops, and any a failed
|
|
241
|
+
* flush had held back before them. When the flush fails, nothing has:
|
|
242
|
+
* `landed` is absent, the cursor is where it was, and the client was
|
|
243
|
+
* refused `unavailable`.
|
|
244
|
+
*
|
|
245
|
+
* `peers` is every socket the host holds, for the same presence: one a
|
|
246
|
+
* socket holds is said `held: "socket"` whatever the host built (as in
|
|
247
|
+
* `tell`). Unsaid, only this socket's own is known to be held.
|
|
108
248
|
*/
|
|
109
|
-
receive(peer: LivePeer, text: string, who?: readonly Presence[]): Promise<LiveReceived>;
|
|
249
|
+
receive(peer: LivePeer, text: string, who?: readonly Presence[], peers?: Iterable<LiveSocketState>): Promise<LiveReceived>;
|
|
110
250
|
/**
|
|
111
251
|
* Ops that landed, down every socket that has said hello and has not had
|
|
112
252
|
* them, each as its own seat may see them (FR-02, FR-16): in seq order,
|
|
113
253
|
* none skipped, caught up from the peer's own cursor. Sets each peer's
|
|
114
|
-
* cursor; the host keeps it.
|
|
254
|
+
* cursor; the host keeps it. Each seat's view is made once however many
|
|
255
|
+
* sockets it holds: its key resolved once, each run of ops redacted and
|
|
256
|
+
* written once.
|
|
115
257
|
*/
|
|
116
258
|
publish(ops: readonly Operation[], peers: Iterable<LivePeer>): void;
|
|
117
|
-
/**
|
|
259
|
+
/**
|
|
260
|
+
* Who is here, told to every socket that has said hello: as its seat may
|
|
261
|
+
* be told it, and without itself. A presence whose participant one of
|
|
262
|
+
* `peers` holds is said `held: "socket"` — it stands while that socket
|
|
263
|
+
* does, with no heartbeat — whatever the host built it with, so a host
|
|
264
|
+
* that rebuilds presences from its own records cannot drop the stamp; a
|
|
265
|
+
* visitor's `until` is said as the host gave it.
|
|
266
|
+
*/
|
|
118
267
|
tell(who: readonly Presence[], peers: Iterable<LivePeer>): void;
|
|
268
|
+
/**
|
|
269
|
+
* `POST /graview/ops`, FOR A HOST THAT ROUTES ITS OWN REQUESTS. Hand it
|
|
270
|
+
* the request's body as text and who is asking; it answers the status,
|
|
271
|
+
* the JSON body and the headers to send, exactly as `createStoreHandler`
|
|
272
|
+
* answers the route — which is this — and `landed`, the ops it put in
|
|
273
|
+
* the store, unredacted, for the host to `publish` to its sockets:
|
|
274
|
+
*
|
|
275
|
+
* - a batch the asking seat already landed: 200 with the ops it made;
|
|
276
|
+
* somebody else's, or not a client's shape: 409, `invalid`;
|
|
277
|
+
* - the host's `limit`: 429 with `Retry-After` (busy), 413 `limit`,
|
|
278
|
+
* 503 `unavailable`;
|
|
279
|
+
* - a field that moved since the call's `base`: 409 with `conflict`;
|
|
280
|
+
* - refused by the store: 409 with its sentence and `reason`;
|
|
281
|
+
* - landed: 200 with the ops as the seat may see them, once `flush`
|
|
282
|
+
* says they are durable.
|
|
283
|
+
*
|
|
284
|
+
* Every answer but busy says the declaration `version` and the `build`.
|
|
285
|
+
*/
|
|
286
|
+
post(body: string, asked: WireAsked): Promise<WireAnswer & {
|
|
287
|
+
readonly landed?: readonly Operation[];
|
|
288
|
+
}>;
|
|
289
|
+
/** `GET /graview/state`: the store as the asking seat sees it — snapshot, log, migrations, modules, horizon. */
|
|
290
|
+
state(asked: WireAsked): WireAnswer;
|
|
291
|
+
/** `GET /graview/since?seq=N`: the ops after `seq`, as the asking seat sees them. */
|
|
292
|
+
since(seq: number, asked: WireAsked): WireAnswer;
|
|
119
293
|
/**
|
|
120
294
|
* THE DECLARATION CHANGED (FR-43), and this protocol is the one over the
|
|
121
295
|
* store migrated to it. Every socket that has said hello is told
|
|
@@ -126,12 +300,38 @@ export interface LiveProtocol<S extends AnySchema> {
|
|
|
126
300
|
*/
|
|
127
301
|
declared(peers: Iterable<LivePeer>): void;
|
|
128
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* WHO ASKS A ROUTE, as the host's own routing says it: the seat its
|
|
305
|
+
* credential names, what the request came through (FR-52), and — for a
|
|
306
|
+
* host whose build differs per request — the build that answers it (FR-44).
|
|
307
|
+
*/
|
|
308
|
+
export interface WireAsked {
|
|
309
|
+
readonly seat: Principal;
|
|
310
|
+
readonly via: string;
|
|
311
|
+
/** The host's build answering this request; the protocol's `build` when absent. */
|
|
312
|
+
readonly build?: string;
|
|
313
|
+
}
|
|
314
|
+
/** A route's answer, for the host to send: a status, a JSON body, and the headers that carry meaning (`Retry-After`). */
|
|
315
|
+
export interface WireAnswer {
|
|
316
|
+
readonly status: number;
|
|
317
|
+
readonly body: Readonly<Record<string, unknown>>;
|
|
318
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* A STORE'S REFUSAL, SAID TO A PERSON (FR-46). The store's own sentences
|
|
322
|
+
* were written for a developer: `Invalid arguments for mutation "add"
|
|
323
|
+
* label: Too small…`, and an unknown act listed every act the app has.
|
|
324
|
+
* Arguments are said field by field in the words the form asked in, and
|
|
325
|
+
* an unknown act by the name the call gave; anything else is the
|
|
326
|
+
* refusal's own sentence, the policy's among them.
|
|
327
|
+
*/
|
|
328
|
+
export declare function wireRefusalOf(store: Store<AnySchema>, error: unknown): WireRefusal;
|
|
129
329
|
/**
|
|
130
330
|
* A PRESENCE AS THE SERVER BUILDS IT. Keyed by the seat — a client cannot
|
|
131
331
|
* claim to be somebody else — with only the session taken from what it
|
|
132
332
|
* said, and stamped with the server's clock. What it is, and for whom it
|
|
133
|
-
* acts, are the seat's (FR-47): a claimed `kind`, `onBehalfOf
|
|
134
|
-
* is dropped, and the seat's name stands over a claimed one. `participant`
|
|
333
|
+
* acts, are the seat's (FR-47): a claimed `kind`, `onBehalfOf`, `until` or
|
|
334
|
+
* `held` is dropped, and the seat's name stands over a claimed one. `participant`
|
|
135
335
|
* is the key the server already gave this socket (its welcome said it):
|
|
136
336
|
* given, the claimed key is not read at all.
|
|
137
337
|
*/
|
|
@@ -165,6 +365,38 @@ export declare function announcePresence(who: readonly Presence[], presence: Pre
|
|
|
165
365
|
* may not see. A participant whose id is no record is shown as they are.
|
|
166
366
|
*/
|
|
167
367
|
export declare function presenceSeenBy(who: readonly Presence[], sees: (id: string) => boolean): Presence[];
|
|
368
|
+
/** Whether a client may name this batch: `batch:<tag>:<n>` or `undo:<tag>:<n>`, as a `Store` mints them. */
|
|
369
|
+
export declare function isClientBatch(batch: unknown): batch is string;
|
|
370
|
+
/**
|
|
371
|
+
* BATCH IDS NO CLIENT CAN NAME FIRST: `served:<kind>:<tag>:<n>`, outside
|
|
372
|
+
* the shape `isClientBatch` accepts. Hand it to the host's own store —
|
|
373
|
+
* `new Store({ batchIds: serverBatchIds() })`, or `openStore`'s
|
|
374
|
+
* `storeOptions` — so what the host lands itself (an agent's RPC, a
|
|
375
|
+
* migration, a seed) is in a batch no client could have claimed.
|
|
376
|
+
* `createStoreHandler` mints its own this way, and `liveProtocol` mints
|
|
377
|
+
* one for a call that names none.
|
|
378
|
+
*/
|
|
379
|
+
export declare function serverBatchIds(): (kind: "batch" | "undo") => string;
|
|
380
|
+
/**
|
|
381
|
+
* THE SAME SEAT. An op is the asking seat's own when its author is the
|
|
382
|
+
* same kind and id — and, for an agent, acts for the same person: Claude
|
|
383
|
+
* for Ada is not Claude for Bo.
|
|
384
|
+
*/
|
|
385
|
+
export declare function authoredBy(author: Author, seat: Principal): boolean;
|
|
386
|
+
/**
|
|
387
|
+
* WHAT A BATCH A CHANGE NAMES IS: answered already (`answered`, the ops it
|
|
388
|
+
* made), refused (`refusal`), or free to land in (neither).
|
|
389
|
+
*/
|
|
390
|
+
export type BatchClaim = {
|
|
391
|
+
readonly answered: readonly Operation[];
|
|
392
|
+
readonly refusal?: undefined;
|
|
393
|
+
} | {
|
|
394
|
+
readonly refusal: WireRefusal;
|
|
395
|
+
readonly answered?: undefined;
|
|
396
|
+
} | {
|
|
397
|
+
readonly answered?: undefined;
|
|
398
|
+
readonly refusal?: undefined;
|
|
399
|
+
};
|
|
168
400
|
/**
|
|
169
401
|
* THE STORE AS EACH SEAT SEES IT, on the wire — shared by the HTTP routes
|
|
170
402
|
* and the socket, so the two can never disagree. Internal: everything in
|
|
@@ -183,23 +415,34 @@ export interface Wire<S extends AnySchema> {
|
|
|
183
415
|
since(principal: Principal, seq: number): Operation[];
|
|
184
416
|
/** The store as the seat sees it. */
|
|
185
417
|
seenFor(principal: Principal): Store<S>;
|
|
418
|
+
/** The store's log as the seat sees it: every op in place, withheld ones under an opaque batch. */
|
|
419
|
+
seenLog(principal: Principal): Operation[];
|
|
186
420
|
whoFor(principal: Principal, who: readonly Presence[]): Presence[];
|
|
187
|
-
/** The fields a call would write that moved since the caller's base: a stale write (FR-05). */
|
|
188
|
-
conflictsOf(author: Principal, calls: readonly MutationCall[], base: unknown): FieldConflict[];
|
|
421
|
+
/** The fields a call would write that moved since the caller's base: a stale write (FR-05). Judged as the call would be, by its seat and channel (FR-56). */
|
|
422
|
+
conflictsOf(author: Principal, calls: readonly MutationCall[], base: unknown, via?: string): FieldConflict[];
|
|
189
423
|
/**
|
|
190
|
-
* SENT TWICE, ANSWERED ONCE: the
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
424
|
+
* SENT TWICE, ANSWERED ONCE: what the batch a call or an undo names is,
|
|
425
|
+
* for the seat that names it. A client that never heard the answer sends
|
|
426
|
+
* again under the same batch — down the socket or over HTTP — and is
|
|
427
|
+
* answered with what it made the first time (FR-49): only ever its own
|
|
428
|
+
* ops. A batch that holds somebody else's, or one a client may not name
|
|
429
|
+
* (`isClientBatch`), is refused `invalid`.
|
|
194
430
|
*/
|
|
195
|
-
|
|
431
|
+
claim(batch: unknown, seat: Principal): BatchClaim;
|
|
196
432
|
/** `{ horizon }` when the log was compacted (FR-23); nothing otherwise. */
|
|
197
433
|
horizonOf(): {
|
|
198
434
|
horizon?: number;
|
|
199
435
|
};
|
|
200
436
|
enabledModules(): string[];
|
|
201
437
|
}
|
|
202
|
-
export declare function wireOf<S extends AnySchema>(store: Store<S
|
|
438
|
+
export declare function wireOf<S extends AnySchema>(store: Store<S>, withheldKey?: string): Wire<S>;
|
|
439
|
+
/**
|
|
440
|
+
* A SEAT, NOT ITS TAB: the principal without its session — and without the
|
|
441
|
+
* session of the person an agent acts for. What a seat is served never
|
|
442
|
+
* depends on which tab asks, so its key never does either: the key a
|
|
443
|
+
* handler asks a host for (`seatKey`), and the one a sight is kept under.
|
|
444
|
+
*/
|
|
445
|
+
export declare function seatOfTab(seat: Principal): Principal;
|
|
203
446
|
/**
|
|
204
447
|
* THE PROTOCOL OVER A STORE. Cheap to make, and safe to make again on
|
|
205
448
|
* every wake: what it keeps is derived from the store.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-protocol.d.ts","sourceRoot":"","sources":["../src/live-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"live-protocol.d.ts","sourceRoot":"","sources":["../src/live-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAkBL,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,aAAa,EAElB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,KAAK,EACV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