@livestore/sync-cf 0.4.0-dev.0 → 0.4.0-dev.10
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 +60 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/cf-worker/do/durable-object.d.ts +45 -0
- package/dist/cf-worker/do/durable-object.d.ts.map +1 -0
- package/dist/cf-worker/do/durable-object.js +150 -0
- package/dist/cf-worker/do/durable-object.js.map +1 -0
- package/dist/cf-worker/do/layer.d.ts +34 -0
- package/dist/cf-worker/do/layer.d.ts.map +1 -0
- package/dist/cf-worker/do/layer.js +91 -0
- package/dist/cf-worker/do/layer.js.map +1 -0
- package/dist/cf-worker/do/pull.d.ts +6 -0
- package/dist/cf-worker/do/pull.d.ts.map +1 -0
- package/dist/cf-worker/do/pull.js +47 -0
- package/dist/cf-worker/do/pull.js.map +1 -0
- package/dist/cf-worker/do/push.d.ts +14 -0
- package/dist/cf-worker/do/push.d.ts.map +1 -0
- package/dist/cf-worker/do/push.js +131 -0
- package/dist/cf-worker/do/push.js.map +1 -0
- package/dist/cf-worker/{durable-object.d.ts → do/sqlite.d.ts} +77 -70
- package/dist/cf-worker/do/sqlite.d.ts.map +1 -0
- package/dist/cf-worker/do/sqlite.js +27 -0
- package/dist/cf-worker/do/sqlite.js.map +1 -0
- package/dist/cf-worker/do/sync-storage.d.ts +25 -0
- package/dist/cf-worker/do/sync-storage.d.ts.map +1 -0
- package/dist/cf-worker/do/sync-storage.js +190 -0
- package/dist/cf-worker/do/sync-storage.js.map +1 -0
- package/dist/cf-worker/do/transport/do-rpc-server.d.ts +9 -0
- package/dist/cf-worker/do/transport/do-rpc-server.d.ts.map +1 -0
- package/dist/cf-worker/do/transport/do-rpc-server.js +45 -0
- package/dist/cf-worker/do/transport/do-rpc-server.js.map +1 -0
- package/dist/cf-worker/do/transport/http-rpc-server.d.ts +7 -0
- package/dist/cf-worker/do/transport/http-rpc-server.d.ts.map +1 -0
- package/dist/cf-worker/do/transport/http-rpc-server.js +24 -0
- package/dist/cf-worker/do/transport/http-rpc-server.js.map +1 -0
- package/dist/cf-worker/do/transport/ws-rpc-server.d.ts +4 -0
- package/dist/cf-worker/do/transport/ws-rpc-server.d.ts.map +1 -0
- package/dist/cf-worker/do/transport/ws-rpc-server.js +21 -0
- package/dist/cf-worker/do/transport/ws-rpc-server.js.map +1 -0
- package/dist/cf-worker/mod.d.ts +4 -2
- package/dist/cf-worker/mod.d.ts.map +1 -1
- package/dist/cf-worker/mod.js +3 -2
- package/dist/cf-worker/mod.js.map +1 -1
- package/dist/cf-worker/shared.d.ts +147 -0
- package/dist/cf-worker/shared.d.ts.map +1 -0
- package/dist/cf-worker/shared.js +32 -0
- package/dist/cf-worker/shared.js.map +1 -0
- package/dist/cf-worker/worker.d.ts +45 -45
- package/dist/cf-worker/worker.d.ts.map +1 -1
- package/dist/cf-worker/worker.js +51 -39
- package/dist/cf-worker/worker.js.map +1 -1
- package/dist/client/mod.d.ts +4 -0
- package/dist/client/mod.d.ts.map +1 -0
- package/dist/client/mod.js +4 -0
- package/dist/client/mod.js.map +1 -0
- package/dist/client/transport/do-rpc-client.d.ts +40 -0
- package/dist/client/transport/do-rpc-client.d.ts.map +1 -0
- package/dist/client/transport/do-rpc-client.js +117 -0
- package/dist/client/transport/do-rpc-client.js.map +1 -0
- package/dist/client/transport/http-rpc-client.d.ts +43 -0
- package/dist/client/transport/http-rpc-client.d.ts.map +1 -0
- package/dist/client/transport/http-rpc-client.js +103 -0
- package/dist/client/transport/http-rpc-client.js.map +1 -0
- package/dist/client/transport/ws-rpc-client.d.ts +45 -0
- package/dist/client/transport/ws-rpc-client.d.ts.map +1 -0
- package/dist/client/transport/ws-rpc-client.js +108 -0
- package/dist/client/transport/ws-rpc-client.js.map +1 -0
- package/dist/common/constants.d.ts +7 -0
- package/dist/common/constants.d.ts.map +1 -0
- package/dist/common/constants.js +17 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/do-rpc-schema.d.ts +76 -0
- package/dist/common/do-rpc-schema.d.ts.map +1 -0
- package/dist/common/do-rpc-schema.js +48 -0
- package/dist/common/do-rpc-schema.js.map +1 -0
- package/dist/common/http-rpc-schema.d.ts +58 -0
- package/dist/common/http-rpc-schema.d.ts.map +1 -0
- package/dist/common/http-rpc-schema.js +37 -0
- package/dist/common/http-rpc-schema.js.map +1 -0
- package/dist/common/mod.d.ts +8 -1
- package/dist/common/mod.d.ts.map +1 -1
- package/dist/common/mod.js +7 -1
- package/dist/common/mod.js.map +1 -1
- package/dist/common/{ws-message-types.d.ts → sync-message-types.d.ts} +119 -153
- package/dist/common/sync-message-types.d.ts.map +1 -0
- package/dist/common/sync-message-types.js +60 -0
- package/dist/common/sync-message-types.js.map +1 -0
- package/dist/common/ws-rpc-schema.d.ts +55 -0
- package/dist/common/ws-rpc-schema.d.ts.map +1 -0
- package/dist/common/ws-rpc-schema.js +32 -0
- package/dist/common/ws-rpc-schema.js.map +1 -0
- package/package.json +7 -8
- package/src/cf-worker/do/durable-object.ts +237 -0
- package/src/cf-worker/do/layer.ts +128 -0
- package/src/cf-worker/do/pull.ts +77 -0
- package/src/cf-worker/do/push.ts +205 -0
- package/src/cf-worker/do/sqlite.ts +28 -0
- package/src/cf-worker/do/sync-storage.ts +321 -0
- package/src/cf-worker/do/transport/do-rpc-server.ts +84 -0
- package/src/cf-worker/do/transport/http-rpc-server.ts +37 -0
- package/src/cf-worker/do/transport/ws-rpc-server.ts +34 -0
- package/src/cf-worker/mod.ts +4 -2
- package/src/cf-worker/shared.ts +112 -0
- package/src/cf-worker/worker.ts +91 -105
- package/src/client/mod.ts +3 -0
- package/src/client/transport/do-rpc-client.ts +191 -0
- package/src/client/transport/http-rpc-client.ts +225 -0
- package/src/client/transport/ws-rpc-client.ts +202 -0
- package/src/common/constants.ts +18 -0
- package/src/common/do-rpc-schema.ts +54 -0
- package/src/common/http-rpc-schema.ts +40 -0
- package/src/common/mod.ts +10 -1
- package/src/common/sync-message-types.ts +117 -0
- package/src/common/ws-rpc-schema.ts +36 -0
- package/dist/cf-worker/cf-types.d.ts +0 -2
- package/dist/cf-worker/cf-types.d.ts.map +0 -1
- package/dist/cf-worker/cf-types.js +0 -2
- package/dist/cf-worker/cf-types.js.map +0 -1
- package/dist/cf-worker/durable-object.d.ts.map +0 -1
- package/dist/cf-worker/durable-object.js +0 -317
- package/dist/cf-worker/durable-object.js.map +0 -1
- package/dist/common/ws-message-types.d.ts.map +0 -1
- package/dist/common/ws-message-types.js +0 -57
- package/dist/common/ws-message-types.js.map +0 -1
- package/dist/sync-impl/mod.d.ts +0 -2
- package/dist/sync-impl/mod.d.ts.map +0 -1
- package/dist/sync-impl/mod.js +0 -2
- package/dist/sync-impl/mod.js.map +0 -1
- package/dist/sync-impl/ws-impl.d.ts +0 -7
- package/dist/sync-impl/ws-impl.d.ts.map +0 -1
- package/dist/sync-impl/ws-impl.js +0 -175
- package/dist/sync-impl/ws-impl.js.map +0 -1
- package/src/cf-worker/cf-types.ts +0 -12
- package/src/cf-worker/durable-object.ts +0 -478
- package/src/common/ws-message-types.ts +0 -114
- package/src/sync-impl/mod.ts +0 -1
- package/src/sync-impl/ws-impl.ts +0 -274
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { InvalidPullError, InvalidPushError, UnexpectedError } from '@livestore/common';
|
|
2
|
+
import { Rpc, RpcGroup, Schema } from '@livestore/utils/effect';
|
|
3
|
+
declare const SyncHttpRpc_base: RpcGroup.RpcGroup<Rpc.Rpc<"SyncHttpRpc.Pull", Schema.Struct<{
|
|
4
|
+
cursor: Schema.Option<Schema.Struct<{
|
|
5
|
+
backendId: Schema.SchemaClass<string, string, never>;
|
|
6
|
+
eventSequenceNumber: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
7
|
+
}>>;
|
|
8
|
+
storeId: typeof Schema.String;
|
|
9
|
+
payload: Schema.optional<Schema.Schema<Schema.JsonValue, Schema.JsonValue, never>>;
|
|
10
|
+
}>, import("@effect/rpc/RpcSchema").Stream<Schema.Struct<{
|
|
11
|
+
batch: Schema.Array$<Schema.Struct<{
|
|
12
|
+
eventEncoded: Schema.Struct<{
|
|
13
|
+
name: typeof Schema.String;
|
|
14
|
+
args: typeof Schema.Any;
|
|
15
|
+
seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
16
|
+
parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
17
|
+
clientId: typeof Schema.String;
|
|
18
|
+
sessionId: typeof Schema.String;
|
|
19
|
+
}>;
|
|
20
|
+
metadata: Schema.Option<Schema.Struct<{
|
|
21
|
+
_tag: Schema.tag<"SyncMessage.SyncMetadata">;
|
|
22
|
+
} & {
|
|
23
|
+
createdAt: typeof Schema.String;
|
|
24
|
+
}>>;
|
|
25
|
+
}>>;
|
|
26
|
+
pageInfo: Schema.Union<[Schema.TaggedStruct<"MoreUnknown", {}>, Schema.TaggedStruct<"MoreKnown", {
|
|
27
|
+
remaining: typeof Schema.Number;
|
|
28
|
+
}>, Schema.TaggedStruct<"NoMore", {}>]>;
|
|
29
|
+
backendId: Schema.SchemaClass<string, string, never>;
|
|
30
|
+
}>, typeof InvalidPullError>, typeof Schema.Never, never> | Rpc.Rpc<"SyncHttpRpc.Push", Schema.Struct<{
|
|
31
|
+
batch: Schema.Array$<Schema.Struct<{
|
|
32
|
+
name: typeof Schema.String;
|
|
33
|
+
args: typeof Schema.Any;
|
|
34
|
+
seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
35
|
+
parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
36
|
+
clientId: typeof Schema.String;
|
|
37
|
+
sessionId: typeof Schema.String;
|
|
38
|
+
}>>;
|
|
39
|
+
backendId: Schema.Option<Schema.SchemaClass<string, string, never>>;
|
|
40
|
+
storeId: typeof Schema.String;
|
|
41
|
+
payload: Schema.optional<Schema.Schema<Schema.JsonValue, Schema.JsonValue, never>>;
|
|
42
|
+
}>, Schema.Struct<{}>, typeof InvalidPushError, never> | Rpc.Rpc<"SyncHttpRpc.Ping", Schema.Struct<{
|
|
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 UnexpectedError, never>>;
|
|
48
|
+
/**
|
|
49
|
+
* HTTP RPC Schema for LiveStore CF Sync Provider
|
|
50
|
+
*
|
|
51
|
+
* This defines the RPC endpoints available over HTTP transport.
|
|
52
|
+
* Unlike WebSocket transport which maintains persistent connections,
|
|
53
|
+
* HTTP transport uses request/response patterns for each operation.
|
|
54
|
+
*/
|
|
55
|
+
export declare class SyncHttpRpc extends SyncHttpRpc_base {
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=http-rpc-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-rpc-schema.d.ts","sourceRoot":"","sources":["../../src/common/http-rpc-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACvF,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG/D;;;;;;GAMG;AACH,qBAAa,WAAY,SAAQ,gBA4BhC;CAAG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { InvalidPullError, InvalidPushError, UnexpectedError } from '@livestore/common';
|
|
2
|
+
import { Rpc, RpcGroup, Schema } from '@livestore/utils/effect';
|
|
3
|
+
import * as SyncMessage from "./sync-message-types.js";
|
|
4
|
+
/**
|
|
5
|
+
* HTTP RPC Schema for LiveStore CF Sync Provider
|
|
6
|
+
*
|
|
7
|
+
* This defines the RPC endpoints available over HTTP transport.
|
|
8
|
+
* Unlike WebSocket transport which maintains persistent connections,
|
|
9
|
+
* HTTP transport uses request/response patterns for each operation.
|
|
10
|
+
*/
|
|
11
|
+
export class SyncHttpRpc extends RpcGroup.make(Rpc.make('SyncHttpRpc.Pull', {
|
|
12
|
+
payload: Schema.Struct({
|
|
13
|
+
storeId: Schema.String,
|
|
14
|
+
payload: Schema.optional(Schema.JsonValue),
|
|
15
|
+
...SyncMessage.PullRequest.fields,
|
|
16
|
+
}),
|
|
17
|
+
success: SyncMessage.PullResponse,
|
|
18
|
+
error: InvalidPullError,
|
|
19
|
+
stream: true,
|
|
20
|
+
}), Rpc.make('SyncHttpRpc.Push', {
|
|
21
|
+
payload: Schema.Struct({
|
|
22
|
+
storeId: Schema.String,
|
|
23
|
+
payload: Schema.optional(Schema.JsonValue),
|
|
24
|
+
...SyncMessage.PushRequest.fields,
|
|
25
|
+
}),
|
|
26
|
+
success: SyncMessage.PushAck,
|
|
27
|
+
error: InvalidPushError,
|
|
28
|
+
}), Rpc.make('SyncHttpRpc.Ping', {
|
|
29
|
+
payload: Schema.Struct({
|
|
30
|
+
storeId: Schema.String,
|
|
31
|
+
payload: Schema.optional(Schema.JsonValue),
|
|
32
|
+
}),
|
|
33
|
+
success: SyncMessage.Pong,
|
|
34
|
+
error: UnexpectedError,
|
|
35
|
+
})) {
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=http-rpc-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-rpc-schema.js","sourceRoot":"","sources":["../../src/common/http-rpc-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACvF,OAAO,EAAE,G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
1
2
|
import { Schema } from '@livestore/utils/effect';
|
|
2
|
-
export
|
|
3
|
+
export type { CfTypes } from '@livestore/common-cf';
|
|
4
|
+
export * from './constants.ts';
|
|
5
|
+
export { SyncHttpRpc } from './http-rpc-schema.ts';
|
|
6
|
+
export * as SyncMessage from './sync-message-types.ts';
|
|
7
|
+
export { OversizeChunkItemError, splitChunkBySize };
|
|
3
8
|
export declare const SearchParamsSchema: Schema.Struct<{
|
|
4
9
|
storeId: typeof Schema.String;
|
|
5
10
|
payload: Schema.UndefinedOr<Schema.transform<Schema.transformOrFail<Schema.SchemaClass<string, string, never>, typeof Schema.String, never>, Schema.transform<Schema.SchemaClass<unknown, string, never>, Schema.Schema<Schema.JsonValue, Schema.JsonValue, never>>>>;
|
|
11
|
+
transport: Schema.Union<[Schema.Literal<["http"]>, Schema.Literal<["ws"]>]>;
|
|
6
12
|
}>;
|
|
13
|
+
export type SearchParams = typeof SearchParamsSchema.Type;
|
|
7
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,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,OAAO,KAAK,
|
|
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,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,CAAA;AAEnD,eAAO,MAAM,kBAAkB;;;;EAK7B,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAA"}
|
package/dist/common/mod.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { OversizeChunkItemError, splitChunkBySize } from '@livestore/common/sync';
|
|
1
2
|
import { Schema } from '@livestore/utils/effect';
|
|
2
|
-
export *
|
|
3
|
+
export * from "./constants.js";
|
|
4
|
+
export { SyncHttpRpc } from "./http-rpc-schema.js";
|
|
5
|
+
export * as SyncMessage from "./sync-message-types.js";
|
|
6
|
+
export { OversizeChunkItemError, splitChunkBySize };
|
|
3
7
|
export const SearchParamsSchema = Schema.Struct({
|
|
4
8
|
storeId: Schema.String,
|
|
5
9
|
payload: Schema.compose(Schema.StringFromUriComponent, Schema.parseJson(Schema.JsonValue)).pipe(Schema.UndefinedOr),
|
|
10
|
+
// NOTE `do-rpc` is handled differently
|
|
11
|
+
transport: Schema.Union(Schema.Literal('http'), Schema.Literal('ws')),
|
|
6
12
|
});
|
|
7
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,MAAM,EAAE,MAAM,yBAAyB,CAAA;
|
|
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,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,CAAA;AAEnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;IACnH,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;CACtE,CAAC,CAAA"}
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { Schema } from '@livestore/utils/effect';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
cursor: Schema.optional<typeof Schema.Number>;
|
|
8
|
-
}>;
|
|
9
|
-
export type PullReq = typeof PullReq.Type;
|
|
2
|
+
/**
|
|
3
|
+
* Common sync message types shared between different transport modes (WS, HTTP, RPC)
|
|
4
|
+
*
|
|
5
|
+
* These are the canonical message definitions used across all transport implementations.
|
|
6
|
+
*/
|
|
10
7
|
export declare const SyncMetadata: Schema.Struct<{
|
|
8
|
+
_tag: Schema.tag<"SyncMessage.SyncMetadata">;
|
|
9
|
+
} & {
|
|
11
10
|
/** ISO date format */
|
|
12
11
|
createdAt: typeof Schema.String;
|
|
13
12
|
}>;
|
|
14
13
|
export type SyncMetadata = typeof SyncMetadata.Type;
|
|
15
|
-
export declare const
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
export declare const PullRequest: Schema.Struct<{
|
|
15
|
+
/** Omitting the cursor will start from the beginning */
|
|
16
|
+
cursor: Schema.Option<Schema.Struct<{
|
|
17
|
+
backendId: Schema.SchemaClass<string, string, never>;
|
|
18
|
+
eventSequenceNumber: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
19
|
+
}>>;
|
|
20
|
+
}>;
|
|
21
|
+
export type PullRequest = typeof PullRequest.Type;
|
|
22
|
+
export declare const PullResponse: Schema.Struct<{
|
|
18
23
|
batch: Schema.Array$<Schema.Struct<{
|
|
19
24
|
eventEncoded: Schema.Struct<{
|
|
20
25
|
name: typeof Schema.String;
|
|
@@ -25,21 +30,44 @@ export declare const PullRes: Schema.Struct<{
|
|
|
25
30
|
sessionId: typeof Schema.String;
|
|
26
31
|
}>;
|
|
27
32
|
metadata: Schema.Option<Schema.Struct<{
|
|
33
|
+
_tag: Schema.tag<"SyncMessage.SyncMetadata">;
|
|
34
|
+
} & {
|
|
28
35
|
/** ISO date format */
|
|
29
36
|
createdAt: typeof Schema.String;
|
|
30
37
|
}>>;
|
|
31
38
|
}>>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
remaining: typeof Schema.Number;
|
|
39
|
+
pageInfo: Schema.Union<[Schema.TaggedStruct<"MoreUnknown", {}>, Schema.TaggedStruct<"MoreKnown", {
|
|
40
|
+
remaining: typeof Schema.Number;
|
|
41
|
+
}>, Schema.TaggedStruct<"NoMore", {}>]>;
|
|
42
|
+
backendId: Schema.SchemaClass<string, string, never>;
|
|
37
43
|
}>;
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
export declare const emptyPullResponse: (backendId: string) => {
|
|
45
|
+
readonly backendId: string;
|
|
46
|
+
readonly batch: readonly {
|
|
47
|
+
readonly metadata: import("effect/Option").Option<{
|
|
48
|
+
readonly createdAt: string;
|
|
49
|
+
readonly _tag: "SyncMessage.SyncMetadata";
|
|
50
|
+
}>;
|
|
51
|
+
readonly eventEncoded: {
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly args: any;
|
|
54
|
+
readonly seqNum: any;
|
|
55
|
+
readonly parentSeqNum: any;
|
|
56
|
+
readonly clientId: string;
|
|
57
|
+
readonly sessionId: string;
|
|
58
|
+
};
|
|
59
|
+
}[];
|
|
60
|
+
readonly pageInfo: {
|
|
61
|
+
readonly _tag: "MoreUnknown";
|
|
62
|
+
} | {
|
|
63
|
+
readonly _tag: "MoreKnown";
|
|
64
|
+
readonly remaining: number;
|
|
65
|
+
} | {
|
|
66
|
+
readonly _tag: "NoMore";
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export type PullResponse = typeof PullResponse.Type;
|
|
70
|
+
export declare const PushRequest: Schema.Struct<{
|
|
43
71
|
batch: Schema.Array$<Schema.Struct<{
|
|
44
72
|
name: typeof Schema.String;
|
|
45
73
|
args: typeof Schema.Any;
|
|
@@ -48,71 +76,44 @@ export declare const PushReq: Schema.Struct<{
|
|
|
48
76
|
clientId: typeof Schema.String;
|
|
49
77
|
sessionId: typeof Schema.String;
|
|
50
78
|
}>>;
|
|
79
|
+
backendId: Schema.Option<Schema.SchemaClass<string, string, never>>;
|
|
51
80
|
}>;
|
|
52
|
-
export type
|
|
53
|
-
export declare const PushAck: Schema.Struct<{
|
|
54
|
-
_tag: Schema.tag<"WSMessage.PushAck">;
|
|
55
|
-
} & {
|
|
56
|
-
requestId: typeof Schema.String;
|
|
57
|
-
}>;
|
|
81
|
+
export type PushRequest = typeof PushRequest.Type;
|
|
82
|
+
export declare const PushAck: Schema.Struct<{}>;
|
|
58
83
|
export type PushAck = typeof PushAck.Type;
|
|
59
|
-
export declare const Error: Schema.Struct<{
|
|
60
|
-
_tag: Schema.tag<"WSMessage.Error">;
|
|
61
|
-
} & {
|
|
62
|
-
requestId: typeof Schema.String;
|
|
63
|
-
message: typeof Schema.String;
|
|
64
|
-
}>;
|
|
65
|
-
export type Error = typeof Error.Type;
|
|
66
84
|
export declare const Ping: Schema.Struct<{
|
|
67
|
-
_tag: Schema.tag<"
|
|
68
|
-
} & {
|
|
69
|
-
requestId: Schema.Literal<["ping"]>;
|
|
85
|
+
_tag: Schema.tag<"SyncMessage.Ping">;
|
|
70
86
|
}>;
|
|
71
87
|
export type Ping = typeof Ping.Type;
|
|
72
88
|
export declare const Pong: Schema.Struct<{
|
|
73
|
-
_tag: Schema.tag<"
|
|
74
|
-
} & {
|
|
75
|
-
requestId: Schema.Literal<["ping"]>;
|
|
89
|
+
_tag: Schema.tag<"SyncMessage.Pong">;
|
|
76
90
|
}>;
|
|
77
91
|
export type Pong = typeof Pong.Type;
|
|
78
|
-
export declare const
|
|
79
|
-
_tag: Schema.tag<"
|
|
92
|
+
export declare const AdminResetRoomRequest: Schema.Struct<{
|
|
93
|
+
_tag: Schema.tag<"SyncMessage.AdminResetRoomRequest">;
|
|
80
94
|
} & {
|
|
81
|
-
requestId: typeof Schema.String;
|
|
82
95
|
adminSecret: typeof Schema.String;
|
|
83
96
|
}>;
|
|
84
|
-
export type
|
|
85
|
-
export declare const
|
|
86
|
-
_tag: Schema.tag<"
|
|
87
|
-
} & {
|
|
88
|
-
requestId: typeof Schema.String;
|
|
97
|
+
export type AdminResetRoomRequest = typeof AdminResetRoomRequest.Type;
|
|
98
|
+
export declare const AdminResetRoomResponse: Schema.Struct<{
|
|
99
|
+
_tag: Schema.tag<"SyncMessage.AdminResetRoomResponse">;
|
|
89
100
|
}>;
|
|
90
|
-
export type
|
|
91
|
-
export declare const
|
|
92
|
-
_tag: Schema.tag<"
|
|
101
|
+
export type AdminResetRoomResponse = typeof AdminResetRoomResponse.Type;
|
|
102
|
+
export declare const AdminInfoRequest: Schema.Struct<{
|
|
103
|
+
_tag: Schema.tag<"SyncMessage.AdminInfoRequest">;
|
|
93
104
|
} & {
|
|
94
|
-
requestId: typeof Schema.String;
|
|
95
105
|
adminSecret: typeof Schema.String;
|
|
96
106
|
}>;
|
|
97
|
-
export type
|
|
98
|
-
export declare const
|
|
99
|
-
_tag: Schema.tag<"
|
|
107
|
+
export type AdminInfoRequest = typeof AdminInfoRequest.Type;
|
|
108
|
+
export declare const AdminInfoResponse: Schema.Struct<{
|
|
109
|
+
_tag: Schema.tag<"SyncMessage.AdminInfoResponse">;
|
|
100
110
|
} & {
|
|
101
|
-
requestId: typeof Schema.String;
|
|
102
111
|
info: Schema.Struct<{
|
|
103
112
|
durableObjectId: typeof Schema.String;
|
|
104
113
|
}>;
|
|
105
114
|
}>;
|
|
106
|
-
export type
|
|
107
|
-
export declare const
|
|
108
|
-
_tag: Schema.tag<"WSMessage.PullReq">;
|
|
109
|
-
} & {
|
|
110
|
-
requestId: typeof Schema.String;
|
|
111
|
-
/** Omitting the cursor will start from the beginning */
|
|
112
|
-
cursor: Schema.optional<typeof Schema.Number>;
|
|
113
|
-
}>, Schema.Struct<{
|
|
114
|
-
_tag: Schema.tag<"WSMessage.PullRes">;
|
|
115
|
-
} & {
|
|
115
|
+
export type AdminInfoResponse = typeof AdminInfoResponse.Type;
|
|
116
|
+
export declare const BackendToClientMessage: Schema.Union<[Schema.Struct<{
|
|
116
117
|
batch: Schema.Array$<Schema.Struct<{
|
|
117
118
|
eventEncoded: Schema.Struct<{
|
|
118
119
|
name: typeof Schema.String;
|
|
@@ -123,19 +124,35 @@ export declare const Message: Schema.Union<[Schema.Struct<{
|
|
|
123
124
|
sessionId: typeof Schema.String;
|
|
124
125
|
}>;
|
|
125
126
|
metadata: Schema.Option<Schema.Struct<{
|
|
127
|
+
_tag: Schema.tag<"SyncMessage.SyncMetadata">;
|
|
128
|
+
} & {
|
|
126
129
|
/** ISO date format */
|
|
127
130
|
createdAt: typeof Schema.String;
|
|
128
131
|
}>>;
|
|
129
132
|
}>>;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
pageInfo: Schema.Union<[Schema.TaggedStruct<"MoreUnknown", {}>, Schema.TaggedStruct<"MoreKnown", {
|
|
134
|
+
remaining: typeof Schema.Number;
|
|
135
|
+
}>, Schema.TaggedStruct<"NoMore", {}>]>;
|
|
136
|
+
backendId: Schema.SchemaClass<string, string, never>;
|
|
137
|
+
}>, Schema.Struct<{}>, Schema.Struct<{
|
|
138
|
+
_tag: Schema.tag<"SyncMessage.Pong">;
|
|
139
|
+
}>, Schema.Struct<{
|
|
140
|
+
_tag: Schema.tag<"SyncMessage.AdminResetRoomResponse">;
|
|
135
141
|
}>, Schema.Struct<{
|
|
136
|
-
_tag: Schema.tag<"
|
|
142
|
+
_tag: Schema.tag<"SyncMessage.AdminInfoResponse">;
|
|
137
143
|
} & {
|
|
138
|
-
|
|
144
|
+
info: Schema.Struct<{
|
|
145
|
+
durableObjectId: typeof Schema.String;
|
|
146
|
+
}>;
|
|
147
|
+
}>]>;
|
|
148
|
+
export type BackendToClientMessage = typeof BackendToClientMessage.Type;
|
|
149
|
+
export declare const ClientToBackendMessage: Schema.Union<[Schema.Struct<{
|
|
150
|
+
/** Omitting the cursor will start from the beginning */
|
|
151
|
+
cursor: Schema.Option<Schema.Struct<{
|
|
152
|
+
backendId: Schema.SchemaClass<string, string, never>;
|
|
153
|
+
eventSequenceNumber: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
154
|
+
}>>;
|
|
155
|
+
}>, Schema.Struct<{
|
|
139
156
|
batch: Schema.Array$<Schema.Struct<{
|
|
140
157
|
name: typeof Schema.String;
|
|
141
158
|
args: typeof Schema.Any;
|
|
@@ -144,50 +161,20 @@ export declare const Message: Schema.Union<[Schema.Struct<{
|
|
|
144
161
|
clientId: typeof Schema.String;
|
|
145
162
|
sessionId: typeof Schema.String;
|
|
146
163
|
}>>;
|
|
164
|
+
backendId: Schema.Option<Schema.SchemaClass<string, string, never>>;
|
|
147
165
|
}>, Schema.Struct<{
|
|
148
|
-
_tag: Schema.tag<"
|
|
149
|
-
} & {
|
|
150
|
-
requestId: typeof Schema.String;
|
|
151
|
-
}>, Schema.Struct<{
|
|
152
|
-
_tag: Schema.tag<"WSMessage.Error">;
|
|
153
|
-
} & {
|
|
154
|
-
requestId: typeof Schema.String;
|
|
155
|
-
message: typeof Schema.String;
|
|
156
|
-
}>, Schema.Struct<{
|
|
157
|
-
_tag: Schema.tag<"WSMessage.Ping">;
|
|
158
|
-
} & {
|
|
159
|
-
requestId: Schema.Literal<["ping"]>;
|
|
160
|
-
}>, Schema.Struct<{
|
|
161
|
-
_tag: Schema.tag<"WSMessage.Pong">;
|
|
162
|
-
} & {
|
|
163
|
-
requestId: Schema.Literal<["ping"]>;
|
|
166
|
+
_tag: Schema.tag<"SyncMessage.Ping">;
|
|
164
167
|
}>, Schema.Struct<{
|
|
165
|
-
_tag: Schema.tag<"
|
|
168
|
+
_tag: Schema.tag<"SyncMessage.AdminResetRoomRequest">;
|
|
166
169
|
} & {
|
|
167
|
-
requestId: typeof Schema.String;
|
|
168
170
|
adminSecret: typeof Schema.String;
|
|
169
171
|
}>, Schema.Struct<{
|
|
170
|
-
_tag: Schema.tag<"
|
|
172
|
+
_tag: Schema.tag<"SyncMessage.AdminInfoRequest">;
|
|
171
173
|
} & {
|
|
172
|
-
requestId: typeof Schema.String;
|
|
173
|
-
}>, Schema.Struct<{
|
|
174
|
-
_tag: Schema.tag<"WSMessage.AdminInfoReq">;
|
|
175
|
-
} & {
|
|
176
|
-
requestId: typeof Schema.String;
|
|
177
174
|
adminSecret: typeof Schema.String;
|
|
178
|
-
}>, Schema.Struct<{
|
|
179
|
-
_tag: Schema.tag<"WSMessage.AdminInfoRes">;
|
|
180
|
-
} & {
|
|
181
|
-
requestId: typeof Schema.String;
|
|
182
|
-
info: Schema.Struct<{
|
|
183
|
-
durableObjectId: typeof Schema.String;
|
|
184
|
-
}>;
|
|
185
175
|
}>]>;
|
|
186
|
-
export type
|
|
187
|
-
export
|
|
188
|
-
export declare const BackendToClientMessage: Schema.Union<[Schema.Struct<{
|
|
189
|
-
_tag: Schema.tag<"WSMessage.PullRes">;
|
|
190
|
-
} & {
|
|
176
|
+
export type ClientToBackendMessage = typeof ClientToBackendMessage.Type;
|
|
177
|
+
export declare const Message: Schema.Union<[Schema.Union<[Schema.Struct<{
|
|
191
178
|
batch: Schema.Array$<Schema.Struct<{
|
|
192
179
|
eventEncoded: Schema.Struct<{
|
|
193
180
|
name: typeof Schema.String;
|
|
@@ -198,51 +185,33 @@ export declare const BackendToClientMessage: Schema.Union<[Schema.Struct<{
|
|
|
198
185
|
sessionId: typeof Schema.String;
|
|
199
186
|
}>;
|
|
200
187
|
metadata: Schema.Option<Schema.Struct<{
|
|
188
|
+
_tag: Schema.tag<"SyncMessage.SyncMetadata">;
|
|
189
|
+
} & {
|
|
201
190
|
/** ISO date format */
|
|
202
191
|
createdAt: typeof Schema.String;
|
|
203
192
|
}>>;
|
|
204
193
|
}>>;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
_tag: Schema.tag<"WSMessage.PushAck">;
|
|
212
|
-
} & {
|
|
213
|
-
requestId: typeof Schema.String;
|
|
194
|
+
pageInfo: Schema.Union<[Schema.TaggedStruct<"MoreUnknown", {}>, Schema.TaggedStruct<"MoreKnown", {
|
|
195
|
+
remaining: typeof Schema.Number;
|
|
196
|
+
}>, Schema.TaggedStruct<"NoMore", {}>]>;
|
|
197
|
+
backendId: Schema.SchemaClass<string, string, never>;
|
|
198
|
+
}>, Schema.Struct<{}>, Schema.Struct<{
|
|
199
|
+
_tag: Schema.tag<"SyncMessage.Pong">;
|
|
214
200
|
}>, Schema.Struct<{
|
|
215
|
-
_tag: Schema.tag<"
|
|
216
|
-
} & {
|
|
217
|
-
requestId: typeof Schema.String;
|
|
201
|
+
_tag: Schema.tag<"SyncMessage.AdminResetRoomResponse">;
|
|
218
202
|
}>, Schema.Struct<{
|
|
219
|
-
_tag: Schema.tag<"
|
|
203
|
+
_tag: Schema.tag<"SyncMessage.AdminInfoResponse">;
|
|
220
204
|
} & {
|
|
221
|
-
requestId: typeof Schema.String;
|
|
222
205
|
info: Schema.Struct<{
|
|
223
206
|
durableObjectId: typeof Schema.String;
|
|
224
207
|
}>;
|
|
225
|
-
}>, Schema.Struct<{
|
|
226
|
-
_tag: Schema.tag<"WSMessage.Error">;
|
|
227
|
-
} & {
|
|
228
|
-
requestId: typeof Schema.String;
|
|
229
|
-
message: typeof Schema.String;
|
|
230
|
-
}>, Schema.Struct<{
|
|
231
|
-
_tag: Schema.tag<"WSMessage.Pong">;
|
|
232
|
-
} & {
|
|
233
|
-
requestId: Schema.Literal<["ping"]>;
|
|
234
|
-
}>]>;
|
|
235
|
-
export type BackendToClientMessage = typeof BackendToClientMessage.Type;
|
|
236
|
-
export declare const ClientToBackendMessage: Schema.Union<[Schema.Struct<{
|
|
237
|
-
_tag: Schema.tag<"WSMessage.PullReq">;
|
|
238
|
-
} & {
|
|
239
|
-
requestId: typeof Schema.String;
|
|
208
|
+
}>]>, Schema.Union<[Schema.Struct<{
|
|
240
209
|
/** Omitting the cursor will start from the beginning */
|
|
241
|
-
cursor: Schema.
|
|
210
|
+
cursor: Schema.Option<Schema.Struct<{
|
|
211
|
+
backendId: Schema.SchemaClass<string, string, never>;
|
|
212
|
+
eventSequenceNumber: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
213
|
+
}>>;
|
|
242
214
|
}>, Schema.Struct<{
|
|
243
|
-
_tag: Schema.tag<"WSMessage.PushReq">;
|
|
244
|
-
} & {
|
|
245
|
-
requestId: typeof Schema.String;
|
|
246
215
|
batch: Schema.Array$<Schema.Struct<{
|
|
247
216
|
name: typeof Schema.String;
|
|
248
217
|
args: typeof Schema.Any;
|
|
@@ -251,20 +220,17 @@ export declare const ClientToBackendMessage: Schema.Union<[Schema.Struct<{
|
|
|
251
220
|
clientId: typeof Schema.String;
|
|
252
221
|
sessionId: typeof Schema.String;
|
|
253
222
|
}>>;
|
|
223
|
+
backendId: Schema.Option<Schema.SchemaClass<string, string, never>>;
|
|
254
224
|
}>, Schema.Struct<{
|
|
255
|
-
_tag: Schema.tag<"
|
|
256
|
-
} & {
|
|
257
|
-
requestId: typeof Schema.String;
|
|
258
|
-
adminSecret: typeof Schema.String;
|
|
225
|
+
_tag: Schema.tag<"SyncMessage.Ping">;
|
|
259
226
|
}>, Schema.Struct<{
|
|
260
|
-
_tag: Schema.tag<"
|
|
227
|
+
_tag: Schema.tag<"SyncMessage.AdminResetRoomRequest">;
|
|
261
228
|
} & {
|
|
262
|
-
requestId: typeof Schema.String;
|
|
263
229
|
adminSecret: typeof Schema.String;
|
|
264
230
|
}>, Schema.Struct<{
|
|
265
|
-
_tag: Schema.tag<"
|
|
231
|
+
_tag: Schema.tag<"SyncMessage.AdminInfoRequest">;
|
|
266
232
|
} & {
|
|
267
|
-
|
|
268
|
-
}>]>;
|
|
269
|
-
export type
|
|
270
|
-
//# sourceMappingURL=
|
|
233
|
+
adminSecret: typeof Schema.String;
|
|
234
|
+
}>]>]>;
|
|
235
|
+
export type Message = typeof Message.Type;
|
|
236
|
+
//# sourceMappingURL=sync-message-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-message-types.d.ts","sourceRoot":"","sources":["../../src/common/sync-message-types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD;;;;GAIG;AAEH,eAAO,MAAM,YAAY;;;IACvB,sBAAsB;;EAEoC,CAAA;AAE5D,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAEnD,eAAO,MAAM,WAAW;IACtB,wDAAwD;;;;;EAOC,CAAA;AAE3D,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA;AAEjD,eAAO,MAAM,YAAY;;;;;;;;;;;;;YAlBvB,sBAAsB;;;;;;;;EA2BoC,CAAA;AAE5D,eAAO,MAAM,iBAAiB,GAAI,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;CAK/C,CAAA;AAEJ,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAEnD,eAAO,MAAM,WAAW;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;;;;;;;;;;;;;;;;;;;;MAiGyB,CAAA;AACnF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { BackendId, SyncBackend } from '@livestore/common';
|
|
2
|
+
import { EventSequenceNumber, LiveStoreEvent } from '@livestore/common/schema';
|
|
3
|
+
import { Schema } from '@livestore/utils/effect';
|
|
4
|
+
/**
|
|
5
|
+
* Common sync message types shared between different transport modes (WS, HTTP, RPC)
|
|
6
|
+
*
|
|
7
|
+
* These are the canonical message definitions used across all transport implementations.
|
|
8
|
+
*/
|
|
9
|
+
export const SyncMetadata = Schema.TaggedStruct('SyncMessage.SyncMetadata', {
|
|
10
|
+
/** ISO date format */
|
|
11
|
+
createdAt: Schema.String,
|
|
12
|
+
}).annotations({ title: '@livestore/sync-cf:SyncMetadata' });
|
|
13
|
+
export const PullRequest = Schema.Struct({
|
|
14
|
+
/** Omitting the cursor will start from the beginning */
|
|
15
|
+
cursor: Schema.Option(Schema.Struct({
|
|
16
|
+
backendId: BackendId,
|
|
17
|
+
eventSequenceNumber: EventSequenceNumber.GlobalEventSequenceNumber,
|
|
18
|
+
})),
|
|
19
|
+
}).annotations({ title: '@livestore/sync-cf:PullRequest' });
|
|
20
|
+
export const PullResponse = Schema.Struct({
|
|
21
|
+
batch: Schema.Array(Schema.Struct({
|
|
22
|
+
eventEncoded: LiveStoreEvent.AnyEncodedGlobal,
|
|
23
|
+
metadata: Schema.Option(SyncMetadata),
|
|
24
|
+
})),
|
|
25
|
+
pageInfo: SyncBackend.PullResPageInfo,
|
|
26
|
+
backendId: BackendId,
|
|
27
|
+
}).annotations({ title: '@livestore/sync-cf:PullResponse' });
|
|
28
|
+
export const emptyPullResponse = (backendId) => PullResponse.make({
|
|
29
|
+
batch: [],
|
|
30
|
+
pageInfo: SyncBackend.pageInfoNoMore,
|
|
31
|
+
backendId,
|
|
32
|
+
});
|
|
33
|
+
export const PushRequest = Schema.Struct({
|
|
34
|
+
batch: Schema.Array(LiveStoreEvent.AnyEncodedGlobal),
|
|
35
|
+
backendId: Schema.Option(BackendId),
|
|
36
|
+
}).annotations({ title: '@livestore/sync-cf:PushRequest' });
|
|
37
|
+
export const PushAck = Schema.Struct({}).annotations({
|
|
38
|
+
title: '@livestore/sync-cf:PushAck',
|
|
39
|
+
});
|
|
40
|
+
export const Ping = Schema.TaggedStruct('SyncMessage.Ping', {}).annotations({ title: '@livestore/sync-cf:Ping' });
|
|
41
|
+
export const Pong = Schema.TaggedStruct('SyncMessage.Pong', {}).annotations({ title: '@livestore/sync-cf:Pong' });
|
|
42
|
+
// Admin operations
|
|
43
|
+
export const AdminResetRoomRequest = Schema.TaggedStruct('SyncMessage.AdminResetRoomRequest', {
|
|
44
|
+
adminSecret: Schema.String,
|
|
45
|
+
}).annotations({ title: '@livestore/sync-cf:AdminResetRoomRequest' });
|
|
46
|
+
export const AdminResetRoomResponse = Schema.TaggedStruct('SyncMessage.AdminResetRoomResponse', {}).annotations({
|
|
47
|
+
title: '@livestore/sync-cf:AdminResetRoomResponse',
|
|
48
|
+
});
|
|
49
|
+
export const AdminInfoRequest = Schema.TaggedStruct('SyncMessage.AdminInfoRequest', {
|
|
50
|
+
adminSecret: Schema.String,
|
|
51
|
+
}).annotations({ title: '@livestore/sync-cf:AdminInfoRequest' });
|
|
52
|
+
export const AdminInfoResponse = Schema.TaggedStruct('SyncMessage.AdminInfoResponse', {
|
|
53
|
+
info: Schema.Struct({
|
|
54
|
+
durableObjectId: Schema.String,
|
|
55
|
+
}),
|
|
56
|
+
}).annotations({ title: '@livestore/sync-cf:AdminInfoResponse' });
|
|
57
|
+
export const BackendToClientMessage = Schema.Union(PullResponse, PushAck, Pong, AdminResetRoomResponse, AdminInfoResponse);
|
|
58
|
+
export const ClientToBackendMessage = Schema.Union(PullRequest, PushRequest, Ping, AdminResetRoomRequest, AdminInfoRequest);
|
|
59
|
+
export const Message = Schema.Union(BackendToClientMessage, ClientToBackendMessage);
|
|
60
|
+
//# sourceMappingURL=sync-message-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-message-types.js","sourceRoot":"","sources":["../../src/common/sync-message-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD;;;;GAIG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC,0BAA0B,EAAE;IAC1E,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC,MAAM;CACzB,CAAC,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,iCAAiC,EAAE,CAAC,CAAA;AAI5D,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC,MAAM,CACnB,MAAM,CAAC,MAAM,CAAC;QACZ,SAAS,EAAE,SAAS;QACpB,mBAAmB,EAAE,mBAAmB,CAAC,yBAAyB;KACnE,CAAC,CACH;CACF,CAAC,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,gCAAgC,EAAE,CAAC,CAAA;AAI3D,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC,KAAK,CACjB,MAAM,CAAC,MAAM,CAAC;QACZ,YAAY,EAAE,cAAc,CAAC,gBAAgB;QAC7C,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;KACtC,CAAC,CACH;IACD,QAAQ,EAAE,WAAW,CAAC,eAAe;IACrC,SAAS,EAAE,SAAS;CACrB,CAAC,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,iCAAiC,EAAE,CAAC,CAAA;AAE5D,M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