@smthrs/sync 0.0.0-stage → 1.0.0-rc.4
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/CHANGELOG.md +208 -0
- package/LICENSE +21 -0
- package/README.md +208 -2
- package/dist/cjs/BranchCommands.d.ts +228 -0
- package/dist/cjs/BranchCommands.d.ts.map +1 -0
- package/dist/cjs/BranchCommands.js +316 -0
- package/dist/cjs/BranchCommands.js.map +7 -0
- package/dist/cjs/BranchIds.d.ts +65 -0
- package/dist/cjs/BranchIds.d.ts.map +1 -0
- package/dist/cjs/BranchIds.js +53 -0
- package/dist/cjs/BranchIds.js.map +7 -0
- package/dist/cjs/BranchPresence.d.ts +195 -0
- package/dist/cjs/BranchPresence.d.ts.map +1 -0
- package/dist/cjs/BranchPresence.js +276 -0
- package/dist/cjs/BranchPresence.js.map +7 -0
- package/dist/cjs/BranchProjection.d.ts +179 -0
- package/dist/cjs/BranchProjection.d.ts.map +1 -0
- package/dist/cjs/BranchProjection.js +197 -0
- package/dist/cjs/BranchProjection.js.map +7 -0
- package/dist/cjs/BranchProtocol.d.ts +415 -0
- package/dist/cjs/BranchProtocol.d.ts.map +1 -0
- package/dist/cjs/BranchProtocol.js +172 -0
- package/dist/cjs/BranchProtocol.js.map +7 -0
- package/dist/cjs/BranchRpcs.d.ts +177 -0
- package/dist/cjs/BranchRpcs.d.ts.map +1 -0
- package/dist/cjs/BranchRpcs.js +85 -0
- package/dist/cjs/BranchRpcs.js.map +7 -0
- package/dist/cjs/BranchServer.d.ts +55 -0
- package/dist/cjs/BranchServer.d.ts.map +1 -0
- package/dist/cjs/BranchServer.js +147 -0
- package/dist/cjs/BranchServer.js.map +7 -0
- package/dist/cjs/BranchShare.d.ts +159 -0
- package/dist/cjs/BranchShare.d.ts.map +1 -0
- package/dist/cjs/BranchShare.js +147 -0
- package/dist/cjs/BranchShare.js.map +7 -0
- package/dist/cjs/RunCatalog.d.ts +207 -0
- package/dist/cjs/RunCatalog.d.ts.map +1 -0
- package/dist/cjs/RunCatalog.js +122 -0
- package/dist/cjs/RunCatalog.js.map +7 -0
- package/dist/cjs/SyncAuth.d.ts +70 -0
- package/dist/cjs/SyncAuth.d.ts.map +1 -0
- package/dist/cjs/SyncAuth.js +109 -0
- package/dist/cjs/SyncAuth.js.map +7 -0
- package/dist/cjs/SyncClient.d.ts +274 -0
- package/dist/cjs/SyncClient.d.ts.map +1 -0
- package/dist/cjs/SyncClient.js +474 -0
- package/dist/cjs/SyncClient.js.map +7 -0
- package/dist/cjs/SyncError.d.ts +107 -0
- package/dist/cjs/SyncError.d.ts.map +1 -0
- package/dist/cjs/SyncError.js +110 -0
- package/dist/cjs/SyncError.js.map +7 -0
- package/dist/cjs/SyncPrincipal.d.ts +100 -0
- package/dist/cjs/SyncPrincipal.d.ts.map +1 -0
- package/dist/cjs/SyncPrincipal.js +48 -0
- package/dist/cjs/SyncPrincipal.js.map +7 -0
- package/dist/cjs/SyncProtocol.d.ts +592 -0
- package/dist/cjs/SyncProtocol.d.ts.map +1 -0
- package/dist/cjs/SyncProtocol.js +165 -0
- package/dist/cjs/SyncProtocol.js.map +7 -0
- package/dist/cjs/SyncRpcs.d.ts +92 -0
- package/dist/cjs/SyncRpcs.d.ts.map +1 -0
- package/dist/cjs/SyncRpcs.js +35 -0
- package/dist/cjs/SyncRpcs.js.map +7 -0
- package/dist/cjs/SyncServer.d.ts +184 -0
- package/dist/cjs/SyncServer.d.ts.map +1 -0
- package/dist/cjs/SyncServer.js +513 -0
- package/dist/cjs/SyncServer.js.map +7 -0
- package/dist/cjs/WorkspaceShare.d.ts +174 -0
- package/dist/cjs/WorkspaceShare.d.ts.map +1 -0
- package/dist/cjs/WorkspaceShare.js +149 -0
- package/dist/cjs/WorkspaceShare.js.map +7 -0
- package/dist/cjs/index.d.ts +91 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +67 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/Admission.d.ts +43 -0
- package/dist/cjs/internal/Admission.d.ts.map +1 -0
- package/dist/cjs/internal/Admission.js +90 -0
- package/dist/cjs/internal/Admission.js.map +7 -0
- package/dist/cjs/internal/CauseText.d.ts +55 -0
- package/dist/cjs/internal/CauseText.d.ts.map +1 -0
- package/dist/cjs/internal/CauseText.js +38 -0
- package/dist/cjs/internal/CauseText.js.map +7 -0
- package/dist/cjs/internal/JournalErrorCode.d.ts +23 -0
- package/dist/cjs/internal/JournalErrorCode.d.ts.map +1 -0
- package/dist/cjs/internal/JournalErrorCode.js +34 -0
- package/dist/cjs/internal/JournalErrorCode.js.map +7 -0
- package/dist/cjs/internal/PolicyOptions.d.ts +57 -0
- package/dist/cjs/internal/PolicyOptions.d.ts.map +1 -0
- package/dist/cjs/internal/PolicyOptions.js +62 -0
- package/dist/cjs/internal/PolicyOptions.js.map +7 -0
- package/dist/cjs/internal/ProtocolVersion.d.ts +17 -0
- package/dist/cjs/internal/ProtocolVersion.d.ts.map +1 -0
- package/dist/cjs/internal/ProtocolVersion.js +44 -0
- package/dist/cjs/internal/ProtocolVersion.js.map +7 -0
- package/dist/cjs/internal/ShareSigner.d.ts +173 -0
- package/dist/cjs/internal/ShareSigner.d.ts.map +1 -0
- package/dist/cjs/internal/ShareSigner.js +150 -0
- package/dist/cjs/internal/ShareSigner.js.map +7 -0
- package/dist/cjs/internal/SnapshotBoundary.d.ts +17 -0
- package/dist/cjs/internal/SnapshotBoundary.d.ts.map +1 -0
- package/dist/cjs/internal/SnapshotBoundary.js +97 -0
- package/dist/cjs/internal/SnapshotBoundary.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/test/TestSocket.d.ts +55 -0
- package/dist/cjs/test/TestSocket.d.ts.map +1 -0
- package/dist/cjs/test/TestSocket.js +145 -0
- package/dist/cjs/test/TestSocket.js.map +7 -0
- package/dist/cjs/test/TestSync.d.ts +54 -0
- package/dist/cjs/test/TestSync.d.ts.map +1 -0
- package/dist/cjs/test/TestSync.js +96 -0
- package/dist/cjs/test/TestSync.js.map +7 -0
- package/dist/esm/BranchCommands.d.ts +228 -0
- package/dist/esm/BranchCommands.d.ts.map +1 -0
- package/dist/esm/BranchCommands.js +496 -0
- package/dist/esm/BranchCommands.js.map +1 -0
- package/dist/esm/BranchIds.d.ts +65 -0
- package/dist/esm/BranchIds.d.ts.map +1 -0
- package/dist/esm/BranchIds.js +61 -0
- package/dist/esm/BranchIds.js.map +1 -0
- package/dist/esm/BranchPresence.d.ts +195 -0
- package/dist/esm/BranchPresence.d.ts.map +1 -0
- package/dist/esm/BranchPresence.js +361 -0
- package/dist/esm/BranchPresence.js.map +1 -0
- package/dist/esm/BranchProjection.d.ts +179 -0
- package/dist/esm/BranchProjection.d.ts.map +1 -0
- package/dist/esm/BranchProjection.js +269 -0
- package/dist/esm/BranchProjection.js.map +1 -0
- package/dist/esm/BranchProtocol.d.ts +415 -0
- package/dist/esm/BranchProtocol.d.ts.map +1 -0
- package/dist/esm/BranchProtocol.js +323 -0
- package/dist/esm/BranchProtocol.js.map +1 -0
- package/dist/esm/BranchRpcs.d.ts +177 -0
- package/dist/esm/BranchRpcs.d.ts.map +1 -0
- package/dist/esm/BranchRpcs.js +103 -0
- package/dist/esm/BranchRpcs.js.map +1 -0
- package/dist/esm/BranchServer.d.ts +55 -0
- package/dist/esm/BranchServer.d.ts.map +1 -0
- package/dist/esm/BranchServer.js +168 -0
- package/dist/esm/BranchServer.js.map +1 -0
- package/dist/esm/BranchShare.d.ts +159 -0
- package/dist/esm/BranchShare.d.ts.map +1 -0
- package/dist/esm/BranchShare.js +213 -0
- package/dist/esm/BranchShare.js.map +1 -0
- package/dist/esm/RunCatalog.d.ts +207 -0
- package/dist/esm/RunCatalog.d.ts.map +1 -0
- package/dist/esm/RunCatalog.js +196 -0
- package/dist/esm/RunCatalog.js.map +1 -0
- package/dist/esm/SyncAuth.d.ts +70 -0
- package/dist/esm/SyncAuth.d.ts.map +1 -0
- package/dist/esm/SyncAuth.js +119 -0
- package/dist/esm/SyncAuth.js.map +1 -0
- package/dist/esm/SyncClient.d.ts +274 -0
- package/dist/esm/SyncClient.d.ts.map +1 -0
- package/dist/esm/SyncClient.js +586 -0
- package/dist/esm/SyncClient.js.map +1 -0
- package/dist/esm/SyncError.d.ts +107 -0
- package/dist/esm/SyncError.d.ts.map +1 -0
- package/dist/esm/SyncError.js +133 -0
- package/dist/esm/SyncError.js.map +1 -0
- package/dist/esm/SyncPrincipal.d.ts +100 -0
- package/dist/esm/SyncPrincipal.d.ts.map +1 -0
- package/dist/esm/SyncPrincipal.js +58 -0
- package/dist/esm/SyncPrincipal.js.map +1 -0
- package/dist/esm/SyncProtocol.d.ts +592 -0
- package/dist/esm/SyncProtocol.d.ts.map +1 -0
- package/dist/esm/SyncProtocol.js +434 -0
- package/dist/esm/SyncProtocol.js.map +1 -0
- package/dist/esm/SyncRpcs.d.ts +92 -0
- package/dist/esm/SyncRpcs.d.ts.map +1 -0
- package/dist/esm/SyncRpcs.js +35 -0
- package/dist/esm/SyncRpcs.js.map +1 -0
- package/dist/esm/SyncServer.d.ts +184 -0
- package/dist/esm/SyncServer.d.ts.map +1 -0
- package/dist/esm/SyncServer.js +897 -0
- package/dist/esm/SyncServer.js.map +1 -0
- package/dist/esm/WorkspaceShare.d.ts +174 -0
- package/dist/esm/WorkspaceShare.d.ts.map +1 -0
- package/dist/esm/WorkspaceShare.js +208 -0
- package/dist/esm/WorkspaceShare.js.map +1 -0
- package/dist/esm/index.d.ts +91 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +91 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/Admission.d.ts +43 -0
- package/dist/esm/internal/Admission.d.ts.map +1 -0
- package/dist/esm/internal/Admission.js +80 -0
- package/dist/esm/internal/Admission.js.map +1 -0
- package/dist/esm/internal/CauseText.d.ts +55 -0
- package/dist/esm/internal/CauseText.d.ts.map +1 -0
- package/dist/esm/internal/CauseText.js +67 -0
- package/dist/esm/internal/CauseText.js.map +1 -0
- package/dist/esm/internal/JournalErrorCode.d.ts +23 -0
- package/dist/esm/internal/JournalErrorCode.d.ts.map +1 -0
- package/dist/esm/internal/JournalErrorCode.js +44 -0
- package/dist/esm/internal/JournalErrorCode.js.map +1 -0
- package/dist/esm/internal/PolicyOptions.d.ts +57 -0
- package/dist/esm/internal/PolicyOptions.d.ts.map +1 -0
- package/dist/esm/internal/PolicyOptions.js +70 -0
- package/dist/esm/internal/PolicyOptions.js.map +1 -0
- package/dist/esm/internal/ProtocolVersion.d.ts +17 -0
- package/dist/esm/internal/ProtocolVersion.d.ts.map +1 -0
- package/dist/esm/internal/ProtocolVersion.js +24 -0
- package/dist/esm/internal/ProtocolVersion.js.map +1 -0
- package/dist/esm/internal/ShareSigner.d.ts +173 -0
- package/dist/esm/internal/ShareSigner.d.ts.map +1 -0
- package/dist/esm/internal/ShareSigner.js +219 -0
- package/dist/esm/internal/ShareSigner.js.map +1 -0
- package/dist/esm/internal/SnapshotBoundary.d.ts +17 -0
- package/dist/esm/internal/SnapshotBoundary.d.ts.map +1 -0
- package/dist/esm/internal/SnapshotBoundary.js +68 -0
- package/dist/esm/internal/SnapshotBoundary.js.map +1 -0
- package/dist/esm/test/TestSocket.d.ts +55 -0
- package/dist/esm/test/TestSocket.d.ts.map +1 -0
- package/dist/esm/test/TestSocket.js +128 -0
- package/dist/esm/test/TestSocket.js.map +1 -0
- package/dist/esm/test/TestSync.d.ts +54 -0
- package/dist/esm/test/TestSync.d.ts.map +1 -0
- package/dist/esm/test/TestSync.js +76 -0
- package/dist/esm/test/TestSync.js.map +1 -0
- package/docs/README.md +156 -0
- package/docs/api.md +328 -0
- package/docs/concepts/authorization.md +117 -0
- package/docs/concepts/branches.md +195 -0
- package/docs/concepts/compaction.md +144 -0
- package/docs/concepts/replay-then-follow.md +129 -0
- package/docs/concepts/scopes-and-cursors.md +135 -0
- package/docs/guides/authorize-a-connection.md +174 -0
- package/docs/guides/follow-a-run.md +174 -0
- package/docs/guides/handle-a-compacted-run.md +158 -0
- package/docs/guides/list-workspace-runs.md +120 -0
- package/docs/guides/run-a-long-soak.md +80 -0
- package/docs/guides/serve-the-read-path.md +146 -0
- package/docs/guides/test-a-follower.md +273 -0
- package/docs/installation.md +92 -0
- package/docs/protocol.md +183 -0
- package/docs/quickstart.md +159 -0
- package/docs/troubleshooting.md +234 -0
- package/package.json +304 -3
- package/src/BranchCommands.ts +684 -0
- package/src/BranchIds.ts +76 -0
- package/src/BranchPresence.ts +512 -0
- package/src/BranchProjection.ts +308 -0
- package/src/BranchProtocol.ts +411 -0
- package/src/BranchRpcs.ts +163 -0
- package/src/BranchServer.ts +202 -0
- package/src/BranchShare.ts +297 -0
- package/src/RunCatalog.ts +308 -0
- package/src/SyncAuth.ts +146 -0
- package/src/SyncClient.ts +902 -0
- package/src/SyncError.ts +147 -0
- package/src/SyncPrincipal.ts +115 -0
- package/src/SyncProtocol.ts +594 -0
- package/src/SyncRpcs.ts +40 -0
- package/src/SyncServer.ts +1184 -0
- package/src/WorkspaceShare.ts +292 -0
- package/src/index.ts +107 -0
- package/src/internal/Admission.ts +119 -0
- package/src/internal/CauseText.ts +74 -0
- package/src/internal/JournalErrorCode.ts +46 -0
- package/src/internal/PolicyOptions.ts +97 -0
- package/src/internal/ProtocolVersion.ts +28 -0
- package/src/internal/ShareSigner.ts +300 -0
- package/src/internal/SnapshotBoundary.ts +91 -0
- package/src/test/TestSocket.ts +192 -0
- package/src/test/TestSync.ts +113 -0
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wire contract shared by the sync server and the browser-safe client.
|
|
3
|
+
*
|
|
4
|
+
* Every message is schema-backed so the same definitions serve the RPC group,
|
|
5
|
+
* the HTTP transport, and replay tooling.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.1.0
|
|
8
|
+
*/
|
|
9
|
+
import * as JournalEvent from "@smthrs/journal/JournalEvent";
|
|
10
|
+
import * as Schema from "effect/Schema";
|
|
11
|
+
import { ShareCapability } from "./BranchProtocol.ts";
|
|
12
|
+
/**
|
|
13
|
+
* Wire revision requiring explicit generations in server positions.
|
|
14
|
+
* Missing request versions decode so the server can return a typed refusal.
|
|
15
|
+
*
|
|
16
|
+
* @category constants
|
|
17
|
+
* @since 1.0.0-rc.0
|
|
18
|
+
*/
|
|
19
|
+
export declare const protocolVersion = 1;
|
|
20
|
+
/**
|
|
21
|
+
* Selects every run in the workspace.
|
|
22
|
+
*
|
|
23
|
+
* @category models
|
|
24
|
+
* @since 0.1.0
|
|
25
|
+
*/
|
|
26
|
+
export declare const WorkspaceScope: Schema.TaggedStruct<"Workspace", {}>;
|
|
27
|
+
/**
|
|
28
|
+
* Selects a single run.
|
|
29
|
+
*
|
|
30
|
+
* @category models
|
|
31
|
+
* @since 0.1.0
|
|
32
|
+
*/
|
|
33
|
+
export declare const RunScope: Schema.TaggedStruct<"Run", {
|
|
34
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* The set of runs a request covers.
|
|
38
|
+
*
|
|
39
|
+
* @category models
|
|
40
|
+
* @since 0.1.0
|
|
41
|
+
*/
|
|
42
|
+
export declare const Scope: Schema.Union<readonly [Schema.TaggedStruct<"Workspace", {}>, Schema.TaggedStruct<"Run", {
|
|
43
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
44
|
+
}>]>;
|
|
45
|
+
/**
|
|
46
|
+
* The set of runs a request covers.
|
|
47
|
+
*
|
|
48
|
+
* @category models
|
|
49
|
+
* @since 0.1.0
|
|
50
|
+
*/
|
|
51
|
+
export type Scope = typeof Scope.Type;
|
|
52
|
+
/**
|
|
53
|
+
* The last sequence one run has been DELIVERED to a client through.
|
|
54
|
+
*
|
|
55
|
+
* "Delivered", not "applied": {@link SyncClient}'s default follow advances a
|
|
56
|
+
* cursor as it hands the entry to the consumer, so a consumer whose own apply
|
|
57
|
+
* step then fails must not treat the cursor as an acknowledgement of that
|
|
58
|
+
* apply. A consumer that needs the stronger meaning supplies
|
|
59
|
+
* `SubscribeOptions.apply`, which the client runs to success before the cursor
|
|
60
|
+
* moves. `Progress.applied` records that application claim; a bare wire
|
|
61
|
+
* cursor never acknowledges application to the server.
|
|
62
|
+
*
|
|
63
|
+
* `generation` identifies the run's current history after rewinds. Requests may
|
|
64
|
+
* omit it for persisted generation-zero cursors. Server responses must include
|
|
65
|
+
* it in exactly one cursor for every run represented in Read entries. Clients
|
|
66
|
+
* refuse missing cursor rows or generations before delivery; persist a returned
|
|
67
|
+
* generation with its sequence.
|
|
68
|
+
* Sequence ordering is meaningful only within one generation.
|
|
69
|
+
*
|
|
70
|
+
* @category models
|
|
71
|
+
* @since 0.1.0
|
|
72
|
+
*/
|
|
73
|
+
export declare const RunCursor: Schema.Struct<{
|
|
74
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
75
|
+
readonly afterSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
76
|
+
readonly generation: Schema.optional<Schema.Int>;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* The last sequence one run has been delivered to a client through.
|
|
80
|
+
*
|
|
81
|
+
* @category models
|
|
82
|
+
* @since 0.1.0
|
|
83
|
+
*/
|
|
84
|
+
export type RunCursor = typeof RunCursor.Type;
|
|
85
|
+
/**
|
|
86
|
+
* A client's delivered position across the workspace.
|
|
87
|
+
*
|
|
88
|
+
* At most ONE cursor per run: a request carrying two cursors for the same run
|
|
89
|
+
* is ambiguous about where the read starts, so the server refuses it with
|
|
90
|
+
* `invalid_request` rather than picking one (see {@link duplicateCursorRunId}).
|
|
91
|
+
*
|
|
92
|
+
* @category models
|
|
93
|
+
* @since 0.1.0
|
|
94
|
+
*/
|
|
95
|
+
export declare const WorkspaceCursor: Schema.$Array<Schema.Struct<{
|
|
96
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
97
|
+
readonly afterSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
98
|
+
readonly generation: Schema.optional<Schema.Int>;
|
|
99
|
+
}>>;
|
|
100
|
+
/**
|
|
101
|
+
* A client's delivered position across the workspace.
|
|
102
|
+
*
|
|
103
|
+
* @category models
|
|
104
|
+
* @since 0.1.0
|
|
105
|
+
*/
|
|
106
|
+
export type WorkspaceCursor = typeof WorkspaceCursor.Type;
|
|
107
|
+
/**
|
|
108
|
+
* One run's delivered position as a SERVER states it.
|
|
109
|
+
*
|
|
110
|
+
* Identical to {@link RunCursor} except that `generation` is required: a
|
|
111
|
+
* request may omit it for a persisted generation-zero cursor, a response may
|
|
112
|
+
* not. Server positions are typed with this shape so an implementation that
|
|
113
|
+
* omits a generation fails to compile rather than being refused at run time by
|
|
114
|
+
* every client that reads it.
|
|
115
|
+
*
|
|
116
|
+
* The wire schemas stay lenient on purpose. {@link ReadResponse} and
|
|
117
|
+
* {@link Frame} decode an absent generation so {@link SyncClient} can answer a
|
|
118
|
+
* non-conforming server with a typed `protocol_violation` naming the missing
|
|
119
|
+
* field, rather than a bare decode failure.
|
|
120
|
+
*
|
|
121
|
+
* @category models
|
|
122
|
+
* @since 1.0.0-rc.0
|
|
123
|
+
*/
|
|
124
|
+
export declare const ServerCursor: Schema.Struct<{
|
|
125
|
+
readonly generation: Schema.Int;
|
|
126
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
127
|
+
readonly afterSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* One run's delivered position as a server states it.
|
|
131
|
+
*
|
|
132
|
+
* @category models
|
|
133
|
+
* @since 1.0.0-rc.0
|
|
134
|
+
*/
|
|
135
|
+
export type ServerCursor = typeof ServerCursor.Type;
|
|
136
|
+
/**
|
|
137
|
+
* The scope and cursor set every read and subscribe request carries.
|
|
138
|
+
*
|
|
139
|
+
* Server read, server subscribe and client subscribe each admit a
|
|
140
|
+
* caller-built request against this one schema, so an envelope field is
|
|
141
|
+
* declared once and every entry point agrees on what an admitted request is.
|
|
142
|
+
*
|
|
143
|
+
* @category models
|
|
144
|
+
* @since 1.0.0-rc.0
|
|
145
|
+
*/
|
|
146
|
+
export declare const RequestEnvelope: Schema.Struct<{
|
|
147
|
+
readonly scope: Schema.Union<readonly [Schema.TaggedStruct<"Workspace", {}>, Schema.TaggedStruct<"Run", {
|
|
148
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
149
|
+
}>]>;
|
|
150
|
+
readonly cursors: Schema.$Array<Schema.Struct<{
|
|
151
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
152
|
+
readonly afterSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
153
|
+
readonly generation: Schema.optional<Schema.Int>;
|
|
154
|
+
}>>;
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* The scope and cursor set every read and subscribe request carries.
|
|
158
|
+
*
|
|
159
|
+
* @category models
|
|
160
|
+
* @since 1.0.0-rc.0
|
|
161
|
+
*/
|
|
162
|
+
export type RequestEnvelope = typeof RequestEnvelope.Type;
|
|
163
|
+
/**
|
|
164
|
+
* A client's delivery and application positions, as two cursor sets.
|
|
165
|
+
*
|
|
166
|
+
* `delivered` is transport delivery and never an application acknowledgement.
|
|
167
|
+
* `applied` holds the positions committed after a successful `apply` or
|
|
168
|
+
* `onResync` callback; consumers persist state and these positions in the
|
|
169
|
+
* same transaction. The field names carry the distinction, so neither set is
|
|
170
|
+
* wrapped in a tag.
|
|
171
|
+
*
|
|
172
|
+
* @category models
|
|
173
|
+
* @since 1.0.0-rc.0
|
|
174
|
+
*/
|
|
175
|
+
export declare const Progress: Schema.Struct<{
|
|
176
|
+
readonly delivered: Schema.$Array<Schema.Struct<{
|
|
177
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
178
|
+
readonly afterSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
179
|
+
readonly generation: Schema.optional<Schema.Int>;
|
|
180
|
+
}>>;
|
|
181
|
+
readonly applied: Schema.$Array<Schema.Struct<{
|
|
182
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
183
|
+
readonly afterSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
184
|
+
readonly generation: Schema.optional<Schema.Int>;
|
|
185
|
+
}>>;
|
|
186
|
+
}>;
|
|
187
|
+
/** The value form of progress.
|
|
188
|
+
* @category models
|
|
189
|
+
* @since 1.0.0-rc.0
|
|
190
|
+
*/
|
|
191
|
+
export type Progress = typeof Progress.Type;
|
|
192
|
+
/**
|
|
193
|
+
* The first run named twice in a cursor set, or `undefined` when every run is
|
|
194
|
+
* named at most once.
|
|
195
|
+
*
|
|
196
|
+
* The schema cannot express the uniqueness — `Schema.Array` has no such check
|
|
197
|
+
* — so the one rule is stated once here and enforced by both request paths.
|
|
198
|
+
*
|
|
199
|
+
* @category predicates
|
|
200
|
+
* @since 0.1.0
|
|
201
|
+
*/
|
|
202
|
+
export declare const duplicateCursorRunId: (cursors: WorkspaceCursor) => JournalEvent.RunId | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* Where a follower must resume after the server refused a cursor that starts
|
|
205
|
+
* below a run's compaction floor.
|
|
206
|
+
*
|
|
207
|
+
* Compaction deletes the entries below a checkpoint, so a cursor under the
|
|
208
|
+
* floor names history that no longer exists. `checkpointSeq` is that floor:
|
|
209
|
+
* the checkpoint's state subsumes every entry at or below it, so a follower
|
|
210
|
+
* must restore a snapshot covering that sequence before reading forward.
|
|
211
|
+
* Its applied cursor names that snapshot, which may be newer than this floor.
|
|
212
|
+
*
|
|
213
|
+
* `generation` is the run's history the floor belongs to. A run rewound
|
|
214
|
+
* before it was compacted is past generation zero, and a fresh follower has
|
|
215
|
+
* no earlier cursor to learn that from, so a recovery receipt that omits its
|
|
216
|
+
* generation is bound to this one. The server's refusal of a read always
|
|
217
|
+
* carries it; a snapshot that falls short of a floor refuses without one.
|
|
218
|
+
*
|
|
219
|
+
* This field carries no replacement state. The client fails closed without
|
|
220
|
+
* an explicit recovery handler returning the cursor it actually restored.
|
|
221
|
+
* `SnapshotRequest` fetches a separately selected public projection. Raw journal
|
|
222
|
+
* checkpoints are unredacted and must not be exposed under history permission.
|
|
223
|
+
*
|
|
224
|
+
* @category models
|
|
225
|
+
* @since 0.1.0
|
|
226
|
+
*/
|
|
227
|
+
export declare const Resync: Schema.Struct<{
|
|
228
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
229
|
+
readonly checkpointSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
230
|
+
readonly generation: Schema.optional<Schema.Int>;
|
|
231
|
+
}>;
|
|
232
|
+
/**
|
|
233
|
+
* Where a follower must resume after a compaction refusal.
|
|
234
|
+
*
|
|
235
|
+
* @category models
|
|
236
|
+
* @since 0.1.0
|
|
237
|
+
*/
|
|
238
|
+
export type Resync = typeof Resync.Type;
|
|
239
|
+
/**
|
|
240
|
+
* Requests an explicitly public projection covering the missing prefix.
|
|
241
|
+
* Identity and version must match exactly; this never requests raw engine state.
|
|
242
|
+
* @category models
|
|
243
|
+
* @since 1.0.0-rc.0
|
|
244
|
+
*/
|
|
245
|
+
export declare const SnapshotRequest: Schema.Struct<{
|
|
246
|
+
readonly atLeastSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
247
|
+
readonly capability: Schema.optional<typeof ShareCapability>;
|
|
248
|
+
readonly protocolVersion: Schema.Int;
|
|
249
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
250
|
+
readonly lineageId: Schema.NonEmptyString;
|
|
251
|
+
readonly projection: Schema.NonEmptyString;
|
|
252
|
+
readonly projectionVersion: Schema.Int;
|
|
253
|
+
}>;
|
|
254
|
+
/** A decoded request for an explicitly public projection.
|
|
255
|
+
* @category models
|
|
256
|
+
* @since 1.0.0-rc.0
|
|
257
|
+
*/
|
|
258
|
+
export type SnapshotRequest = typeof SnapshotRequest.Type;
|
|
259
|
+
/**
|
|
260
|
+
* A complete public projection through `seq`, inclusive. Apply its state and
|
|
261
|
+
* durable cursor atomically, then read entries strictly after `seq`.
|
|
262
|
+
* @category models
|
|
263
|
+
* @since 1.0.0-rc.0
|
|
264
|
+
*/
|
|
265
|
+
export declare const Snapshot: Schema.Struct<{
|
|
266
|
+
readonly seq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
267
|
+
readonly state: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
268
|
+
readonly protocolVersion: Schema.Int;
|
|
269
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
270
|
+
readonly lineageId: Schema.NonEmptyString;
|
|
271
|
+
readonly projection: Schema.NonEmptyString;
|
|
272
|
+
readonly projectionVersion: Schema.Int;
|
|
273
|
+
}>;
|
|
274
|
+
/** A complete, versioned public projection at one journal sequence.
|
|
275
|
+
* @category models
|
|
276
|
+
* @since 1.0.0-rc.0
|
|
277
|
+
*/
|
|
278
|
+
export type Snapshot = typeof Snapshot.Type;
|
|
279
|
+
/**
|
|
280
|
+
* Largest number of entries one {@link ReadRequest} may ask for.
|
|
281
|
+
*
|
|
282
|
+
* `limit` is request-controlled fan-out: the server passes it to the journal
|
|
283
|
+
* as the page size, once per covered run, so an unbounded limit made one
|
|
284
|
+
* workspace read materialize an unbounded number of rows per run. The frame
|
|
285
|
+
* ceiling does not cover it — that drops entries AFTER they have been read.
|
|
286
|
+
* A request above this bound is refused at the wire, and an in-process caller
|
|
287
|
+
* that bypasses the schema is clamped to it.
|
|
288
|
+
*
|
|
289
|
+
* @category limits
|
|
290
|
+
* @since 0.1.0
|
|
291
|
+
*/
|
|
292
|
+
export declare const maxReadLimit = 1024;
|
|
293
|
+
/**
|
|
294
|
+
* Largest number of frames one {@link SubscribeRequest} may hold open.
|
|
295
|
+
*
|
|
296
|
+
* Credit is a hard frame limit, so it is also how long one subscription may
|
|
297
|
+
* pin a server-side fan-out. The bound keeps that lifetime a function of the
|
|
298
|
+
* protocol rather than of what the caller asks for; a follower that wants
|
|
299
|
+
* more resubscribes from the cursors it has, which is what
|
|
300
|
+
* `SyncClient.defaultCredit` already does.
|
|
301
|
+
*
|
|
302
|
+
* @category limits
|
|
303
|
+
* @since 0.1.0
|
|
304
|
+
*/
|
|
305
|
+
export declare const maxSubscribeCredit = 4096;
|
|
306
|
+
/**
|
|
307
|
+
* A durable catch-up request.
|
|
308
|
+
*
|
|
309
|
+
* `capability` authorizes branch runs: a run whose id maps to a shared branch
|
|
310
|
+
* is only read when the capability verifies for that branch. Non-branch runs
|
|
311
|
+
* ignore it.
|
|
312
|
+
*
|
|
313
|
+
* `limit` is bounded on both sides: at least one entry, at most
|
|
314
|
+
* {@link maxReadLimit}.
|
|
315
|
+
*
|
|
316
|
+
* @category models
|
|
317
|
+
* @since 0.1.0
|
|
318
|
+
*/
|
|
319
|
+
export declare const ReadRequest: Schema.Struct<{
|
|
320
|
+
readonly protocolVersion: Schema.optional<Schema.Int>;
|
|
321
|
+
readonly scope: Schema.Union<readonly [Schema.TaggedStruct<"Workspace", {}>, Schema.TaggedStruct<"Run", {
|
|
322
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
323
|
+
}>]>;
|
|
324
|
+
readonly cursors: Schema.$Array<Schema.Struct<{
|
|
325
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
326
|
+
readonly afterSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
327
|
+
readonly generation: Schema.optional<Schema.Int>;
|
|
328
|
+
}>>;
|
|
329
|
+
readonly limit: Schema.Int;
|
|
330
|
+
readonly capability: Schema.optional<typeof ShareCapability>;
|
|
331
|
+
}>;
|
|
332
|
+
/**
|
|
333
|
+
* A durable catch-up request.
|
|
334
|
+
*
|
|
335
|
+
* @category models
|
|
336
|
+
* @since 0.1.0
|
|
337
|
+
*/
|
|
338
|
+
export type ReadRequest = typeof ReadRequest.Type;
|
|
339
|
+
/**
|
|
340
|
+
* One page of durable catch-up entries.
|
|
341
|
+
*
|
|
342
|
+
* `done` reports that the page reached the durable tail, which is the point at
|
|
343
|
+
* which a client may switch from paging to following.
|
|
344
|
+
*
|
|
345
|
+
* @category models
|
|
346
|
+
* @since 0.1.0
|
|
347
|
+
*/
|
|
348
|
+
export declare const ReadResponse: Schema.Struct<{
|
|
349
|
+
readonly entries: Schema.$Array<typeof JournalEvent.Entry>;
|
|
350
|
+
readonly cursors: Schema.$Array<Schema.Struct<{
|
|
351
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
352
|
+
readonly afterSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
353
|
+
readonly generation: Schema.optional<Schema.Int>;
|
|
354
|
+
}>>;
|
|
355
|
+
readonly done: Schema.Boolean;
|
|
356
|
+
}>;
|
|
357
|
+
/**
|
|
358
|
+
* One page of durable catch-up entries.
|
|
359
|
+
*
|
|
360
|
+
* @category models
|
|
361
|
+
* @since 0.1.0
|
|
362
|
+
*/
|
|
363
|
+
export type ReadResponse = typeof ReadResponse.Type;
|
|
364
|
+
/**
|
|
365
|
+
* One page of durable catch-up entries as a SERVER states it.
|
|
366
|
+
*
|
|
367
|
+
* Every cursor carries its generation. {@link SyncServer.Service} answers with
|
|
368
|
+
* this shape; {@link ReadResponse} is the lenient shape a client decodes an
|
|
369
|
+
* untrusted server's page into before refusing a missing generation.
|
|
370
|
+
*
|
|
371
|
+
* @category models
|
|
372
|
+
* @since 1.0.0-rc.0
|
|
373
|
+
*/
|
|
374
|
+
export declare const ServerReadResponse: Schema.Struct<{
|
|
375
|
+
readonly cursors: Schema.$Array<Schema.Struct<{
|
|
376
|
+
readonly generation: Schema.Int;
|
|
377
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
378
|
+
readonly afterSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
379
|
+
}>>;
|
|
380
|
+
readonly entries: Schema.$Array<typeof JournalEvent.Entry>;
|
|
381
|
+
readonly done: Schema.Boolean;
|
|
382
|
+
}>;
|
|
383
|
+
/**
|
|
384
|
+
* One page of durable catch-up entries as a server states it.
|
|
385
|
+
*
|
|
386
|
+
* @category models
|
|
387
|
+
* @since 1.0.0-rc.0
|
|
388
|
+
*/
|
|
389
|
+
export type ServerReadResponse = typeof ServerReadResponse.Type;
|
|
390
|
+
/**
|
|
391
|
+
* A request to follow committed entries.
|
|
392
|
+
*
|
|
393
|
+
* `capability` authorizes branch runs exactly as on {@link ReadRequest}.
|
|
394
|
+
*
|
|
395
|
+
* `credit` is bounded on both sides: at least one frame, at most
|
|
396
|
+
* {@link maxSubscribeCredit}. Zero is refused rather than served as an
|
|
397
|
+
* immediately-empty stream, because the two readings of it — "open a window
|
|
398
|
+
* of nothing" and "a caller computed its window wrong" — are
|
|
399
|
+
* indistinguishable on the wire, and the second one busy-loops a follow that
|
|
400
|
+
* replenishes by resubscribing.
|
|
401
|
+
*
|
|
402
|
+
* @category models
|
|
403
|
+
* @since 0.1.0
|
|
404
|
+
*/
|
|
405
|
+
export declare const SubscribeRequest: Schema.Struct<{
|
|
406
|
+
readonly protocolVersion: Schema.optional<Schema.Int>;
|
|
407
|
+
readonly scope: Schema.Union<readonly [Schema.TaggedStruct<"Workspace", {}>, Schema.TaggedStruct<"Run", {
|
|
408
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
409
|
+
}>]>;
|
|
410
|
+
readonly cursors: Schema.$Array<Schema.Struct<{
|
|
411
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
412
|
+
readonly afterSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
413
|
+
readonly generation: Schema.optional<Schema.Int>;
|
|
414
|
+
}>>;
|
|
415
|
+
readonly credit: Schema.Int;
|
|
416
|
+
readonly capability: Schema.optional<typeof ShareCapability>;
|
|
417
|
+
}>;
|
|
418
|
+
/**
|
|
419
|
+
* A request to follow committed entries.
|
|
420
|
+
*
|
|
421
|
+
* @category models
|
|
422
|
+
* @since 0.1.0
|
|
423
|
+
*/
|
|
424
|
+
export type SubscribeRequest = typeof SubscribeRequest.Type;
|
|
425
|
+
/**
|
|
426
|
+
* A contiguous batch of committed entries for one run.
|
|
427
|
+
*
|
|
428
|
+
* `fromSeq` and `toSeq` describe the interval the server covered, not the
|
|
429
|
+
* sequences actually carried: dropped admissions leave legitimate holes.
|
|
430
|
+
* `generation` identifies the history covering the interval and is mandatory
|
|
431
|
+
* on server responses, including zero. Clients refuse its omission before
|
|
432
|
+
* deduplicating by sequence. The optional schema permits a typed refusal.
|
|
433
|
+
*
|
|
434
|
+
* @category models
|
|
435
|
+
* @since 0.1.0
|
|
436
|
+
*/
|
|
437
|
+
export declare const EntriesFrame: Schema.TaggedStruct<"Entries", {
|
|
438
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
439
|
+
readonly generation: Schema.optional<Schema.Int>;
|
|
440
|
+
readonly fromSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
441
|
+
readonly toSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
442
|
+
readonly entries: Schema.$Array<typeof JournalEvent.Entry>;
|
|
443
|
+
}>;
|
|
444
|
+
/**
|
|
445
|
+
* A contiguous batch of committed entries for one run.
|
|
446
|
+
*
|
|
447
|
+
* @category models
|
|
448
|
+
* @since 0.1.0
|
|
449
|
+
*/
|
|
450
|
+
export type EntriesFrame = typeof EntriesFrame.Type;
|
|
451
|
+
/**
|
|
452
|
+
* A liveness frame reserved for a future revision, which no rc.0 server emits.
|
|
453
|
+
*
|
|
454
|
+
* No server in this package constructs one at rc.0, and a client must not wait
|
|
455
|
+
* for one: {@link SyncClient} tolerates the variant and ignores it, which is
|
|
456
|
+
* the whole of the contract today. It stays in the {@link Frame} union so
|
|
457
|
+
* adding the frame later is not a wire break, and so a third-party client
|
|
458
|
+
* written against this schema already ignores it.
|
|
459
|
+
*
|
|
460
|
+
* Keepalive is a transport concern at rc.0. Emitting a heartbeat here would
|
|
461
|
+
* spend the subscription's `credit`, which is a hard frame limit, so an idle
|
|
462
|
+
* follow would resubscribe on a timer instead of staying quiet.
|
|
463
|
+
*
|
|
464
|
+
* @category models
|
|
465
|
+
* @since 0.1.0
|
|
466
|
+
*/
|
|
467
|
+
export declare const HeartbeatFrame: Schema.TaggedStruct<"Heartbeat", {}>;
|
|
468
|
+
/**
|
|
469
|
+
* A terminal frame reporting that the server ended the subscription.
|
|
470
|
+
*
|
|
471
|
+
* @category models
|
|
472
|
+
* @since 0.1.0
|
|
473
|
+
*/
|
|
474
|
+
export declare const ClosedFrame: Schema.TaggedStruct<"Closed", {
|
|
475
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
476
|
+
}>;
|
|
477
|
+
/**
|
|
478
|
+
* Any frame a subscription may emit.
|
|
479
|
+
*
|
|
480
|
+
* @category models
|
|
481
|
+
* @since 0.1.0
|
|
482
|
+
*/
|
|
483
|
+
export declare const Frame: Schema.Union<readonly [Schema.TaggedStruct<"Entries", {
|
|
484
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
485
|
+
readonly generation: Schema.optional<Schema.Int>;
|
|
486
|
+
readonly fromSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
487
|
+
readonly toSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
488
|
+
readonly entries: Schema.$Array<typeof JournalEvent.Entry>;
|
|
489
|
+
}>, Schema.TaggedStruct<"Heartbeat", {}>, Schema.TaggedStruct<"Closed", {
|
|
490
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
491
|
+
}>]>;
|
|
492
|
+
/**
|
|
493
|
+
* Any frame a subscription may emit.
|
|
494
|
+
*
|
|
495
|
+
* @category models
|
|
496
|
+
* @since 0.1.0
|
|
497
|
+
*/
|
|
498
|
+
export type Frame = typeof Frame.Type;
|
|
499
|
+
/**
|
|
500
|
+
* A contiguous batch of committed entries as a SERVER states it.
|
|
501
|
+
*
|
|
502
|
+
* `generation` is required here: a server that covers an interval knows the
|
|
503
|
+
* history it read, so omitting it is a compile error rather than a run-time
|
|
504
|
+
* refusal. {@link EntriesFrame} is the lenient shape a client decodes an
|
|
505
|
+
* untrusted server's frame into.
|
|
506
|
+
*
|
|
507
|
+
* @category models
|
|
508
|
+
* @since 1.0.0-rc.0
|
|
509
|
+
*/
|
|
510
|
+
export declare const ServerEntriesFrame: Schema.TaggedStruct<"Entries", {
|
|
511
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
512
|
+
readonly generation: Schema.Int;
|
|
513
|
+
readonly fromSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
514
|
+
readonly toSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
515
|
+
readonly entries: Schema.$Array<typeof JournalEvent.Entry>;
|
|
516
|
+
}>;
|
|
517
|
+
/**
|
|
518
|
+
* A contiguous batch of committed entries as a server states it.
|
|
519
|
+
*
|
|
520
|
+
* @category models
|
|
521
|
+
* @since 1.0.0-rc.0
|
|
522
|
+
*/
|
|
523
|
+
export type ServerEntriesFrame = typeof ServerEntriesFrame.Type;
|
|
524
|
+
/**
|
|
525
|
+
* Any frame a subscription may emit, as a server states it.
|
|
526
|
+
*
|
|
527
|
+
* @category models
|
|
528
|
+
* @since 1.0.0-rc.0
|
|
529
|
+
*/
|
|
530
|
+
export declare const ServerFrame: Schema.Union<readonly [Schema.TaggedStruct<"Entries", {
|
|
531
|
+
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
532
|
+
readonly generation: Schema.Int;
|
|
533
|
+
readonly fromSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
534
|
+
readonly toSeq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
535
|
+
readonly entries: Schema.$Array<typeof JournalEvent.Entry>;
|
|
536
|
+
}>, Schema.TaggedStruct<"Heartbeat", {}>, Schema.TaggedStruct<"Closed", {
|
|
537
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
538
|
+
}>]>;
|
|
539
|
+
/**
|
|
540
|
+
* Any frame a subscription may emit, as a server states it.
|
|
541
|
+
*
|
|
542
|
+
* @category models
|
|
543
|
+
* @since 1.0.0-rc.0
|
|
544
|
+
*/
|
|
545
|
+
export type ServerFrame = typeof ServerFrame.Type;
|
|
546
|
+
/**
|
|
547
|
+
* Whether a scope covers a run.
|
|
548
|
+
*
|
|
549
|
+
* @category predicates
|
|
550
|
+
* @since 0.1.0
|
|
551
|
+
*/
|
|
552
|
+
export declare const covers: (scope: Scope, runId: JournalEvent.RunId) => boolean;
|
|
553
|
+
/**
|
|
554
|
+
* Default ceiling on the encoded entries one frame or page may
|
|
555
|
+
* carry, in bytes.
|
|
556
|
+
*
|
|
557
|
+
* Both ends enforce the sum of encoded journal entries, excluding the outer
|
|
558
|
+
* RPC/frame envelope. Transports must allow their own envelope overhead.
|
|
559
|
+
* Commands default to 1 MiB; the 2 MiB entry ceiling includes their durable
|
|
560
|
+
* journal envelope and keeps already-admitted maximum commands consumable.
|
|
561
|
+
*
|
|
562
|
+
* @category limits
|
|
563
|
+
* @since 0.1.0
|
|
564
|
+
*/
|
|
565
|
+
export declare const defaultMaxFrameBytes: number;
|
|
566
|
+
/**
|
|
567
|
+
* The wire size of one value: the UTF-8 byte length of its JSON text.
|
|
568
|
+
*
|
|
569
|
+
* Ceilings measure this encoded form rather than in-memory object size, so a
|
|
570
|
+
* limit tracks what a transport actually carries.
|
|
571
|
+
*
|
|
572
|
+
* The function is TOTAL, because every caller is a size guard whose whole job
|
|
573
|
+
* is to produce a typed `frame_too_large` refusal rather than a defect:
|
|
574
|
+
*
|
|
575
|
+
* - A value with no JSON text at all — `undefined`, a function, a symbol —
|
|
576
|
+
* measures {@link nullByteLength}, the bytes it occupies once an enclosing
|
|
577
|
+
* array or object encodes it as `null`. It used to measure zero, which let
|
|
578
|
+
* an unencodable value pass every ceiling.
|
|
579
|
+
* - A value `JSON.stringify` refuses — a cycle, a `bigint`, a throwing
|
|
580
|
+
* `toJSON` — measures `Infinity`, so it trips every ceiling instead of
|
|
581
|
+
* throwing a `TypeError` out of code that only ever fails typed.
|
|
582
|
+
*
|
|
583
|
+
* It measures the JSON text, so a `toJSON` method, a getter, or a proxy trap
|
|
584
|
+
* on the value runs while the size is taken; the read path measures each
|
|
585
|
+
* entry once per end. Entries that arrive over the wire are schema-decoded
|
|
586
|
+
* data and have none of those.
|
|
587
|
+
*
|
|
588
|
+
* @category limits
|
|
589
|
+
* @since 0.1.0
|
|
590
|
+
*/
|
|
591
|
+
export declare const encodedByteLength: (value: unknown) => number;
|
|
592
|
+
//# sourceMappingURL=SyncProtocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyncProtocol.d.ts","sourceRoot":"","sources":["../../src/SyncProtocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAA;AAC5D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD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