@livestore/sync-cf 0.4.0 → 0.5.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/.tsbuildinfo +1 -1
- package/dist/cf-worker/do/durable-object.d.ts.map +1 -1
- package/dist/cf-worker/do/durable-object.js +53 -36
- package/dist/cf-worker/do/durable-object.js.map +1 -1
- package/dist/cf-worker/do/layer.d.ts +22 -18
- package/dist/cf-worker/do/layer.d.ts.map +1 -1
- package/dist/cf-worker/do/layer.js +45 -35
- package/dist/cf-worker/do/layer.js.map +1 -1
- package/dist/cf-worker/do/observability.d.ts +23 -0
- package/dist/cf-worker/do/observability.d.ts.map +1 -0
- package/dist/cf-worker/do/observability.js +52 -0
- package/dist/cf-worker/do/observability.js.map +1 -0
- package/dist/cf-worker/do/observability.test.d.ts +2 -0
- package/dist/cf-worker/do/observability.test.d.ts.map +1 -0
- package/dist/cf-worker/do/observability.test.js +204 -0
- package/dist/cf-worker/do/observability.test.js.map +1 -0
- package/dist/cf-worker/do/pull.d.ts +3 -3
- package/dist/cf-worker/do/pull.d.ts.map +1 -1
- package/dist/cf-worker/do/pull.js +19 -20
- package/dist/cf-worker/do/pull.js.map +1 -1
- package/dist/cf-worker/do/push.d.ts +16 -3
- package/dist/cf-worker/do/push.d.ts.map +1 -1
- package/dist/cf-worker/do/push.js +74 -53
- package/dist/cf-worker/do/push.js.map +1 -1
- package/dist/cf-worker/do/push.test.d.ts +2 -0
- package/dist/cf-worker/do/push.test.d.ts.map +1 -0
- package/dist/cf-worker/do/push.test.js +30 -0
- package/dist/cf-worker/do/push.test.js.map +1 -0
- package/dist/cf-worker/do/sqlite.d.ts +34 -46
- package/dist/cf-worker/do/sqlite.d.ts.map +1 -1
- package/dist/cf-worker/do/sqlite.js +2 -2
- package/dist/cf-worker/do/sqlite.js.map +1 -1
- package/dist/cf-worker/do/sync-storage.d.ts +7 -6
- package/dist/cf-worker/do/sync-storage.d.ts.map +1 -1
- package/dist/cf-worker/do/sync-storage.js +29 -17
- package/dist/cf-worker/do/sync-storage.js.map +1 -1
- package/dist/cf-worker/do/transport/do-rpc-server.d.ts +17 -2
- package/dist/cf-worker/do/transport/do-rpc-server.d.ts.map +1 -1
- package/dist/cf-worker/do/transport/do-rpc-server.js +41 -23
- package/dist/cf-worker/do/transport/do-rpc-server.js.map +1 -1
- package/dist/cf-worker/do/transport/do-rpc-server.test.d.ts +2 -0
- package/dist/cf-worker/do/transport/do-rpc-server.test.d.ts.map +1 -0
- package/dist/cf-worker/do/transport/do-rpc-server.test.js +28 -0
- package/dist/cf-worker/do/transport/do-rpc-server.test.js.map +1 -0
- package/dist/cf-worker/do/transport/http-rpc-server.d.ts +2 -2
- package/dist/cf-worker/do/transport/http-rpc-server.d.ts.map +1 -1
- package/dist/cf-worker/do/transport/http-rpc-server.js +12 -12
- package/dist/cf-worker/do/transport/http-rpc-server.js.map +1 -1
- package/dist/cf-worker/do/transport/ws-rpc-server.d.ts +9 -2
- package/dist/cf-worker/do/transport/ws-rpc-server.d.ts.map +1 -1
- package/dist/cf-worker/do/transport/ws-rpc-server.js +37 -29
- package/dist/cf-worker/do/transport/ws-rpc-server.js.map +1 -1
- package/dist/cf-worker/mod.js +3 -3
- package/dist/cf-worker/shared.d.ts +37 -29
- package/dist/cf-worker/shared.d.ts.map +1 -1
- package/dist/cf-worker/shared.js +14 -12
- package/dist/cf-worker/shared.js.map +1 -1
- package/dist/cf-worker/worker.d.ts +9 -9
- package/dist/cf-worker/worker.d.ts.map +1 -1
- package/dist/cf-worker/worker.js +17 -15
- package/dist/cf-worker/worker.js.map +1 -1
- package/dist/client/mod.js +3 -3
- package/dist/client/transport/do-rpc-client.d.ts +18 -6
- package/dist/client/transport/do-rpc-client.d.ts.map +1 -1
- package/dist/client/transport/do-rpc-client.js +112 -38
- package/dist/client/transport/do-rpc-client.js.map +1 -1
- package/dist/client/transport/do-rpc-client.test.d.ts +2 -0
- package/dist/client/transport/do-rpc-client.test.d.ts.map +1 -0
- package/dist/client/transport/do-rpc-client.test.js +268 -0
- package/dist/client/transport/do-rpc-client.test.js.map +1 -0
- package/dist/client/transport/http-rpc-client.d.ts +3 -3
- package/dist/client/transport/http-rpc-client.d.ts.map +1 -1
- package/dist/client/transport/http-rpc-client.js +48 -29
- package/dist/client/transport/http-rpc-client.js.map +1 -1
- package/dist/client/transport/rpc-client-error.d.ts +5 -0
- package/dist/client/transport/rpc-client-error.d.ts.map +1 -0
- package/dist/client/transport/rpc-client-error.js +8 -0
- package/dist/client/transport/rpc-client-error.js.map +1 -0
- package/dist/client/transport/rpc-client-error.test.d.ts +2 -0
- package/dist/client/transport/rpc-client-error.test.d.ts.map +1 -0
- package/dist/client/transport/rpc-client-error.test.js +33 -0
- package/dist/client/transport/rpc-client-error.test.js.map +1 -0
- package/dist/client/transport/ws-rpc-client.d.ts +3 -3
- package/dist/client/transport/ws-rpc-client.d.ts.map +1 -1
- package/dist/client/transport/ws-rpc-client.js +33 -23
- package/dist/client/transport/ws-rpc-client.js.map +1 -1
- package/dist/common/do-rpc-schema.d.ts +53 -41
- package/dist/common/do-rpc-schema.d.ts.map +1 -1
- package/dist/common/do-rpc-schema.js +13 -4
- package/dist/common/do-rpc-schema.js.map +1 -1
- package/dist/common/http-rpc-schema.d.ts +38 -39
- package/dist/common/http-rpc-schema.d.ts.map +1 -1
- package/dist/common/http-rpc-schema.js +6 -6
- package/dist/common/http-rpc-schema.js.map +1 -1
- package/dist/common/mod.d.ts +5 -5
- package/dist/common/mod.d.ts.map +1 -1
- package/dist/common/mod.js +7 -7
- package/dist/common/mod.js.map +1 -1
- package/dist/common/sync-message-types.d.ts +116 -133
- package/dist/common/sync-message-types.d.ts.map +1 -1
- package/dist/common/sync-message-types.js +26 -14
- package/dist/common/sync-message-types.js.map +1 -1
- package/dist/common/ws-rpc-schema.d.ts +33 -34
- package/dist/common/ws-rpc-schema.d.ts.map +1 -1
- package/dist/common/ws-rpc-schema.js +5 -5
- package/dist/common/ws-rpc-schema.js.map +1 -1
- package/package.json +42 -58
- package/src/cf-worker/do/durable-object.ts +70 -64
- package/src/cf-worker/do/layer.ts +142 -99
- package/src/cf-worker/do/observability.test.ts +337 -0
- package/src/cf-worker/do/observability.ts +121 -0
- package/src/cf-worker/do/pull.ts +28 -28
- package/src/cf-worker/do/push.test.ts +40 -0
- package/src/cf-worker/do/push.ts +139 -115
- package/src/cf-worker/do/sqlite.ts +1 -1
- package/src/cf-worker/do/sync-storage.ts +34 -21
- package/src/cf-worker/do/transport/do-rpc-server.test.ts +32 -0
- package/src/cf-worker/do/transport/do-rpc-server.ts +46 -35
- package/src/cf-worker/do/transport/http-rpc-server.ts +7 -10
- package/src/cf-worker/do/transport/ws-rpc-server.ts +52 -28
- package/src/cf-worker/shared.ts +29 -17
- package/src/cf-worker/worker.ts +21 -22
- package/src/client/transport/do-rpc-client.test.ts +411 -0
- package/src/client/transport/do-rpc-client.ts +175 -51
- package/src/client/transport/http-rpc-client.ts +66 -45
- package/src/client/transport/rpc-client-error.test.ts +41 -0
- package/src/client/transport/rpc-client-error.ts +9 -0
- package/src/client/transport/ws-rpc-client.ts +40 -32
- package/src/common/do-rpc-schema.ts +13 -3
- package/src/common/http-rpc-schema.ts +5 -5
- package/src/common/mod.ts +4 -4
- package/src/common/sync-message-types.ts +16 -16
- package/src/common/ws-rpc-schema.ts +4 -4
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { SyncBackend, UnknownError } from '@livestore/common';
|
|
2
|
+
import { splitArrayBySize } from '@livestore/common/sync';
|
|
3
|
+
import { Duration, Effect, Layer, Option, ReadonlyArray as EffectArray, RpcClient, RpcSerialization, Schedule, Schema, Socket, Stream, Struct, SubscriptionRef, UrlParams, } from '@livestore/utils/effect';
|
|
4
|
+
import { MAX_PUSH_EVENTS_PER_REQUEST, MAX_WS_MESSAGE_BYTES } from '../../common/constants.js';
|
|
5
|
+
import { SearchParamsSchema } from '../../common/mod.js';
|
|
6
|
+
import { SyncWsRpc } from '../../common/ws-rpc-schema.js';
|
|
7
|
+
import { mapRpcClientError } from './rpc-client-error.js';
|
|
8
8
|
/**
|
|
9
9
|
* Creates a sync backend that uses WebSocket to communicate with the sync backend.
|
|
10
10
|
*
|
|
@@ -15,7 +15,7 @@ import { SyncWsRpc } from "../../common/ws-rpc-schema.js";
|
|
|
15
15
|
* const syncBackend = makeWsSync({ url: 'wss://sync.example.com' })
|
|
16
16
|
*/
|
|
17
17
|
export const makeWsSync = (options) => ({ storeId, payload }) => Effect.gen(function* () {
|
|
18
|
-
const urlParamsData = yield* Schema.
|
|
18
|
+
const urlParamsData = yield* Schema.encodeEffect(SearchParamsSchema)({
|
|
19
19
|
storeId,
|
|
20
20
|
payload,
|
|
21
21
|
transport: 'ws',
|
|
@@ -31,13 +31,13 @@ export const makeWsSync = (options) => ({ storeId, payload }) => Effect.gen(func
|
|
|
31
31
|
// }
|
|
32
32
|
// TODO bring this back in a cross-platform way
|
|
33
33
|
// if (navigator.onLine === false) {
|
|
34
|
-
// yield* Effect.
|
|
34
|
+
// yield* Effect.callback((cb) => self.addEventListener('online', () => cb(Effect.void)))
|
|
35
35
|
// }
|
|
36
36
|
const pingInterval = options.ping?.requestInterval ?? 10_000;
|
|
37
37
|
const ProtocolLive = RpcClient.layerProtocolSocketWithIsConnected({
|
|
38
38
|
isConnected,
|
|
39
|
-
retryTransientErrors: Schedule.exponential('1 seconds').pipe(Schedule.
|
|
40
|
-
pingSchedule: Schedule.
|
|
39
|
+
retryTransientErrors: Schedule.exponential('1 seconds').pipe(Schedule.modifyDelay(({ duration }) => Effect.succeed(Duration.min(duration, Duration.seconds(30)))), Schedule.jittered),
|
|
40
|
+
pingSchedule: Schedule.recurs(1).pipe(Schedule.concat(Schedule.fixed(pingInterval))),
|
|
41
41
|
url: wsUrl,
|
|
42
42
|
}).pipe(Layer.provide(Socket.layerWebSocket(wsUrl)), Layer.provide(Socket.layerWebSocketConstructorGlobal), Layer.provide(RpcSerialization.layerJson));
|
|
43
43
|
// Warning: we need to build the layer here eagerly to tie it to the scope
|
|
@@ -49,12 +49,15 @@ export const makeWsSync = (options) => ({ storeId, payload }) => Effect.gen(func
|
|
|
49
49
|
const pinger = yield* RpcClient.SocketPinger.pipe(Effect.provide(ctx));
|
|
50
50
|
yield* pinger.ping;
|
|
51
51
|
yield* SubscriptionRef.set(isConnected, true);
|
|
52
|
-
}).pipe(Effect.
|
|
52
|
+
}).pipe(Effect.timeoutOrElse({
|
|
53
|
+
duration: pingTimeout,
|
|
54
|
+
orElse: () => SubscriptionRef.set(isConnected, false),
|
|
55
|
+
}), UnknownError.mapToUnknownError, Effect.withSpan('ping'));
|
|
53
56
|
const backendIdHelper = yield* SyncBackend.makeBackendIdHelper;
|
|
54
57
|
return SyncBackend.of({
|
|
55
58
|
isConnected,
|
|
56
59
|
connect: ping,
|
|
57
|
-
pull: (cursor, options) => rpcClient
|
|
60
|
+
pull: (cursor, options) => rpcClient['SyncWsRpc.Pull']({
|
|
58
61
|
storeId,
|
|
59
62
|
payload,
|
|
60
63
|
cursor: cursor.pipe(Option.map((a) => ({
|
|
@@ -62,8 +65,8 @@ export const makeWsSync = (options) => ({ storeId, payload }) => Effect.gen(func
|
|
|
62
65
|
backendId: backendIdHelper.get().pipe(Option.getOrThrow),
|
|
63
66
|
}))),
|
|
64
67
|
live: options?.live === true,
|
|
65
|
-
}).pipe(Stream.tap((res) => backendIdHelper.lazySet(res.backendId)), Stream.map((res) => omit(res, ['backendId'])), Stream.mapError((cause) => cause._tag === 'RpcClientError'
|
|
66
|
-
?
|
|
68
|
+
}).pipe(Stream.tap((res) => backendIdHelper.lazySet(res.backendId)), Stream.map((res) => Struct.omit(res, ['backendId'])), Stream.mapError((cause) => cause._tag === 'RpcClientError'
|
|
69
|
+
? mapRpcClientError(cause)
|
|
67
70
|
: cause._tag === 'UnknownError' || cause._tag === 'BackendIdMismatchError'
|
|
68
71
|
? cause
|
|
69
72
|
: new UnknownError({ cause })), Stream.withSpan('pull')),
|
|
@@ -76,20 +79,27 @@ export const makeWsSync = (options) => ({ storeId, payload }) => Effect.gen(func
|
|
|
76
79
|
batch,
|
|
77
80
|
backendId: backendIdHelper.get(),
|
|
78
81
|
});
|
|
79
|
-
|
|
82
|
+
if (EffectArray.isReadonlyArrayNonEmpty(batch) === false) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const batchChunks = yield* splitArrayBySize({
|
|
80
86
|
maxItems: MAX_PUSH_EVENTS_PER_REQUEST,
|
|
81
87
|
maxBytes: MAX_WS_MESSAGE_BYTES,
|
|
82
88
|
encode: encodePayload,
|
|
83
|
-
})
|
|
84
|
-
for (const
|
|
85
|
-
yield* rpcClient
|
|
89
|
+
})(batch).pipe(Effect.mapError((cause) => new UnknownError({ cause })));
|
|
90
|
+
for (const batchChunk of batchChunks) {
|
|
91
|
+
yield* rpcClient['SyncWsRpc.Push']({
|
|
86
92
|
storeId,
|
|
87
93
|
payload,
|
|
88
|
-
batch:
|
|
94
|
+
batch: batchChunk,
|
|
89
95
|
backendId: backendIdHelper.get(),
|
|
90
|
-
}).pipe(Effect.mapError((cause) => cause._tag === '
|
|
91
|
-
? cause
|
|
92
|
-
:
|
|
96
|
+
}).pipe(Effect.mapError((cause) => cause._tag === 'RpcClientError'
|
|
97
|
+
? mapRpcClientError(cause)
|
|
98
|
+
: cause._tag === 'UnknownError' ||
|
|
99
|
+
cause._tag === 'ServerAheadError' ||
|
|
100
|
+
cause._tag === 'BackendIdMismatchError'
|
|
101
|
+
? cause
|
|
102
|
+
: new UnknownError({ cause })));
|
|
93
103
|
}
|
|
94
104
|
}),
|
|
95
105
|
ping,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-rpc-client.js","sourceRoot":"","sources":["../../../src/client/transport/ws-rpc-client.ts"],"names":[],"m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CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;YAEvE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;gBACrC,KAAK,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;oBACjC,OAAO;oBACP,OAAO;oBACP,KAAK,EAAE,UAAU;oBACjB,SAAS,EAAE,eAAe,CAAC,GAAG,EAAE;iBACjC,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CACxB,KAAK,CAAC,IAAI,KAAK,gBAAgB;oBAC7B,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC;oBAC1B,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,cAAc;wBAC3B,KAAK,CAAC,IAAI,KAAK,kBAAkB;wBACjC,KAAK,CAAC,IAAI,KAAK,wBAAwB;wBACzC,CAAC,CAAC,KAAK;wBACP,CAAC,CAAC,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,CAClC,CACF,CAAA;YACH,CAAC;QACH,CAAC,CAAC;QACF,IAAI;QACJ,QAAQ,EAAE;YACR,IAAI,EAAE,oBAAoB;YAC1B,WAAW,EAAE,kFAAkF;YAC/F,QAAQ,EAAE,IAAI;YACd,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,IAAI;YACvB,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,75 +1,87 @@
|
|
|
1
1
|
import { BackendIdMismatchError, ServerAheadError, UnknownError } from '@livestore/common';
|
|
2
2
|
import { Rpc, RpcGroup, Schema } from '@livestore/utils/effect';
|
|
3
|
-
declare const SyncDoRpc_base: RpcGroup.RpcGroup<Rpc.Rpc<"SyncDoRpc.
|
|
3
|
+
declare const SyncDoRpc_base: RpcGroup.RpcGroup<Rpc.Rpc<"SyncDoRpc.Ping", Schema.Struct<{
|
|
4
4
|
/**
|
|
5
5
|
* While the storeId is already implied by the Durable Object, we still need the explicit storeId
|
|
6
6
|
* since a DO doesn't know its own id.name value. 🫠
|
|
7
7
|
* https://community.cloudflare.com/t/how-can-i-get-the-name-of-a-durable-object-from-itself/505961/8
|
|
8
8
|
*/
|
|
9
|
-
storeId:
|
|
9
|
+
storeId: Schema.String;
|
|
10
10
|
/** Needed for various reasons (e.g. auth) */
|
|
11
|
-
payload: Schema.optional<Schema.
|
|
11
|
+
payload: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
12
|
+
}>, Schema.Void, Schema.Never, never, never> | Rpc.Rpc<"SyncDoRpc.Pull", Schema.Struct<{
|
|
13
|
+
/**
|
|
14
|
+
* While the storeId is already implied by the Durable Object, we still need the explicit storeId
|
|
15
|
+
* since a DO doesn't know its own id.name value. 🫠
|
|
16
|
+
* https://community.cloudflare.com/t/how-can-i-get-the-name-of-a-durable-object-from-itself/505961/8
|
|
17
|
+
*/
|
|
18
|
+
storeId: Schema.String;
|
|
19
|
+
/** Needed for various reasons (e.g. auth) */
|
|
20
|
+
payload: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
12
21
|
/** Omitting the cursor will start from the beginning */
|
|
13
22
|
cursor: Schema.Option<Schema.Struct<{
|
|
14
|
-
backendId: Schema.
|
|
15
|
-
eventSequenceNumber: Schema.
|
|
23
|
+
readonly backendId: Schema.String;
|
|
24
|
+
readonly eventSequenceNumber: Schema.brand<Schema.Int, "GlobalEventSequenceNumber">;
|
|
16
25
|
}>>;
|
|
17
26
|
/** Whether to keep the pull stream alive and wait for more events */
|
|
18
27
|
rpcContext: Schema.optional<Schema.Struct<{
|
|
19
|
-
callerContext: Schema.Struct<{
|
|
20
|
-
bindingName:
|
|
21
|
-
durableObjectId:
|
|
28
|
+
readonly callerContext: Schema.Struct<{
|
|
29
|
+
readonly bindingName: Schema.String;
|
|
30
|
+
readonly durableObjectId: Schema.String;
|
|
22
31
|
}>;
|
|
23
32
|
}>>;
|
|
24
|
-
}>, import("
|
|
25
|
-
batch: Schema
|
|
26
|
-
eventEncoded: Schema.Struct<{
|
|
27
|
-
name:
|
|
28
|
-
args:
|
|
29
|
-
seqNum: Schema.
|
|
30
|
-
parentSeqNum: Schema.
|
|
31
|
-
clientId:
|
|
32
|
-
sessionId:
|
|
33
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Struct<{
|
|
34
|
+
readonly batch: Schema.$Array<Schema.Struct<{
|
|
35
|
+
readonly eventEncoded: Schema.Struct<{
|
|
36
|
+
readonly name: Schema.String;
|
|
37
|
+
readonly args: Schema.Any;
|
|
38
|
+
readonly seqNum: Schema.brand<Schema.Int, "GlobalEventSequenceNumber">;
|
|
39
|
+
readonly parentSeqNum: Schema.brand<Schema.Int, "GlobalEventSequenceNumber">;
|
|
40
|
+
readonly clientId: Schema.String;
|
|
41
|
+
readonly sessionId: Schema.String;
|
|
33
42
|
}>;
|
|
34
|
-
metadata: Schema.Option<Schema.Struct<{
|
|
35
|
-
_tag: Schema.tag<"SyncMessage.SyncMetadata">;
|
|
36
|
-
|
|
37
|
-
createdAt: typeof Schema.String;
|
|
43
|
+
readonly metadata: Schema.Option<Schema.Struct<{
|
|
44
|
+
readonly _tag: Schema.tag<"SyncMessage.SyncMetadata">;
|
|
45
|
+
readonly createdAt: Schema.String;
|
|
38
46
|
}>>;
|
|
39
47
|
}>>;
|
|
40
|
-
pageInfo: Schema.Union<[Schema.TaggedStruct<"MoreUnknown", {}>, Schema.TaggedStruct<"MoreKnown", {
|
|
41
|
-
remaining:
|
|
48
|
+
readonly pageInfo: Schema.Union<readonly [Schema.TaggedStruct<"MoreUnknown", {}>, Schema.TaggedStruct<"MoreKnown", {
|
|
49
|
+
readonly remaining: Schema.Finite;
|
|
42
50
|
}>, Schema.TaggedStruct<"NoMore", {}>]>;
|
|
43
|
-
backendId: Schema.
|
|
44
|
-
rpcRequestId:
|
|
45
|
-
}>, Schema.Union<[typeof UnknownError, typeof BackendIdMismatchError]>>,
|
|
51
|
+
readonly backendId: Schema.String;
|
|
52
|
+
readonly rpcRequestId: Schema.String;
|
|
53
|
+
}>, Schema.Union<readonly [typeof UnknownError, typeof BackendIdMismatchError]>>, Schema.Never, never, never> | Rpc.Rpc<"SyncDoRpc.Push", Schema.Struct<{
|
|
54
|
+
batch: Schema.$Array<Schema.Struct<{
|
|
55
|
+
readonly name: Schema.String;
|
|
56
|
+
readonly args: Schema.Any;
|
|
57
|
+
readonly seqNum: Schema.brand<Schema.Int, "GlobalEventSequenceNumber">;
|
|
58
|
+
readonly parentSeqNum: Schema.brand<Schema.Int, "GlobalEventSequenceNumber">;
|
|
59
|
+
readonly clientId: Schema.String;
|
|
60
|
+
readonly sessionId: Schema.String;
|
|
61
|
+
}>>;
|
|
62
|
+
backendId: Schema.Option<Schema.String>;
|
|
46
63
|
/**
|
|
47
64
|
* While the storeId is already implied by the Durable Object, we still need the explicit storeId
|
|
48
65
|
* since a DO doesn't know its own id.name value. 🫠
|
|
49
66
|
* https://community.cloudflare.com/t/how-can-i-get-the-name-of-a-durable-object-from-itself/505961/8
|
|
50
67
|
*/
|
|
51
|
-
storeId:
|
|
68
|
+
storeId: Schema.String;
|
|
52
69
|
/** Needed for various reasons (e.g. auth) */
|
|
53
|
-
payload: Schema.optional<Schema.
|
|
54
|
-
|
|
55
|
-
name: typeof Schema.String;
|
|
56
|
-
args: typeof Schema.Any;
|
|
57
|
-
seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
58
|
-
parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
59
|
-
clientId: typeof Schema.String;
|
|
60
|
-
sessionId: typeof Schema.String;
|
|
61
|
-
}>>;
|
|
62
|
-
backendId: Schema.Option<Schema.SchemaClass<string, string, never>>;
|
|
63
|
-
}>, Schema.Struct<{}>, Schema.Union<[typeof UnknownError, typeof ServerAheadError, typeof BackendIdMismatchError]>, never> | Rpc.Rpc<"SyncDoRpc.Ping", Schema.Struct<{
|
|
70
|
+
payload: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
71
|
+
}>, Schema.Struct<{}>, Schema.Union<readonly [typeof UnknownError, typeof ServerAheadError, typeof BackendIdMismatchError]>, never, never> | Rpc.Rpc<"SyncDoRpc.Unsubscribe", Schema.Struct<{
|
|
64
72
|
/**
|
|
65
73
|
* While the storeId is already implied by the Durable Object, we still need the explicit storeId
|
|
66
74
|
* since a DO doesn't know its own id.name value. 🫠
|
|
67
75
|
* https://community.cloudflare.com/t/how-can-i-get-the-name-of-a-durable-object-from-itself/505961/8
|
|
68
76
|
*/
|
|
69
|
-
storeId:
|
|
77
|
+
storeId: Schema.String;
|
|
70
78
|
/** Needed for various reasons (e.g. auth) */
|
|
71
|
-
payload: Schema.optional<Schema.
|
|
72
|
-
|
|
79
|
+
payload: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
80
|
+
/** Client DO id whose live-pull subscription row to drop. */
|
|
81
|
+
durableObjectId: Schema.String;
|
|
82
|
+
/** Request id of the live pull that registered the row; the row is only dropped if it still matches. */
|
|
83
|
+
requestId: Schema.String;
|
|
84
|
+
}>, Schema.Void, Schema.Never, never, never>>;
|
|
73
85
|
export declare class SyncDoRpc extends SyncDoRpc_base {
|
|
74
86
|
}
|
|
75
87
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"do-rpc-schema.d.ts","sourceRoot":"","sources":["../../src/common/do-rpc-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC1F,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;;IAK7D;;;;OAIG;;IAEH,6CAA6C;;IAOzC,wDAAwD;;;;;IAGxD,qEAAqE
|
|
1
|
+
{"version":3,"file":"do-rpc-schema.d.ts","sourceRoot":"","sources":["../../src/common/do-rpc-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC1F,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;;IAK7D;;;;OAIG;;IAEH,6CAA6C;;;IAN7C;;;;OAIG;;IAEH,6CAA6C;;IAOzC,wDAAwD;;;;;IAGxD,qEAAqE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAhBzE;;;;OAIG;;IAEH,6CAA6C;;;IAN7C;;;;OAIG;;IAEH,6CAA6C;;IA4CzC,6DAA6D;;IAE7D,wGAAwG;;;AA1C9G,qBAAa,SAAU,SAAQ,cAgD9B;CAAG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BackendIdMismatchError, ServerAheadError, UnknownError } from '@livestore/common';
|
|
2
2
|
import { Rpc, RpcGroup, Schema } from '@livestore/utils/effect';
|
|
3
|
-
import * as SyncMessage from
|
|
3
|
+
import * as SyncMessage from './sync-message-types.js';
|
|
4
4
|
const commonPayloadFields = {
|
|
5
5
|
/**
|
|
6
6
|
* While the storeId is already implied by the Durable Object, we still need the explicit storeId
|
|
@@ -9,7 +9,7 @@ const commonPayloadFields = {
|
|
|
9
9
|
*/
|
|
10
10
|
storeId: Schema.String,
|
|
11
11
|
/** Needed for various reasons (e.g. auth) */
|
|
12
|
-
payload: Schema.optional(Schema.
|
|
12
|
+
payload: Schema.optional(Schema.Json),
|
|
13
13
|
};
|
|
14
14
|
export class SyncDoRpc extends RpcGroup.make(Rpc.make('SyncDoRpc.Pull', {
|
|
15
15
|
payload: {
|
|
@@ -29,7 +29,7 @@ export class SyncDoRpc extends RpcGroup.make(Rpc.make('SyncDoRpc.Pull', {
|
|
|
29
29
|
rpcRequestId: Schema.String,
|
|
30
30
|
...SyncMessage.PullResponse.fields,
|
|
31
31
|
}),
|
|
32
|
-
error: Schema.Union(UnknownError, BackendIdMismatchError),
|
|
32
|
+
error: Schema.Union([UnknownError, BackendIdMismatchError]),
|
|
33
33
|
stream: true,
|
|
34
34
|
}), Rpc.make('SyncDoRpc.Push', {
|
|
35
35
|
payload: {
|
|
@@ -37,12 +37,21 @@ export class SyncDoRpc extends RpcGroup.make(Rpc.make('SyncDoRpc.Pull', {
|
|
|
37
37
|
...commonPayloadFields,
|
|
38
38
|
},
|
|
39
39
|
success: SyncMessage.PushAck,
|
|
40
|
-
error: Schema.Union(UnknownError, ServerAheadError, BackendIdMismatchError),
|
|
40
|
+
error: Schema.Union([UnknownError, ServerAheadError, BackendIdMismatchError]),
|
|
41
41
|
}), Rpc.make('SyncDoRpc.Ping', {
|
|
42
42
|
payload: {
|
|
43
43
|
...commonPayloadFields,
|
|
44
44
|
},
|
|
45
45
|
success: Schema.Void,
|
|
46
|
+
}), Rpc.make('SyncDoRpc.Unsubscribe', {
|
|
47
|
+
payload: {
|
|
48
|
+
/** Client DO id whose live-pull subscription row to drop. */
|
|
49
|
+
durableObjectId: Schema.String,
|
|
50
|
+
/** Request id of the live pull that registered the row; the row is only dropped if it still matches. */
|
|
51
|
+
requestId: Schema.String,
|
|
52
|
+
...commonPayloadFields,
|
|
53
|
+
},
|
|
54
|
+
success: Schema.Void,
|
|
46
55
|
})) {
|
|
47
56
|
}
|
|
48
57
|
//# sourceMappingURL=do-rpc-schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"do-rpc-schema.js","sourceRoot":"","sources":["../../src/common/do-rpc-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC1F,OAA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AY,EAAE,MAAM,CAAC,MAAM;QAC3B,GAAG,WAAW,CAAC,YAAY,CAAC,MAAM;KACnC,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC;IAC3D,MAAM,EAAE,IAAI;CACb,CAAC,EACF,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE;IACzB,OAAO,EAAE;QACP,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM;QACjC,GAAG,mBAAmB;KACvB;IACD,OAAO,EAAE,WAAW,CAAC,OAAO;IAC5B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,CAAC,CAAC;CAC9E,CAAC,EACF,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE;IACzB,OAAO,EAAE;QACP,GAAG,mBAAmB;KACvB;IACD,OAAO,EAAE,MAAM,CAAC,IAAI;CACrB,CAAC,EACF,GAAG,CAAC,IAAI,CAAC,uBAAuB,EAAE;IAChC,OAAO,EAAE;QACP,6DAA6D;QAC7D,eAAe,EAAE,MAAM,CAAC,MAAM;QAC9B,wGAAwG;QACxG,SAAS,EAAE,MAAM,CAAC,MAAM;QACxB,GAAG,mBAAmB;KACvB;IACD,OAAO,EAAE,MAAM,CAAC,IAAI;CACrB,CAAC,CACH;CAAG"}
|
|
@@ -1,50 +1,49 @@
|
|
|
1
1
|
import { BackendIdMismatchError, ServerAheadError, UnknownError } from '@livestore/common';
|
|
2
2
|
import { Rpc, RpcGroup, Schema } from '@livestore/utils/effect';
|
|
3
|
-
declare const SyncHttpRpc_base: RpcGroup.RpcGroup<Rpc.Rpc<"SyncHttpRpc.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
declare const SyncHttpRpc_base: RpcGroup.RpcGroup<Rpc.Rpc<"SyncHttpRpc.Ping", Schema.Struct<{
|
|
4
|
+
readonly storeId: Schema.String;
|
|
5
|
+
readonly payload: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
6
|
+
}>, Schema.Struct<{
|
|
7
|
+
readonly _tag: Schema.tag<"SyncMessage.Pong">;
|
|
8
|
+
}>, typeof UnknownError, never, never> | Rpc.Rpc<"SyncHttpRpc.Pull", Schema.Struct<{
|
|
9
|
+
readonly cursor: Schema.Option<Schema.Struct<{
|
|
10
|
+
readonly backendId: Schema.String;
|
|
11
|
+
readonly eventSequenceNumber: Schema.brand<Schema.Int, "GlobalEventSequenceNumber">;
|
|
7
12
|
}>>;
|
|
8
|
-
storeId:
|
|
9
|
-
payload: Schema.optional<Schema.
|
|
10
|
-
}>, import("
|
|
11
|
-
batch: Schema
|
|
12
|
-
eventEncoded: Schema.Struct<{
|
|
13
|
-
name:
|
|
14
|
-
args:
|
|
15
|
-
seqNum: Schema.
|
|
16
|
-
parentSeqNum: Schema.
|
|
17
|
-
clientId:
|
|
18
|
-
sessionId:
|
|
13
|
+
readonly storeId: Schema.String;
|
|
14
|
+
readonly payload: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
15
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Struct<{
|
|
16
|
+
readonly batch: Schema.$Array<Schema.Struct<{
|
|
17
|
+
readonly eventEncoded: Schema.Struct<{
|
|
18
|
+
readonly name: Schema.String;
|
|
19
|
+
readonly args: Schema.Any;
|
|
20
|
+
readonly seqNum: Schema.brand<Schema.Int, "GlobalEventSequenceNumber">;
|
|
21
|
+
readonly parentSeqNum: Schema.brand<Schema.Int, "GlobalEventSequenceNumber">;
|
|
22
|
+
readonly clientId: Schema.String;
|
|
23
|
+
readonly sessionId: Schema.String;
|
|
19
24
|
}>;
|
|
20
|
-
metadata: Schema.Option<Schema.Struct<{
|
|
21
|
-
_tag: Schema.tag<"SyncMessage.SyncMetadata">;
|
|
22
|
-
|
|
23
|
-
createdAt: typeof Schema.String;
|
|
25
|
+
readonly metadata: Schema.Option<Schema.Struct<{
|
|
26
|
+
readonly _tag: Schema.tag<"SyncMessage.SyncMetadata">;
|
|
27
|
+
readonly createdAt: Schema.String;
|
|
24
28
|
}>>;
|
|
25
29
|
}>>;
|
|
26
|
-
pageInfo: Schema.Union<[Schema.TaggedStruct<"MoreUnknown", {}>, Schema.TaggedStruct<"MoreKnown", {
|
|
27
|
-
remaining:
|
|
30
|
+
readonly pageInfo: Schema.Union<readonly [Schema.TaggedStruct<"MoreUnknown", {}>, Schema.TaggedStruct<"MoreKnown", {
|
|
31
|
+
readonly remaining: Schema.Finite;
|
|
28
32
|
}>, Schema.TaggedStruct<"NoMore", {}>]>;
|
|
29
|
-
backendId: Schema.
|
|
30
|
-
}>, Schema.Union<[typeof UnknownError, typeof BackendIdMismatchError]>>,
|
|
31
|
-
batch: Schema
|
|
32
|
-
name:
|
|
33
|
-
args:
|
|
34
|
-
seqNum: Schema.
|
|
35
|
-
parentSeqNum: Schema.
|
|
36
|
-
clientId:
|
|
37
|
-
sessionId:
|
|
33
|
+
readonly backendId: Schema.String;
|
|
34
|
+
}>, Schema.Union<readonly [typeof UnknownError, typeof BackendIdMismatchError]>>, Schema.Never, never, never> | Rpc.Rpc<"SyncHttpRpc.Push", Schema.Struct<{
|
|
35
|
+
readonly batch: Schema.$Array<Schema.Struct<{
|
|
36
|
+
readonly name: Schema.String;
|
|
37
|
+
readonly args: Schema.Any;
|
|
38
|
+
readonly seqNum: Schema.brand<Schema.Int, "GlobalEventSequenceNumber">;
|
|
39
|
+
readonly parentSeqNum: Schema.brand<Schema.Int, "GlobalEventSequenceNumber">;
|
|
40
|
+
readonly clientId: Schema.String;
|
|
41
|
+
readonly sessionId: Schema.String;
|
|
38
42
|
}>>;
|
|
39
|
-
backendId: Schema.Option<Schema.
|
|
40
|
-
storeId:
|
|
41
|
-
payload: Schema.optional<Schema.
|
|
42
|
-
}>, Schema.Struct<{}>, Schema.Union<[typeof UnknownError, typeof ServerAheadError, typeof BackendIdMismatchError]>, never
|
|
43
|
-
storeId: typeof Schema.String;
|
|
44
|
-
payload: Schema.optional<Schema.Schema<Schema.JsonValue, Schema.JsonValue, never>>;
|
|
45
|
-
}>, Schema.Struct<{
|
|
46
|
-
_tag: Schema.tag<"SyncMessage.Pong">;
|
|
47
|
-
}>, typeof UnknownError, never>>;
|
|
43
|
+
readonly backendId: Schema.Option<Schema.String>;
|
|
44
|
+
readonly storeId: Schema.String;
|
|
45
|
+
readonly payload: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
46
|
+
}>, Schema.Struct<{}>, Schema.Union<readonly [typeof UnknownError, typeof ServerAheadError, typeof BackendIdMismatchError]>, never, never>>;
|
|
48
47
|
/**
|
|
49
48
|
* HTTP RPC Schema for LiveStore CF Sync Provider
|
|
50
49
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-rpc-schema.d.ts","sourceRoot":"","sources":["../../src/common/http-rpc-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC1F,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA
|
|
1
|
+
{"version":3,"file":"http-rpc-schema.d.ts","sourceRoot":"","sources":["../../src/common/http-rpc-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC1F,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAI/D;;;;;;GAMG;AACH,qBAAa,WAAY,SAAQ,gBA4BhC;CAAG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BackendIdMismatchError, ServerAheadError, UnknownError } from '@livestore/common';
|
|
2
2
|
import { Rpc, RpcGroup, Schema } from '@livestore/utils/effect';
|
|
3
|
-
import * as SyncMessage from
|
|
3
|
+
import * as SyncMessage from './sync-message-types.js';
|
|
4
4
|
/**
|
|
5
5
|
* HTTP RPC Schema for LiveStore CF Sync Provider
|
|
6
6
|
*
|
|
@@ -11,24 +11,24 @@ import * as SyncMessage from "./sync-message-types.js";
|
|
|
11
11
|
export class SyncHttpRpc extends RpcGroup.make(Rpc.make('SyncHttpRpc.Pull', {
|
|
12
12
|
payload: Schema.Struct({
|
|
13
13
|
storeId: Schema.String,
|
|
14
|
-
payload: Schema.optional(Schema.
|
|
14
|
+
payload: Schema.optional(Schema.Json),
|
|
15
15
|
...SyncMessage.PullRequest.fields,
|
|
16
16
|
}),
|
|
17
17
|
success: SyncMessage.PullResponse,
|
|
18
|
-
error: Schema.Union(UnknownError, BackendIdMismatchError),
|
|
18
|
+
error: Schema.Union([UnknownError, BackendIdMismatchError]),
|
|
19
19
|
stream: true,
|
|
20
20
|
}), Rpc.make('SyncHttpRpc.Push', {
|
|
21
21
|
payload: Schema.Struct({
|
|
22
22
|
storeId: Schema.String,
|
|
23
|
-
payload: Schema.optional(Schema.
|
|
23
|
+
payload: Schema.optional(Schema.Json),
|
|
24
24
|
...SyncMessage.PushRequest.fields,
|
|
25
25
|
}),
|
|
26
26
|
success: SyncMessage.PushAck,
|
|
27
|
-
error: Schema.Union(UnknownError, ServerAheadError, BackendIdMismatchError),
|
|
27
|
+
error: Schema.Union([UnknownError, ServerAheadError, BackendIdMismatchError]),
|
|
28
28
|
}), Rpc.make('SyncHttpRpc.Ping', {
|
|
29
29
|
payload: Schema.Struct({
|
|
30
30
|
storeId: Schema.String,
|
|
31
|
-
payload: Schema.optional(Schema.
|
|
31
|
+
payload: Schema.optional(Schema.Json),
|
|
32
32
|
}),
|
|
33
33
|
success: SyncMessage.Pong,
|
|
34
34
|
error: UnknownError,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-rpc-schema.js","sourceRoot":"","sources":["../../src/common/http-rpc-schema.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GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC,MAAM;QACtB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;QACrC,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM;KAClC,CAAC;IACF,OAAO,EAAE,WAAW,CAAC,OAAO;IAC5B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,CAAC,CAAC;CAC9E,CAAC,EACF,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC,MAAM;QACtB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;KACtC,CAAC;IACF,OAAO,EAAE,WAAW,CAAC,IAAI;IACzB,KAAK,EAAE,YAAY;CACpB,CAAC,CACH;CAAG"}
|
package/dist/common/mod.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
export { OversizeChunkItemError, splitArrayBySize } from '@livestore/common/sync';
|
|
2
2
|
import { Schema } from '@livestore/utils/effect';
|
|
3
3
|
export type { CfTypes } from '@livestore/common-cf';
|
|
4
4
|
export * from './constants.ts';
|
|
5
|
+
export { SyncDoRpc } from './do-rpc-schema.ts';
|
|
5
6
|
export { SyncHttpRpc } from './http-rpc-schema.ts';
|
|
6
7
|
export * as SyncMessage from './sync-message-types.ts';
|
|
7
|
-
export { OversizeChunkItemError, splitChunkBySize };
|
|
8
8
|
export declare const SearchParamsSchema: Schema.Struct<{
|
|
9
|
-
storeId:
|
|
10
|
-
payload: Schema.
|
|
11
|
-
transport: Schema.
|
|
9
|
+
readonly storeId: Schema.String;
|
|
10
|
+
readonly payload: Schema.optional<Schema.compose<Schema.fromJsonString<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.StringFromUriComponent>>;
|
|
11
|
+
readonly transport: Schema.Literals<readonly ["http", "ws"]>;
|
|
12
12
|
}>;
|
|
13
13
|
export type SearchParams = typeof SearchParamsSchema.Type;
|
|
14
14
|
//# sourceMappingURL=mod.d.ts.map
|
package/dist/common/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/common/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,YAAY,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/common/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,YAAY,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAA;AAEtD,eAAO,MAAM,kBAAkB;;;;EAK7B,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAA"}
|
package/dist/common/mod.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
export { OversizeChunkItemError, splitArrayBySize } from '@livestore/common/sync';
|
|
2
2
|
import { Schema } from '@livestore/utils/effect';
|
|
3
|
-
export * from
|
|
4
|
-
export {
|
|
5
|
-
export
|
|
6
|
-
export
|
|
3
|
+
export * from './constants.js';
|
|
4
|
+
export { SyncDoRpc } from './do-rpc-schema.js';
|
|
5
|
+
export { SyncHttpRpc } from './http-rpc-schema.js';
|
|
6
|
+
export * as SyncMessage from './sync-message-types.js';
|
|
7
7
|
export const SearchParamsSchema = Schema.Struct({
|
|
8
8
|
storeId: Schema.String,
|
|
9
|
-
payload: Schema.
|
|
9
|
+
payload: Schema.optional(Schema.StringFromUriComponent.pipe(Schema.decodeTo(Schema.fromJsonString(Schema.Json)))),
|
|
10
10
|
// NOTE `do-rpc` is handled differently
|
|
11
|
-
transport: Schema.
|
|
11
|
+
transport: Schema.Literals(['http', 'ws']),
|
|
12
12
|
});
|
|
13
13
|
//# sourceMappingURL=mod.js.map
|
package/dist/common/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/common/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGhD,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/common/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGhD,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAA;AAEtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjH,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC3C,CAAC,CAAA"}
|