@smthrs/sync 0.0.0-stage → 1.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only journal synchronization services for flows.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.1.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @category errors
|
|
8
|
+
* @since 0.1.0
|
|
9
|
+
*/
|
|
10
|
+
export * as SyncError from "./SyncError.ts";
|
|
11
|
+
/**
|
|
12
|
+
* @category protocol
|
|
13
|
+
* @since 0.1.0
|
|
14
|
+
*/
|
|
15
|
+
export * as SyncProtocol from "./SyncProtocol.ts";
|
|
16
|
+
/**
|
|
17
|
+
* @category protocol
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
*/
|
|
20
|
+
export * as BranchProtocol from "./BranchProtocol.ts";
|
|
21
|
+
/**
|
|
22
|
+
* @category projections
|
|
23
|
+
* @since 0.1.0
|
|
24
|
+
*/
|
|
25
|
+
export * as BranchProjection from "./BranchProjection.ts";
|
|
26
|
+
/**
|
|
27
|
+
* @category rpc
|
|
28
|
+
* @since 0.1.0
|
|
29
|
+
*/
|
|
30
|
+
export * as SyncRpcs from "./SyncRpcs.ts";
|
|
31
|
+
/**
|
|
32
|
+
* @category rpc
|
|
33
|
+
* @since 0.1.0
|
|
34
|
+
*/
|
|
35
|
+
export * as BranchRpcs from "./BranchRpcs.ts";
|
|
36
|
+
/**
|
|
37
|
+
* @category services
|
|
38
|
+
* @since 0.1.0
|
|
39
|
+
*/
|
|
40
|
+
export * as RunCatalog from "./RunCatalog.ts";
|
|
41
|
+
/**
|
|
42
|
+
* @category services
|
|
43
|
+
* @since 0.1.0
|
|
44
|
+
*/
|
|
45
|
+
export * as SyncServer from "./SyncServer.ts";
|
|
46
|
+
/**
|
|
47
|
+
* @category services
|
|
48
|
+
* @since 0.1.0
|
|
49
|
+
*/
|
|
50
|
+
export * as SyncClient from "./SyncClient.ts";
|
|
51
|
+
/**
|
|
52
|
+
* @category services
|
|
53
|
+
* @since 0.1.0
|
|
54
|
+
*/
|
|
55
|
+
export * as BranchShare from "./BranchShare.ts";
|
|
56
|
+
/**
|
|
57
|
+
* @category services
|
|
58
|
+
* @since 0.1.0
|
|
59
|
+
*/
|
|
60
|
+
export * as WorkspaceShare from "./WorkspaceShare.ts";
|
|
61
|
+
/**
|
|
62
|
+
* @category services
|
|
63
|
+
* @since 0.1.0
|
|
64
|
+
*/
|
|
65
|
+
export * as SyncPrincipal from "./SyncPrincipal.ts";
|
|
66
|
+
/**
|
|
67
|
+
* @category rpc
|
|
68
|
+
* @since 0.1.0
|
|
69
|
+
*/
|
|
70
|
+
export * as SyncAuth from "./SyncAuth.ts";
|
|
71
|
+
/**
|
|
72
|
+
* @category services
|
|
73
|
+
* @since 0.1.0
|
|
74
|
+
*/
|
|
75
|
+
export * as BranchPresence from "./BranchPresence.ts";
|
|
76
|
+
/**
|
|
77
|
+
* @category services
|
|
78
|
+
* @since 0.1.0
|
|
79
|
+
*/
|
|
80
|
+
export * as BranchCommands from "./BranchCommands.ts";
|
|
81
|
+
/**
|
|
82
|
+
* @category services
|
|
83
|
+
* @since 0.1.0
|
|
84
|
+
*/
|
|
85
|
+
export * as BranchServer from "./BranchServer.ts";
|
|
86
|
+
/**
|
|
87
|
+
* @category services
|
|
88
|
+
* @since 0.1.0
|
|
89
|
+
*/
|
|
90
|
+
export * as BranchIds from "./BranchIds.ts";
|
|
91
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C;;;GAGG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;GAGG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;GAGG;AACH,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AAEzD;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAE/C;;;GAGG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;GAGG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;GAGG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;GAGG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;GAGG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;GAGG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only journal synchronization services for flows.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.1.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @category errors
|
|
8
|
+
* @since 0.1.0
|
|
9
|
+
*/
|
|
10
|
+
export * as SyncError from "./SyncError.js";
|
|
11
|
+
/**
|
|
12
|
+
* @category protocol
|
|
13
|
+
* @since 0.1.0
|
|
14
|
+
*/
|
|
15
|
+
export * as SyncProtocol from "./SyncProtocol.js";
|
|
16
|
+
/**
|
|
17
|
+
* @category protocol
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
*/
|
|
20
|
+
export * as BranchProtocol from "./BranchProtocol.js";
|
|
21
|
+
/**
|
|
22
|
+
* @category projections
|
|
23
|
+
* @since 0.1.0
|
|
24
|
+
*/
|
|
25
|
+
export * as BranchProjection from "./BranchProjection.js";
|
|
26
|
+
/**
|
|
27
|
+
* @category rpc
|
|
28
|
+
* @since 0.1.0
|
|
29
|
+
*/
|
|
30
|
+
export * as SyncRpcs from "./SyncRpcs.js";
|
|
31
|
+
/**
|
|
32
|
+
* @category rpc
|
|
33
|
+
* @since 0.1.0
|
|
34
|
+
*/
|
|
35
|
+
export * as BranchRpcs from "./BranchRpcs.js";
|
|
36
|
+
/**
|
|
37
|
+
* @category services
|
|
38
|
+
* @since 0.1.0
|
|
39
|
+
*/
|
|
40
|
+
export * as RunCatalog from "./RunCatalog.js";
|
|
41
|
+
/**
|
|
42
|
+
* @category services
|
|
43
|
+
* @since 0.1.0
|
|
44
|
+
*/
|
|
45
|
+
export * as SyncServer from "./SyncServer.js";
|
|
46
|
+
/**
|
|
47
|
+
* @category services
|
|
48
|
+
* @since 0.1.0
|
|
49
|
+
*/
|
|
50
|
+
export * as SyncClient from "./SyncClient.js";
|
|
51
|
+
/**
|
|
52
|
+
* @category services
|
|
53
|
+
* @since 0.1.0
|
|
54
|
+
*/
|
|
55
|
+
export * as BranchShare from "./BranchShare.js";
|
|
56
|
+
/**
|
|
57
|
+
* @category services
|
|
58
|
+
* @since 0.1.0
|
|
59
|
+
*/
|
|
60
|
+
export * as WorkspaceShare from "./WorkspaceShare.js";
|
|
61
|
+
/**
|
|
62
|
+
* @category services
|
|
63
|
+
* @since 0.1.0
|
|
64
|
+
*/
|
|
65
|
+
export * as SyncPrincipal from "./SyncPrincipal.js";
|
|
66
|
+
/**
|
|
67
|
+
* @category rpc
|
|
68
|
+
* @since 0.1.0
|
|
69
|
+
*/
|
|
70
|
+
export * as SyncAuth from "./SyncAuth.js";
|
|
71
|
+
/**
|
|
72
|
+
* @category services
|
|
73
|
+
* @since 0.1.0
|
|
74
|
+
*/
|
|
75
|
+
export * as BranchPresence from "./BranchPresence.js";
|
|
76
|
+
/**
|
|
77
|
+
* @category services
|
|
78
|
+
* @since 0.1.0
|
|
79
|
+
*/
|
|
80
|
+
export * as BranchCommands from "./BranchCommands.js";
|
|
81
|
+
/**
|
|
82
|
+
* @category services
|
|
83
|
+
* @since 0.1.0
|
|
84
|
+
*/
|
|
85
|
+
export * as BranchServer from "./BranchServer.js";
|
|
86
|
+
/**
|
|
87
|
+
* @category services
|
|
88
|
+
* @since 0.1.0
|
|
89
|
+
*/
|
|
90
|
+
export * as BranchIds from "./BranchIds.js";
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C;;;GAGG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;GAGG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;GAGG;AACH,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AAEzD;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAE/C;;;GAGG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;GAGG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;GAGG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;GAGG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;GAGG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;GAGG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA","sourcesContent":["/**\n * Read-only journal synchronization services for flows.\n *\n * @since 0.1.0\n */\n\n/**\n * @category errors\n * @since 0.1.0\n */\nexport * as SyncError from \"./SyncError.ts\"\n\n/**\n * @category protocol\n * @since 0.1.0\n */\nexport * as SyncProtocol from \"./SyncProtocol.ts\"\n\n/**\n * @category protocol\n * @since 0.1.0\n */\nexport * as BranchProtocol from \"./BranchProtocol.ts\"\n\n/**\n * @category projections\n * @since 0.1.0\n */\nexport * as BranchProjection from \"./BranchProjection.ts\"\n\n/**\n * @category rpc\n * @since 0.1.0\n */\nexport * as SyncRpcs from \"./SyncRpcs.ts\"\n\n/**\n * @category rpc\n * @since 0.1.0\n */\nexport * as BranchRpcs from \"./BranchRpcs.ts\"\n\n/**\n * @category services\n * @since 0.1.0\n */\nexport * as RunCatalog from \"./RunCatalog.ts\"\n\n/**\n * @category services\n * @since 0.1.0\n */\nexport * as SyncServer from \"./SyncServer.ts\"\n\n/**\n * @category services\n * @since 0.1.0\n */\nexport * as SyncClient from \"./SyncClient.ts\"\n\n/**\n * @category services\n * @since 0.1.0\n */\nexport * as BranchShare from \"./BranchShare.ts\"\n\n/**\n * @category services\n * @since 0.1.0\n */\nexport * as WorkspaceShare from \"./WorkspaceShare.ts\"\n\n/**\n * @category services\n * @since 0.1.0\n */\nexport * as SyncPrincipal from \"./SyncPrincipal.ts\"\n\n/**\n * @category rpc\n * @since 0.1.0\n */\nexport * as SyncAuth from \"./SyncAuth.ts\"\n\n/**\n * @category services\n * @since 0.1.0\n */\nexport * as BranchPresence from \"./BranchPresence.ts\"\n\n/**\n * @category services\n * @since 0.1.0\n */\nexport * as BranchCommands from \"./BranchCommands.ts\"\n\n/**\n * @category services\n * @since 0.1.0\n */\nexport * as BranchServer from \"./BranchServer.ts\"\n\n/**\n * @category services\n * @since 0.1.0\n */\nexport * as BranchIds from \"./BranchIds.ts\"\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Admission of host and transport values before any progress is committed.
|
|
2
|
+
* @since 1.0.0-rc.0
|
|
3
|
+
*/
|
|
4
|
+
import * as JournalEvent from "@smthrs/journal/JournalEvent";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import { CommandEventPayload } from "../BranchProtocol.ts";
|
|
8
|
+
import { SyncError } from "../SyncError.ts";
|
|
9
|
+
/** Decode a boundary value while retaining a safe cause classification.
|
|
10
|
+
* @category validation
|
|
11
|
+
* @since 1.0.0-rc.0
|
|
12
|
+
*/
|
|
13
|
+
export declare const decode: <S extends Schema.Top & {
|
|
14
|
+
readonly DecodingServices: never;
|
|
15
|
+
}>(schema: S, value: unknown, code?: "decode_failed" | "invalid_request") => Effect.Effect<S["Type"], SyncError>;
|
|
16
|
+
/** One admitted entry beside the command payload admission decoded from it.
|
|
17
|
+
* `command` is `undefined` for every event type other than `CommandEvent`.
|
|
18
|
+
* @category models
|
|
19
|
+
* @since 1.0.0-rc.0
|
|
20
|
+
*/
|
|
21
|
+
export interface Admitted {
|
|
22
|
+
readonly entry: JournalEvent.Entry;
|
|
23
|
+
readonly command: CommandEventPayload | undefined;
|
|
24
|
+
}
|
|
25
|
+
/** Known branch records fail closed; unknown namespaces remain open JSON envelopes.
|
|
26
|
+
* Defaults on persisted command args/target keep their existing additive schema meaning.
|
|
27
|
+
* @category validation
|
|
28
|
+
* @since 1.0.0-rc.0
|
|
29
|
+
*/
|
|
30
|
+
export declare const records: (values: ReadonlyArray<JournalEvent.Entry>) => Effect.Effect<ReadonlyArray<JournalEvent.Entry>, SyncError>;
|
|
31
|
+
/** Admit an entire run batch before its caller publishes or updates a cursor,
|
|
32
|
+
* handing back each command beside the payload admission decoded, so a caller
|
|
33
|
+
* that needs a command field reads it instead of decoding the payload again.
|
|
34
|
+
* @category validation
|
|
35
|
+
* @since 1.0.0-rc.0
|
|
36
|
+
*/
|
|
37
|
+
export declare const withCommands: (values: ReadonlyArray<JournalEvent.Entry>, runId: JournalEvent.RunId, after: number) => Effect.Effect<ReadonlyArray<Admitted>, SyncError>;
|
|
38
|
+
/** Admit an entire run batch before its caller publishes or updates a cursor.
|
|
39
|
+
* @category validation
|
|
40
|
+
* @since 1.0.0-rc.0
|
|
41
|
+
*/
|
|
42
|
+
export declare const entries: (values: ReadonlyArray<JournalEvent.Entry>, runId: JournalEvent.RunId, after: number) => Effect.Effect<ReadonlyArray<JournalEvent.Entry>, SyncError>;
|
|
43
|
+
//# sourceMappingURL=Admission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Admission.d.ts","sourceRoot":"","sources":["../../../src/internal/Admission.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAA;AAC5D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAyC,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AACjG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAG3C;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,MAAM,CAAC,GAAG,GAAG;IAAE,QAAQ,CAAC,gBAAgB,EAAE,KAAK,CAAA;CAAE,EAChF,QAAQ,CAAC,EACT,OAAO,OAAO,EACd,OAAM,eAAe,GAAG,iBAAmC,KAC1D,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,CAIjC,CAAA;AAOJ;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAA;IAClC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAA;CAClD;AAiCD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAClB,QAAQ,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,KACxC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,SAAS,CAAyC,CAAA;AAEtG;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,QAAQ,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,EACzC,OAAO,YAAY,CAAC,KAAK,EACzB,OAAO,MAAM,KACZ,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,SAAS,CAiB/C,CAAA;AAEJ;;;GAGG;AACH,eAAO,MAAM,OAAO,GAClB,QAAQ,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,EACzC,OAAO,YAAY,CAAC,KAAK,EACzB,OAAO,MAAM,KACZ,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,SAAS,CACF,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** Admission of host and transport values before any progress is committed.
|
|
2
|
+
* @since 1.0.0-rc.0
|
|
3
|
+
*/
|
|
4
|
+
import * as JournalEvent from "@smthrs/journal/JournalEvent";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import { BranchId, branchOfRunId, CommandEvent, CommandEventPayload } from "../BranchProtocol.js";
|
|
8
|
+
import { SyncError } from "../SyncError.js";
|
|
9
|
+
import { causeCode } from "./CauseText.js";
|
|
10
|
+
/** Decode a boundary value while retaining a safe cause classification.
|
|
11
|
+
* @category validation
|
|
12
|
+
* @since 1.0.0-rc.0
|
|
13
|
+
*/
|
|
14
|
+
export const decode = (schema, value, code = "decode_failed") => Effect.try({
|
|
15
|
+
try: () => Schema.decodeUnknownSync(schema)(value),
|
|
16
|
+
catch: (cause) => new SyncError({ code, message: "Invalid sync envelope", cause: causeCode(cause) })
|
|
17
|
+
});
|
|
18
|
+
const decodeEntries = Schema.decodeUnknownSync(Schema.Array(JournalEvent.Entry));
|
|
19
|
+
const decodeJson = Schema.decodeUnknownSync(Schema.Struct({ payload: Schema.Json, meta: Schema.Json }));
|
|
20
|
+
const decodeCommand = Schema.decodeUnknownSync(CommandEventPayload);
|
|
21
|
+
const decodeBranch = Schema.decodeUnknownSync(Schema.Struct({ branchId: Schema.optional(BranchId) }));
|
|
22
|
+
/** The one validation `records`, `withCommands`, and `entries` share. It keeps
|
|
23
|
+
* each command's decoded payload beside its entry rather than discarding it.
|
|
24
|
+
*/
|
|
25
|
+
const admit = (values) => Effect.try({
|
|
26
|
+
// Capture getters once and detach nested payloads before any application
|
|
27
|
+
// callback can mutate the producer's next entry after admission.
|
|
28
|
+
try: () => decodeEntries(structuredClone(values)).map((entry) => {
|
|
29
|
+
decodeJson(entry);
|
|
30
|
+
if (entry.eventType !== CommandEvent)
|
|
31
|
+
return { entry, command: undefined };
|
|
32
|
+
const command = decodeCommand(entry.payload);
|
|
33
|
+
const identity = decodeBranch(entry.payload);
|
|
34
|
+
if (identity.branchId !== undefined && identity.branchId !== branchOfRunId(entry.runId)) {
|
|
35
|
+
throw new SyncError({
|
|
36
|
+
code: "protocol_violation",
|
|
37
|
+
message: "Command belongs to another branch",
|
|
38
|
+
cause: "foreign_branch"
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return { entry, command };
|
|
42
|
+
}),
|
|
43
|
+
catch: (cause) => cause instanceof SyncError
|
|
44
|
+
? cause
|
|
45
|
+
: new SyncError({ code: "decode_failed", message: "Invalid sync record", cause: causeCode(cause) })
|
|
46
|
+
});
|
|
47
|
+
const entriesOf = (admitted) => admitted.map(({ entry }) => entry);
|
|
48
|
+
/** Known branch records fail closed; unknown namespaces remain open JSON envelopes.
|
|
49
|
+
* Defaults on persisted command args/target keep their existing additive schema meaning.
|
|
50
|
+
* @category validation
|
|
51
|
+
* @since 1.0.0-rc.0
|
|
52
|
+
*/
|
|
53
|
+
export const records = (values) => Effect.map(admit(values), entriesOf);
|
|
54
|
+
/** Admit an entire run batch before its caller publishes or updates a cursor,
|
|
55
|
+
* handing back each command beside the payload admission decoded, so a caller
|
|
56
|
+
* that needs a command field reads it instead of decoding the payload again.
|
|
57
|
+
* @category validation
|
|
58
|
+
* @since 1.0.0-rc.0
|
|
59
|
+
*/
|
|
60
|
+
export const withCommands = (values, runId, after) => Effect.gen(function* () {
|
|
61
|
+
const admitted = yield* admit(values);
|
|
62
|
+
let previous = after;
|
|
63
|
+
for (const { entry } of admitted) {
|
|
64
|
+
if (entry.runId !== runId || entry.seq <= previous) {
|
|
65
|
+
return yield* Effect.fail(new SyncError({
|
|
66
|
+
code: "protocol_violation",
|
|
67
|
+
message: "Journal batch must belong to the requested run and ascend strictly above its cursor",
|
|
68
|
+
cause: entry.runId !== runId ? "foreign_run" : "non_monotonic_sequence"
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
previous = entry.seq;
|
|
72
|
+
}
|
|
73
|
+
return admitted;
|
|
74
|
+
});
|
|
75
|
+
/** Admit an entire run batch before its caller publishes or updates a cursor.
|
|
76
|
+
* @category validation
|
|
77
|
+
* @since 1.0.0-rc.0
|
|
78
|
+
*/
|
|
79
|
+
export const entries = (values, runId, after) => Effect.map(withCommands(values, runId, after), entriesOf);
|
|
80
|
+
//# sourceMappingURL=Admission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Admission.js","sourceRoot":"","sources":["../../../src/internal/Admission.ts"],"names":[],"mappings":"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","sourcesContent":["/** Admission of host and transport values before any progress is committed.\n * @since 1.0.0-rc.0\n */\n\nimport * as JournalEvent from \"@smthrs/journal/JournalEvent\"\nimport * as Effect from \"effect/Effect\"\nimport * as Schema from \"effect/Schema\"\nimport { BranchId, branchOfRunId, CommandEvent, CommandEventPayload } from \"../BranchProtocol.ts\"\nimport { SyncError } from \"../SyncError.ts\"\nimport { causeCode } from \"./CauseText.ts\"\n\n/** Decode a boundary value while retaining a safe cause classification.\n * @category validation\n * @since 1.0.0-rc.0\n */\nexport const decode = <S extends Schema.Top & { readonly DecodingServices: never }>(\n schema: S,\n value: unknown,\n code: \"decode_failed\" | \"invalid_request\" = \"decode_failed\"\n): Effect.Effect<S[\"Type\"], SyncError> =>\n Effect.try({\n try: () => Schema.decodeUnknownSync(schema)(value),\n catch: (cause) => new SyncError({ code, message: \"Invalid sync envelope\", cause: causeCode(cause) })\n })\n\nconst decodeEntries = Schema.decodeUnknownSync(Schema.Array(JournalEvent.Entry))\nconst decodeJson = Schema.decodeUnknownSync(Schema.Struct({ payload: Schema.Json, meta: Schema.Json }))\nconst decodeCommand = Schema.decodeUnknownSync(CommandEventPayload)\nconst decodeBranch = Schema.decodeUnknownSync(Schema.Struct({ branchId: Schema.optional(BranchId) }))\n\n/** One admitted entry beside the command payload admission decoded from it.\n * `command` is `undefined` for every event type other than `CommandEvent`.\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Admitted {\n readonly entry: JournalEvent.Entry\n readonly command: CommandEventPayload | undefined\n}\n\n/** The one validation `records`, `withCommands`, and `entries` share. It keeps\n * each command's decoded payload beside its entry rather than discarding it.\n */\nconst admit = (values: ReadonlyArray<JournalEvent.Entry>): Effect.Effect<ReadonlyArray<Admitted>, SyncError> =>\n Effect.try({\n // Capture getters once and detach nested payloads before any application\n // callback can mutate the producer's next entry after admission.\n try: () =>\n decodeEntries(structuredClone(values)).map((entry): Admitted => {\n decodeJson(entry)\n if (entry.eventType !== CommandEvent) return { entry, command: undefined }\n const command = decodeCommand(entry.payload)\n const identity = decodeBranch(entry.payload)\n if (identity.branchId !== undefined && identity.branchId !== branchOfRunId(entry.runId)) {\n throw new SyncError({\n code: \"protocol_violation\",\n message: \"Command belongs to another branch\",\n cause: \"foreign_branch\"\n })\n }\n return { entry, command }\n }),\n catch: (cause) =>\n cause instanceof SyncError\n ? cause\n : new SyncError({ code: \"decode_failed\", message: \"Invalid sync record\", cause: causeCode(cause) })\n })\n\nconst entriesOf = (admitted: ReadonlyArray<Admitted>): ReadonlyArray<JournalEvent.Entry> =>\n admitted.map(({ entry }) => entry)\n\n/** Known branch records fail closed; unknown namespaces remain open JSON envelopes.\n * Defaults on persisted command args/target keep their existing additive schema meaning.\n * @category validation\n * @since 1.0.0-rc.0\n */\nexport const records = (\n values: ReadonlyArray<JournalEvent.Entry>\n): Effect.Effect<ReadonlyArray<JournalEvent.Entry>, SyncError> => Effect.map(admit(values), entriesOf)\n\n/** Admit an entire run batch before its caller publishes or updates a cursor,\n * handing back each command beside the payload admission decoded, so a caller\n * that needs a command field reads it instead of decoding the payload again.\n * @category validation\n * @since 1.0.0-rc.0\n */\nexport const withCommands = (\n values: ReadonlyArray<JournalEvent.Entry>,\n runId: JournalEvent.RunId,\n after: number\n): Effect.Effect<ReadonlyArray<Admitted>, SyncError> =>\n Effect.gen(function*() {\n const admitted = yield* admit(values)\n let previous = after\n for (const { entry } of admitted) {\n if (entry.runId !== runId || entry.seq <= previous) {\n return yield* Effect.fail(\n new SyncError({\n code: \"protocol_violation\",\n message: \"Journal batch must belong to the requested run and ascend strictly above its cursor\",\n cause: entry.runId !== runId ? \"foreign_run\" : \"non_monotonic_sequence\"\n })\n )\n }\n previous = entry.seq\n }\n return admitted\n })\n\n/** Admit an entire run batch before its caller publishes or updates a cursor.\n * @category validation\n * @since 1.0.0-rc.0\n */\nexport const entries = (\n values: ReadonlyArray<JournalEvent.Entry>,\n runId: JournalEvent.RunId,\n after: number\n): Effect.Effect<ReadonlyArray<JournalEvent.Entry>, SyncError> =>\n Effect.map(withCommands(values, runId, after), entriesOf)\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a host failure crosses the sync boundary: what a follower is told about
|
|
3
|
+
* it, and what it is not.
|
|
4
|
+
*
|
|
5
|
+
* `SyncError.cause` crosses the wire to a follower that may hold nothing but a
|
|
6
|
+
* branch share link, so it carries a short string rather than the host object
|
|
7
|
+
* that failed. An arbitrary `unknown` had three problems at once: it counted
|
|
8
|
+
* against no ceiling, a class instance or a cyclic value has no defined wire
|
|
9
|
+
* form, and whatever the host threw — a driver message with SQL text, a
|
|
10
|
+
* rejected credential — went out verbatim.
|
|
11
|
+
*
|
|
12
|
+
* @since 1.0.0-rc.0
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Clamps one rendering to {@link maxCauseTextLength}.
|
|
16
|
+
*
|
|
17
|
+
* Every string this module produces leaves through here, and so does every
|
|
18
|
+
* other string a `SyncError` carries out of a host failure: `message` is
|
|
19
|
+
* `Schema.String` and is as unbounded as `cause` was.
|
|
20
|
+
*
|
|
21
|
+
* @category encoding
|
|
22
|
+
* @since 1.0.0-rc.0
|
|
23
|
+
*/
|
|
24
|
+
export declare const boundedText: (text: string) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Renders one host failure as a bounded string.
|
|
27
|
+
*
|
|
28
|
+
* An `Error` renders as `name: message`; anything else renders as its type
|
|
29
|
+
* alone, because a non-`Error` value is arbitrary host data and its contents
|
|
30
|
+
* are not this boundary's to publish. Nothing is retained beyond the returned
|
|
31
|
+
* string, so an oversized input does not keep its subject alive.
|
|
32
|
+
*
|
|
33
|
+
* @category encoding
|
|
34
|
+
* @since 1.0.0-rc.0
|
|
35
|
+
*/
|
|
36
|
+
export declare const causeText: (cause: unknown) => string;
|
|
37
|
+
/**
|
|
38
|
+
* Renders one failure as its TYPE alone, with no message.
|
|
39
|
+
*
|
|
40
|
+
* The journal's message is the SQLite driver's, and it routinely carries SQL
|
|
41
|
+
* text, table and column names, and constraint identifiers. A follower may
|
|
42
|
+
* hold nothing but a branch share link, so what it learns about a storage
|
|
43
|
+
* fault is the stable code the journal enumerates, never the sentence the
|
|
44
|
+
* driver wrote. `decodeCapability` already refuses to be a parsing oracle;
|
|
45
|
+
* this is the same rule for the read and write paths.
|
|
46
|
+
*
|
|
47
|
+
* The result is bounded like {@link causeText}: a `Journal` is a host seam, so
|
|
48
|
+
* the `name` and `code` this reads are as much the host's to choose as the
|
|
49
|
+
* message it refuses to publish.
|
|
50
|
+
*
|
|
51
|
+
* @category encoding
|
|
52
|
+
* @since 1.0.0-rc.0
|
|
53
|
+
*/
|
|
54
|
+
export declare const causeCode: (cause: unknown) => string;
|
|
55
|
+
//# sourceMappingURL=CauseText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CauseText.d.ts","sourceRoot":"","sources":["../../../src/internal/CauseText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,MACoD,CAAA;AAE/F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,MAGxC,CAAA;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,MAM1C,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a host failure crosses the sync boundary: what a follower is told about
|
|
3
|
+
* it, and what it is not.
|
|
4
|
+
*
|
|
5
|
+
* `SyncError.cause` crosses the wire to a follower that may hold nothing but a
|
|
6
|
+
* branch share link, so it carries a short string rather than the host object
|
|
7
|
+
* that failed. An arbitrary `unknown` had three problems at once: it counted
|
|
8
|
+
* against no ceiling, a class instance or a cyclic value has no defined wire
|
|
9
|
+
* form, and whatever the host threw — a driver message with SQL text, a
|
|
10
|
+
* rejected credential — went out verbatim.
|
|
11
|
+
*
|
|
12
|
+
* @since 1.0.0-rc.0
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Longest cause rendering that crosses the wire. Long enough to name a failure
|
|
16
|
+
* and short enough that an error can never be the largest thing a follower
|
|
17
|
+
* receives.
|
|
18
|
+
*/
|
|
19
|
+
const maxCauseTextLength = 512;
|
|
20
|
+
/**
|
|
21
|
+
* Clamps one rendering to {@link maxCauseTextLength}.
|
|
22
|
+
*
|
|
23
|
+
* Every string this module produces leaves through here, and so does every
|
|
24
|
+
* other string a `SyncError` carries out of a host failure: `message` is
|
|
25
|
+
* `Schema.String` and is as unbounded as `cause` was.
|
|
26
|
+
*
|
|
27
|
+
* @category encoding
|
|
28
|
+
* @since 1.0.0-rc.0
|
|
29
|
+
*/
|
|
30
|
+
export const boundedText = (text) => text.length <= maxCauseTextLength ? text : `${text.slice(0, maxCauseTextLength)} (truncated)`;
|
|
31
|
+
/**
|
|
32
|
+
* Renders one host failure as a bounded string.
|
|
33
|
+
*
|
|
34
|
+
* An `Error` renders as `name: message`; anything else renders as its type
|
|
35
|
+
* alone, because a non-`Error` value is arbitrary host data and its contents
|
|
36
|
+
* are not this boundary's to publish. Nothing is retained beyond the returned
|
|
37
|
+
* string, so an oversized input does not keep its subject alive.
|
|
38
|
+
*
|
|
39
|
+
* @category encoding
|
|
40
|
+
* @since 1.0.0-rc.0
|
|
41
|
+
*/
|
|
42
|
+
export const causeText = (cause) => boundedText(cause instanceof Error ? `${cause.name}: ${cause.message}` : Object.prototype.toString.call(cause));
|
|
43
|
+
/**
|
|
44
|
+
* Renders one failure as its TYPE alone, with no message.
|
|
45
|
+
*
|
|
46
|
+
* The journal's message is the SQLite driver's, and it routinely carries SQL
|
|
47
|
+
* text, table and column names, and constraint identifiers. A follower may
|
|
48
|
+
* hold nothing but a branch share link, so what it learns about a storage
|
|
49
|
+
* fault is the stable code the journal enumerates, never the sentence the
|
|
50
|
+
* driver wrote. `decodeCapability` already refuses to be a parsing oracle;
|
|
51
|
+
* this is the same rule for the read and write paths.
|
|
52
|
+
*
|
|
53
|
+
* The result is bounded like {@link causeText}: a `Journal` is a host seam, so
|
|
54
|
+
* the `name` and `code` this reads are as much the host's to choose as the
|
|
55
|
+
* message it refuses to publish.
|
|
56
|
+
*
|
|
57
|
+
* @category encoding
|
|
58
|
+
* @since 1.0.0-rc.0
|
|
59
|
+
*/
|
|
60
|
+
export const causeCode = (cause) => {
|
|
61
|
+
if (cause instanceof Error) {
|
|
62
|
+
const code = cause.code;
|
|
63
|
+
return boundedText(typeof code === "string" ? `${cause.name}(${code})` : cause.name);
|
|
64
|
+
}
|
|
65
|
+
return boundedText(Object.prototype.toString.call(cause));
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=CauseText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CauseText.js","sourceRoot":"","sources":["../../../src/internal/CauseText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,GAAG,CAAA;AAE9B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE,CAClD,IAAI,CAAC,MAAM,IAAI,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAA;AAE/F;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAU,EAAE,CAClD,WAAW,CACT,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CACnG,CAAA;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAU,EAAE;IAClD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAI,KAAqC,CAAC,IAAI,CAAA;QACxD,OAAO,WAAW,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACtF,CAAC;IACD,OAAO,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;AAC3D,CAAC,CAAA","sourcesContent":["/**\n * How a host failure crosses the sync boundary: what a follower is told about\n * it, and what it is not.\n *\n * `SyncError.cause` crosses the wire to a follower that may hold nothing but a\n * branch share link, so it carries a short string rather than the host object\n * that failed. An arbitrary `unknown` had three problems at once: it counted\n * against no ceiling, a class instance or a cyclic value has no defined wire\n * form, and whatever the host threw — a driver message with SQL text, a\n * rejected credential — went out verbatim.\n *\n * @since 1.0.0-rc.0\n */\n\n/**\n * Longest cause rendering that crosses the wire. Long enough to name a failure\n * and short enough that an error can never be the largest thing a follower\n * receives.\n */\nconst maxCauseTextLength = 512\n\n/**\n * Clamps one rendering to {@link maxCauseTextLength}.\n *\n * Every string this module produces leaves through here, and so does every\n * other string a `SyncError` carries out of a host failure: `message` is\n * `Schema.String` and is as unbounded as `cause` was.\n *\n * @category encoding\n * @since 1.0.0-rc.0\n */\nexport const boundedText = (text: string): string =>\n text.length <= maxCauseTextLength ? text : `${text.slice(0, maxCauseTextLength)} (truncated)`\n\n/**\n * Renders one host failure as a bounded string.\n *\n * An `Error` renders as `name: message`; anything else renders as its type\n * alone, because a non-`Error` value is arbitrary host data and its contents\n * are not this boundary's to publish. Nothing is retained beyond the returned\n * string, so an oversized input does not keep its subject alive.\n *\n * @category encoding\n * @since 1.0.0-rc.0\n */\nexport const causeText = (cause: unknown): string =>\n boundedText(\n cause instanceof Error ? `${cause.name}: ${cause.message}` : Object.prototype.toString.call(cause)\n )\n\n/**\n * Renders one failure as its TYPE alone, with no message.\n *\n * The journal's message is the SQLite driver's, and it routinely carries SQL\n * text, table and column names, and constraint identifiers. A follower may\n * hold nothing but a branch share link, so what it learns about a storage\n * fault is the stable code the journal enumerates, never the sentence the\n * driver wrote. `decodeCapability` already refuses to be a parsing oracle;\n * this is the same rule for the read and write paths.\n *\n * The result is bounded like {@link causeText}: a `Journal` is a host seam, so\n * the `name` and `code` this reads are as much the host's to choose as the\n * message it refuses to publish.\n *\n * @category encoding\n * @since 1.0.0-rc.0\n */\nexport const causeCode = (cause: unknown): string => {\n if (cause instanceof Error) {\n const code = (cause as { readonly code?: unknown }).code\n return boundedText(typeof code === \"string\" ? `${cause.name}(${code})` : cause.name)\n }\n return boundedText(Object.prototype.toString.call(cause))\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a journal failure's stable code maps onto the sync boundary's error
|
|
3
|
+
* vocabulary.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0-rc.0
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Projects one journal failure's stable code onto this boundary's vocabulary,
|
|
9
|
+
* or `unknown` when it has no counterpart.
|
|
10
|
+
*
|
|
11
|
+
* `SyncError.ErrorCode` already declares `closed`, `backpressure`, and
|
|
12
|
+
* `decode_failed`, so collapsing every journal failure but `compacted` into
|
|
13
|
+
* `unknown` threw away a classification the wire could already carry, and left
|
|
14
|
+
* a follower unable to tell a shut-down journal from an unexplained fault.
|
|
15
|
+
* Nothing here widens what a follower learns: `causeCode` already publishes
|
|
16
|
+
* the journal's own enumerated code, and the journal's MESSAGE stays refused
|
|
17
|
+
* on every path.
|
|
18
|
+
*
|
|
19
|
+
* @category encoding
|
|
20
|
+
* @since 1.0.0-rc.0
|
|
21
|
+
*/
|
|
22
|
+
export declare const journalErrorCode: (cause: unknown) => "backpressure" | "closed" | "decode_failed" | "unknown";
|
|
23
|
+
//# sourceMappingURL=JournalErrorCode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JournalErrorCode.d.ts","sourceRoot":"","sources":["../../../src/internal/JournalErrorCode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,GAC3B,OAAO,OAAO,KACb,cAAc,GAAG,QAAQ,GAAG,eAAe,GAAG,SAIhD,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a journal failure's stable code maps onto the sync boundary's error
|
|
3
|
+
* vocabulary.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0-rc.0
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The journal codes this boundary can state in its own vocabulary.
|
|
9
|
+
*
|
|
10
|
+
* Only codes whose meaning is identical on both sides are here. A journal that
|
|
11
|
+
* is shut down and a sync boundary that is closed are the same fact; an
|
|
12
|
+
* admission queue that overflowed and backpressure are the same fact; a
|
|
13
|
+
* payload the journal could not decode and one this boundary could not decode
|
|
14
|
+
* are the same fact. Everything else — a fence lost, a sequence conflict, a
|
|
15
|
+
* projection fault — is a storage-layer distinction a follower cannot act on,
|
|
16
|
+
* and inventing a sync code for it would say more than is known.
|
|
17
|
+
*/
|
|
18
|
+
const journalCodes = {
|
|
19
|
+
decode_failed: "decode_failed",
|
|
20
|
+
journal_closed: "closed",
|
|
21
|
+
queue_overflow: "backpressure"
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Projects one journal failure's stable code onto this boundary's vocabulary,
|
|
25
|
+
* or `unknown` when it has no counterpart.
|
|
26
|
+
*
|
|
27
|
+
* `SyncError.ErrorCode` already declares `closed`, `backpressure`, and
|
|
28
|
+
* `decode_failed`, so collapsing every journal failure but `compacted` into
|
|
29
|
+
* `unknown` threw away a classification the wire could already carry, and left
|
|
30
|
+
* a follower unable to tell a shut-down journal from an unexplained fault.
|
|
31
|
+
* Nothing here widens what a follower learns: `causeCode` already publishes
|
|
32
|
+
* the journal's own enumerated code, and the journal's MESSAGE stays refused
|
|
33
|
+
* on every path.
|
|
34
|
+
*
|
|
35
|
+
* @category encoding
|
|
36
|
+
* @since 1.0.0-rc.0
|
|
37
|
+
*/
|
|
38
|
+
export const journalErrorCode = (cause) => {
|
|
39
|
+
if (!(cause instanceof Error))
|
|
40
|
+
return "unknown";
|
|
41
|
+
const code = cause.code;
|
|
42
|
+
return typeof code === "string" ? journalCodes[code] ?? "unknown" : "unknown";
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=JournalErrorCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JournalErrorCode.js","sourceRoot":"","sources":["../../../src/internal/JournalErrorCode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,YAAY,GAA0E;IAC1F,aAAa,EAAE,eAAe;IAC9B,cAAc,EAAE,QAAQ;IACxB,cAAc,EAAE,cAAc;CAC/B,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,KAAc,EAC2C,EAAE;IAC3D,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAC/C,MAAM,IAAI,GAAI,KAAqC,CAAC,IAAI,CAAA;IACxD,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAA;AAC/E,CAAC,CAAA","sourcesContent":["/**\n * How a journal failure's stable code maps onto the sync boundary's error\n * vocabulary.\n *\n * @since 1.0.0-rc.0\n */\n\n/**\n * The journal codes this boundary can state in its own vocabulary.\n *\n * Only codes whose meaning is identical on both sides are here. A journal that\n * is shut down and a sync boundary that is closed are the same fact; an\n * admission queue that overflowed and backpressure are the same fact; a\n * payload the journal could not decode and one this boundary could not decode\n * are the same fact. Everything else — a fence lost, a sequence conflict, a\n * projection fault — is a storage-layer distinction a follower cannot act on,\n * and inventing a sync code for it would say more than is known.\n */\nconst journalCodes: Readonly<Record<string, \"backpressure\" | \"closed\" | \"decode_failed\">> = {\n decode_failed: \"decode_failed\",\n journal_closed: \"closed\",\n queue_overflow: \"backpressure\"\n}\n\n/**\n * Projects one journal failure's stable code onto this boundary's vocabulary,\n * or `unknown` when it has no counterpart.\n *\n * `SyncError.ErrorCode` already declares `closed`, `backpressure`, and\n * `decode_failed`, so collapsing every journal failure but `compacted` into\n * `unknown` threw away a classification the wire could already carry, and left\n * a follower unable to tell a shut-down journal from an unexplained fault.\n * Nothing here widens what a follower learns: `causeCode` already publishes\n * the journal's own enumerated code, and the journal's MESSAGE stays refused\n * on every path.\n *\n * @category encoding\n * @since 1.0.0-rc.0\n */\nexport const journalErrorCode = (\n cause: unknown\n): \"backpressure\" | \"closed\" | \"decode_failed\" | \"unknown\" => {\n if (!(cause instanceof Error)) return \"unknown\"\n const code = (cause as { readonly code?: unknown }).code\n return typeof code === \"string\" ? journalCodes[code] ?? \"unknown\" : \"unknown\"\n}\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution-time validation of the numeric policies this package's
|
|
3
|
+
* constructors accept.
|
|
4
|
+
*
|
|
5
|
+
* Every `Options` field is typed `number`, and TypeScript admits `NaN`,
|
|
6
|
+
* `Infinity`, zero, and a negative under that type. Each of them disables the
|
|
7
|
+
* thing it configures rather than tightening it: `maxFrameBytes: NaN` makes
|
|
8
|
+
* every `bytes > maxFrameBytes` comparison false, so the ceiling silently
|
|
9
|
+
* stops existing; `concurrency: 0` reaches a bounded `Stream.flatMap`
|
|
10
|
+
* unchecked. A policy is checked once, where it enters, and a bad one is a
|
|
11
|
+
* typed refusal rather than a bound that quietly does nothing.
|
|
12
|
+
*
|
|
13
|
+
* @since 1.0.0-rc.0
|
|
14
|
+
*/
|
|
15
|
+
import * as Effect from "effect/Effect";
|
|
16
|
+
import { SyncError } from "../SyncError.ts";
|
|
17
|
+
/**
|
|
18
|
+
* The caller's value when it is a positive safe integer, the fallback when the
|
|
19
|
+
* caller supplied none, and a typed `invalid_request` refusal otherwise. The
|
|
20
|
+
* message names the option so the offending field is identifiable without the
|
|
21
|
+
* error carrying anything but the scalar it was given.
|
|
22
|
+
*
|
|
23
|
+
* @category validation
|
|
24
|
+
* @since 1.0.0-rc.0
|
|
25
|
+
*/
|
|
26
|
+
export declare const positiveInt: (name: string, value: number | undefined, fallback: number) => Effect.Effect<number, SyncError>;
|
|
27
|
+
/**
|
|
28
|
+
* A count carried by a REQUEST rather than by a policy: floored at one,
|
|
29
|
+
* ceilinged at what the wire schema allows, and refused otherwise.
|
|
30
|
+
*
|
|
31
|
+
* `SyncProtocol` already bounds `limit` and `credit` on both sides, so a
|
|
32
|
+
* decoded request cannot carry a bad one. An in-process caller that builds the
|
|
33
|
+
* request value directly never meets that schema, and the TypeScript type it
|
|
34
|
+
* does meet is `number`: `NaN`, zero, and a negative all satisfy it. Each of
|
|
35
|
+
* them disables the bound instead of tightening it — `Math.min(NaN, ceiling)`
|
|
36
|
+
* is `NaN`, every `length >= NaN` comparison answers false, and the value
|
|
37
|
+
* reaches the journal as a page size — so the floor is checked here, where
|
|
38
|
+
* both callers share one refusal and one sentence.
|
|
39
|
+
*
|
|
40
|
+
* @category validation
|
|
41
|
+
* @since 1.0.0-rc.0
|
|
42
|
+
*/
|
|
43
|
+
export declare const requestCount: (name: string, value: number, ceiling: number) => Effect.Effect<number, SyncError>;
|
|
44
|
+
/**
|
|
45
|
+
* {@link positiveInt} plus a ceiling, for a policy the WIRE also bounds.
|
|
46
|
+
*
|
|
47
|
+
* A value the local schema would accept and the wire schema would refuse is
|
|
48
|
+
* not a transport failure, but that is what it looked like: the RPC client's
|
|
49
|
+
* own decode failure arrived through the same channel a dropped connection
|
|
50
|
+
* does, and the follow retried it under backoff forever. The refusal belongs
|
|
51
|
+
* here, before a request is built.
|
|
52
|
+
*
|
|
53
|
+
* @category validation
|
|
54
|
+
* @since 1.0.0-rc.0
|
|
55
|
+
*/
|
|
56
|
+
export declare const boundedInt: (name: string, value: number | undefined, fallback: number, maximum: number) => Effect.Effect<number, SyncError>;
|
|
57
|
+
//# sourceMappingURL=PolicyOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PolicyOptions.d.ts","sourceRoot":"","sources":["../../../src/internal/PolicyOptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,EACZ,OAAO,MAAM,GAAG,SAAS,EACzB,UAAU,MAAM,KACf,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAQjC,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,OAAO,MAAM,EACb,SAAS,MAAM,KACd,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAM/B,CAAA;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,OAAO,MAAM,GAAG,SAAS,EACzB,UAAU,MAAM,EAChB,SAAS,MAAM,KACd,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAU/B,CAAA"}
|