@livestore/sync-cf 0.3.0-dev.3 → 0.3.0-dev.31

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.
Files changed (51) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cf-worker/durable-object.d.ts +58 -47
  3. package/dist/cf-worker/durable-object.d.ts.map +1 -1
  4. package/dist/cf-worker/durable-object.js +233 -156
  5. package/dist/cf-worker/durable-object.js.map +1 -1
  6. package/dist/cf-worker/mod.d.ts +3 -0
  7. package/dist/cf-worker/mod.d.ts.map +1 -0
  8. package/dist/cf-worker/mod.js +3 -0
  9. package/dist/cf-worker/mod.js.map +1 -0
  10. package/dist/cf-worker/worker.d.ts +12 -0
  11. package/dist/cf-worker/worker.d.ts.map +1 -0
  12. package/dist/cf-worker/worker.js +58 -0
  13. package/dist/cf-worker/worker.js.map +1 -0
  14. package/dist/common/mod.d.ts +7 -0
  15. package/dist/common/mod.d.ts.map +1 -0
  16. package/dist/common/mod.js +7 -0
  17. package/dist/common/mod.js.map +1 -0
  18. package/dist/common/ws-message-types.d.ts +163 -266
  19. package/dist/common/ws-message-types.d.ts.map +1 -1
  20. package/dist/common/ws-message-types.js +19 -24
  21. package/dist/common/ws-message-types.js.map +1 -1
  22. package/dist/sync-impl/mod.d.ts +2 -0
  23. package/dist/sync-impl/mod.d.ts.map +1 -0
  24. package/dist/sync-impl/mod.js +2 -0
  25. package/dist/sync-impl/mod.js.map +1 -0
  26. package/dist/sync-impl/ws-impl.d.ts +3 -15
  27. package/dist/sync-impl/ws-impl.d.ts.map +1 -1
  28. package/dist/sync-impl/ws-impl.js +89 -36
  29. package/dist/sync-impl/ws-impl.js.map +1 -1
  30. package/package.json +15 -13
  31. package/src/cf-worker/durable-object.ts +309 -177
  32. package/src/cf-worker/mod.ts +2 -0
  33. package/src/cf-worker/worker.ts +85 -0
  34. package/src/common/mod.ts +8 -0
  35. package/src/common/ws-message-types.ts +22 -36
  36. package/src/sync-impl/ws-impl.ts +146 -100
  37. package/dist/cf-worker/index.d.ts +0 -8
  38. package/dist/cf-worker/index.d.ts.map +0 -1
  39. package/dist/cf-worker/index.js +0 -67
  40. package/dist/cf-worker/index.js.map +0 -1
  41. package/dist/common/index.d.ts +0 -2
  42. package/dist/common/index.d.ts.map +0 -1
  43. package/dist/common/index.js +0 -2
  44. package/dist/common/index.js.map +0 -1
  45. package/dist/sync-impl/index.d.ts +0 -2
  46. package/dist/sync-impl/index.d.ts.map +0 -1
  47. package/dist/sync-impl/index.js +0 -2
  48. package/dist/sync-impl/index.js.map +0 -1
  49. package/src/cf-worker/index.ts +0 -84
  50. package/src/common/index.ts +0 -1
  51. /package/src/sync-impl/{index.ts → mod.ts} +0 -0
@@ -0,0 +1,3 @@
1
+ export * from './durable-object.js';
2
+ export * from './worker.js';
3
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/cf-worker/mod.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './durable-object.js';
2
+ export * from './worker.js';
3
+ //# sourceMappingURL=mod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/cf-worker/mod.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { Schema } from '@livestore/utils/effect';
2
+ import type { Env } from './durable-object.js';
3
+ export type CFWorker = {
4
+ fetch: (request: Request, env: Env, ctx: ExecutionContext) => Promise<Response>;
5
+ };
6
+ export type MakeWorkerOptions = {
7
+ validatePayload?: (payload: Schema.JsonValue | undefined) => void | Promise<void>;
8
+ /** @default false */
9
+ enableCORS?: boolean;
10
+ };
11
+ export declare const makeWorker: (options?: MakeWorkerOptions) => CFWorker;
12
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/cf-worker/worker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAIrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAE9C,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAChF,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACjF,qBAAqB;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,UAAS,iBAAsB,KAAG,QAmE5D,CAAA"}
@@ -0,0 +1,58 @@
1
+ import { UnexpectedError } from '@livestore/common';
2
+ import { Effect, UrlParams } from '@livestore/utils/effect';
3
+ import { SearchParamsSchema } from '../common/mod.js';
4
+ export const makeWorker = (options = {}) => {
5
+ return {
6
+ fetch: async (request, env, _ctx) => Effect.gen(function* () {
7
+ const url = new URL(request.url);
8
+ const urlParams = UrlParams.fromInput(url.searchParams);
9
+ const paramsResult = yield* UrlParams.schemaStruct(SearchParamsSchema)(urlParams).pipe(Effect.either);
10
+ const corsHeaders = options.enableCORS
11
+ ? {
12
+ 'Access-Control-Allow-Origin': '*',
13
+ 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
14
+ 'Access-Control-Allow-Headers': request.headers.get('Access-Control-Request-Headers') ?? '*',
15
+ }
16
+ : {};
17
+ if (request.method === 'OPTIONS' && options.enableCORS) {
18
+ return new Response(null, {
19
+ status: 204,
20
+ headers: corsHeaders,
21
+ });
22
+ }
23
+ if (paramsResult._tag === 'Left') {
24
+ return new Response(`Invalid search params: ${paramsResult.left.toString()}`, {
25
+ status: 500,
26
+ headers: corsHeaders,
27
+ });
28
+ }
29
+ const { storeId, payload } = paramsResult.right;
30
+ if (options.validatePayload !== undefined) {
31
+ const result = yield* Effect.promise(async () => options.validatePayload(payload)).pipe(UnexpectedError.mapToUnexpectedError, Effect.either);
32
+ if (result._tag === 'Left') {
33
+ console.error('Invalid payload', result.left);
34
+ return new Response(result.left.toString(), { status: 400, headers: corsHeaders });
35
+ }
36
+ }
37
+ const id = env.WEBSOCKET_SERVER.idFromName(storeId);
38
+ const durableObject = env.WEBSOCKET_SERVER.get(id);
39
+ if (url.pathname.endsWith('/websocket')) {
40
+ const upgradeHeader = request.headers.get('Upgrade');
41
+ if (!upgradeHeader || upgradeHeader !== 'websocket') {
42
+ return new Response('Durable Object expected Upgrade: websocket', { status: 426, headers: corsHeaders });
43
+ }
44
+ return durableObject.fetch(request);
45
+ }
46
+ console.error('Invalid path', url.pathname);
47
+ return new Response(null, {
48
+ status: 400,
49
+ statusText: 'Bad Request',
50
+ headers: {
51
+ ...corsHeaders,
52
+ 'Content-Type': 'text/plain',
53
+ },
54
+ });
55
+ }).pipe(Effect.tapCauseLogPretty, Effect.runPromise),
56
+ };
57
+ };
58
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/cf-worker/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAarD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAA6B,EAAE,EAAY,EAAE;IACtE,OAAO;QACL,KAAK,EAAE,KAAK,EAAE,OAAO,EA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AAE,YAAY;iBAC7B;aACF,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,UAAU,CAAC;KACvD,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { Schema } from '@livestore/utils/effect';
2
+ export * as WSMessage from './ws-message-types.js';
3
+ export declare const SearchParamsSchema: Schema.Struct<{
4
+ storeId: typeof Schema.String;
5
+ 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>>>>;
6
+ }>;
7
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +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,SAAS,MAAM,uBAAuB,CAAA;AAElD,eAAO,MAAM,kBAAkB;;;EAG7B,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { Schema } from '@livestore/utils/effect';
2
+ export * as WSMessage from './ws-message-types.js';
3
+ export const SearchParamsSchema = Schema.Struct({
4
+ storeId: Schema.String,
5
+ payload: Schema.compose(Schema.StringFromUriComponent, Schema.parseJson(Schema.JsonValue)).pipe(Schema.UndefinedOr),
6
+ });
7
+ //# sourceMappingURL=mod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/common/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAA;AAElD,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;CACpH,CAAC,CAAA"}
@@ -1,5 +1,7 @@
1
1
  import { Schema } from '@livestore/utils/effect';
2
- export declare const PullReq: Schema.TaggedStruct<"WSMessage.PullReq", {
2
+ export declare const PullReq: Schema.Struct<{
3
+ _tag: Schema.tag<"WSMessage.PullReq">;
4
+ } & {
3
5
  requestId: typeof Schema.String;
4
6
  /** Omitting the cursor will start from the beginning */
5
7
  cursor: Schema.optional<typeof Schema.Number>;
@@ -10,243 +12,172 @@ export declare const SyncMetadata: Schema.Struct<{
10
12
  createdAt: typeof Schema.String;
11
13
  }>;
12
14
  export type SyncMetadata = typeof SyncMetadata.Type;
13
- export declare const PullRes: Schema.TaggedStruct<"WSMessage.PullRes", {
14
- requestId: typeof Schema.String;
15
- events: Schema.Array$<Schema.Struct<{
16
- mutationEventEncoded: Schema.SchemaClass<{
17
- readonly id: {
18
- readonly global: number;
19
- readonly local: number;
20
- };
21
- readonly mutation: string;
22
- readonly args: any;
23
- readonly parentId: {
24
- readonly global: number;
25
- readonly local: number;
26
- };
27
- }, {
28
- readonly id: {
29
- readonly global: number;
30
- readonly local: number;
31
- };
32
- readonly mutation: string;
33
- readonly args: any;
34
- readonly parentId: {
35
- readonly global: number;
36
- readonly local: number;
37
- };
38
- }, never>;
15
+ export declare const PullRes: Schema.Struct<{
16
+ _tag: Schema.tag<"WSMessage.PullRes">;
17
+ } & {
18
+ batch: Schema.Array$<Schema.Struct<{
19
+ eventEncoded: Schema.Struct<{
20
+ name: typeof Schema.String;
21
+ args: typeof Schema.Any;
22
+ id: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
23
+ parentId: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
24
+ clientId: typeof Schema.String;
25
+ sessionId: typeof Schema.String;
26
+ }>;
39
27
  metadata: Schema.Option<Schema.Struct<{
40
28
  /** ISO date format */
41
29
  createdAt: typeof Schema.String;
42
30
  }>>;
43
31
  }>>;
32
+ requestId: Schema.Struct<{
33
+ context: Schema.Literal<["pull", "push"]>;
34
+ requestId: typeof Schema.String;
35
+ }>;
44
36
  remaining: typeof Schema.Number;
45
37
  }>;
46
38
  export type PullRes = typeof PullRes.Type;
47
- export declare const PushBroadcast: Schema.TaggedStruct<"WSMessage.PushBroadcast", {
48
- mutationEventEncoded: Schema.SchemaClass<{
49
- readonly id: {
50
- readonly global: number;
51
- readonly local: number;
52
- };
53
- readonly mutation: string;
54
- readonly args: any;
55
- readonly parentId: {
56
- readonly global: number;
57
- readonly local: number;
58
- };
59
- }, {
60
- readonly id: {
61
- readonly global: number;
62
- readonly local: number;
63
- };
64
- readonly mutation: string;
65
- readonly args: any;
66
- readonly parentId: {
67
- readonly global: number;
68
- readonly local: number;
69
- };
70
- }, never>;
71
- metadata: Schema.Option<Schema.Struct<{
72
- /** ISO date format */
73
- createdAt: typeof Schema.String;
74
- }>>;
75
- }>;
76
- export type PushBroadcast = typeof PushBroadcast.Type;
77
- export declare const PushReq: Schema.TaggedStruct<"WSMessage.PushReq", {
39
+ export declare const PushReq: Schema.Struct<{
40
+ _tag: Schema.tag<"WSMessage.PushReq">;
41
+ } & {
78
42
  requestId: typeof Schema.String;
79
- batch: Schema.Array$<Schema.SchemaClass<{
80
- readonly id: {
81
- readonly global: number;
82
- readonly local: number;
83
- };
84
- readonly mutation: string;
85
- readonly args: any;
86
- readonly parentId: {
87
- readonly global: number;
88
- readonly local: number;
89
- };
90
- }, {
91
- readonly id: {
92
- readonly global: number;
93
- readonly local: number;
94
- };
95
- readonly mutation: string;
96
- readonly args: any;
97
- readonly parentId: {
98
- readonly global: number;
99
- readonly local: number;
100
- };
101
- }, never>>;
43
+ batch: Schema.Array$<Schema.Struct<{
44
+ name: typeof Schema.String;
45
+ args: typeof Schema.Any;
46
+ id: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
47
+ parentId: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
48
+ clientId: typeof Schema.String;
49
+ sessionId: typeof Schema.String;
50
+ }>>;
102
51
  }>;
103
52
  export type PushReq = typeof PushReq.Type;
104
- export declare const PushAck: Schema.TaggedStruct<"WSMessage.PushAck", {
53
+ export declare const PushAck: Schema.Struct<{
54
+ _tag: Schema.tag<"WSMessage.PushAck">;
55
+ } & {
105
56
  requestId: typeof Schema.String;
106
- mutationId: typeof Schema.Number;
107
57
  }>;
108
58
  export type PushAck = typeof PushAck.Type;
109
- export declare const Error: Schema.TaggedStruct<"WSMessage.Error", {
59
+ export declare const Error: Schema.Struct<{
60
+ _tag: Schema.tag<"WSMessage.Error">;
61
+ } & {
110
62
  requestId: typeof Schema.String;
111
63
  message: typeof Schema.String;
112
64
  }>;
113
- export declare const Ping: Schema.TaggedStruct<"WSMessage.Ping", {
65
+ export type Error = typeof Error.Type;
66
+ export declare const Ping: Schema.Struct<{
67
+ _tag: Schema.tag<"WSMessage.Ping">;
68
+ } & {
114
69
  requestId: Schema.Literal<["ping"]>;
115
70
  }>;
116
71
  export type Ping = typeof Ping.Type;
117
- export declare const Pong: Schema.TaggedStruct<"WSMessage.Pong", {
72
+ export declare const Pong: Schema.Struct<{
73
+ _tag: Schema.tag<"WSMessage.Pong">;
74
+ } & {
118
75
  requestId: Schema.Literal<["ping"]>;
119
76
  }>;
120
77
  export type Pong = typeof Pong.Type;
121
- export declare const AdminResetRoomReq: Schema.TaggedStruct<"WSMessage.AdminResetRoomReq", {
78
+ export declare const AdminResetRoomReq: Schema.Struct<{
79
+ _tag: Schema.tag<"WSMessage.AdminResetRoomReq">;
80
+ } & {
122
81
  requestId: typeof Schema.String;
123
82
  adminSecret: typeof Schema.String;
124
83
  }>;
125
84
  export type AdminResetRoomReq = typeof AdminResetRoomReq.Type;
126
- export declare const AdminResetRoomRes: Schema.TaggedStruct<"WSMessage.AdminResetRoomRes", {
85
+ export declare const AdminResetRoomRes: Schema.Struct<{
86
+ _tag: Schema.tag<"WSMessage.AdminResetRoomRes">;
87
+ } & {
127
88
  requestId: typeof Schema.String;
128
89
  }>;
129
90
  export type AdminResetRoomRes = typeof AdminResetRoomRes.Type;
130
- export declare const AdminInfoReq: Schema.TaggedStruct<"WSMessage.AdminInfoReq", {
91
+ export declare const AdminInfoReq: Schema.Struct<{
92
+ _tag: Schema.tag<"WSMessage.AdminInfoReq">;
93
+ } & {
131
94
  requestId: typeof Schema.String;
132
95
  adminSecret: typeof Schema.String;
133
96
  }>;
134
97
  export type AdminInfoReq = typeof AdminInfoReq.Type;
135
- export declare const AdminInfoRes: Schema.TaggedStruct<"WSMessage.AdminInfoRes", {
98
+ export declare const AdminInfoRes: Schema.Struct<{
99
+ _tag: Schema.tag<"WSMessage.AdminInfoRes">;
100
+ } & {
136
101
  requestId: typeof Schema.String;
137
102
  info: Schema.Struct<{
138
103
  durableObjectId: typeof Schema.String;
139
104
  }>;
140
105
  }>;
141
106
  export type AdminInfoRes = typeof AdminInfoRes.Type;
142
- export declare const Message: Schema.Union<[Schema.TaggedStruct<"WSMessage.PullReq", {
107
+ export declare const Message: Schema.Union<[Schema.Struct<{
108
+ _tag: Schema.tag<"WSMessage.PullReq">;
109
+ } & {
143
110
  requestId: typeof Schema.String;
144
111
  /** Omitting the cursor will start from the beginning */
145
112
  cursor: Schema.optional<typeof Schema.Number>;
146
- }>, Schema.TaggedStruct<"WSMessage.PullRes", {
147
- requestId: typeof Schema.String;
148
- events: Schema.Array$<Schema.Struct<{
149
- mutationEventEncoded: Schema.SchemaClass<{
150
- readonly id: {
151
- readonly global: number;
152
- readonly local: number;
153
- };
154
- readonly mutation: string;
155
- readonly args: any;
156
- readonly parentId: {
157
- readonly global: number;
158
- readonly local: number;
159
- };
160
- }, {
161
- readonly id: {
162
- readonly global: number;
163
- readonly local: number;
164
- };
165
- readonly mutation: string;
166
- readonly args: any;
167
- readonly parentId: {
168
- readonly global: number;
169
- readonly local: number;
170
- };
171
- }, never>;
113
+ }>, Schema.Struct<{
114
+ _tag: Schema.tag<"WSMessage.PullRes">;
115
+ } & {
116
+ batch: Schema.Array$<Schema.Struct<{
117
+ eventEncoded: Schema.Struct<{
118
+ name: typeof Schema.String;
119
+ args: typeof Schema.Any;
120
+ id: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
121
+ parentId: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
122
+ clientId: typeof Schema.String;
123
+ sessionId: typeof Schema.String;
124
+ }>;
172
125
  metadata: Schema.Option<Schema.Struct<{
173
126
  /** ISO date format */
174
127
  createdAt: typeof Schema.String;
175
128
  }>>;
176
129
  }>>;
130
+ requestId: Schema.Struct<{
131
+ context: Schema.Literal<["pull", "push"]>;
132
+ requestId: typeof Schema.String;
133
+ }>;
177
134
  remaining: typeof Schema.Number;
178
- }>, Schema.TaggedStruct<"WSMessage.PushBroadcast", {
179
- mutationEventEncoded: Schema.SchemaClass<{
180
- readonly id: {
181
- readonly global: number;
182
- readonly local: number;
183
- };
184
- readonly mutation: string;
185
- readonly args: any;
186
- readonly parentId: {
187
- readonly global: number;
188
- readonly local: number;
189
- };
190
- }, {
191
- readonly id: {
192
- readonly global: number;
193
- readonly local: number;
194
- };
195
- readonly mutation: string;
196
- readonly args: any;
197
- readonly parentId: {
198
- readonly global: number;
199
- readonly local: number;
200
- };
201
- }, never>;
202
- metadata: Schema.Option<Schema.Struct<{
203
- /** ISO date format */
204
- createdAt: typeof Schema.String;
205
- }>>;
206
- }>, Schema.TaggedStruct<"WSMessage.PushReq", {
135
+ }>, Schema.Struct<{
136
+ _tag: Schema.tag<"WSMessage.PushReq">;
137
+ } & {
207
138
  requestId: typeof Schema.String;
208
- batch: Schema.Array$<Schema.SchemaClass<{
209
- readonly id: {
210
- readonly global: number;
211
- readonly local: number;
212
- };
213
- readonly mutation: string;
214
- readonly args: any;
215
- readonly parentId: {
216
- readonly global: number;
217
- readonly local: number;
218
- };
219
- }, {
220
- readonly id: {
221
- readonly global: number;
222
- readonly local: number;
223
- };
224
- readonly mutation: string;
225
- readonly args: any;
226
- readonly parentId: {
227
- readonly global: number;
228
- readonly local: number;
229
- };
230
- }, never>>;
231
- }>, Schema.TaggedStruct<"WSMessage.PushAck", {
139
+ batch: Schema.Array$<Schema.Struct<{
140
+ name: typeof Schema.String;
141
+ args: typeof Schema.Any;
142
+ id: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
143
+ parentId: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
144
+ clientId: typeof Schema.String;
145
+ sessionId: typeof Schema.String;
146
+ }>>;
147
+ }>, Schema.Struct<{
148
+ _tag: Schema.tag<"WSMessage.PushAck">;
149
+ } & {
232
150
  requestId: typeof Schema.String;
233
- mutationId: typeof Schema.Number;
234
- }>, Schema.TaggedStruct<"WSMessage.Error", {
151
+ }>, Schema.Struct<{
152
+ _tag: Schema.tag<"WSMessage.Error">;
153
+ } & {
235
154
  requestId: typeof Schema.String;
236
155
  message: typeof Schema.String;
237
- }>, Schema.TaggedStruct<"WSMessage.Ping", {
156
+ }>, Schema.Struct<{
157
+ _tag: Schema.tag<"WSMessage.Ping">;
158
+ } & {
238
159
  requestId: Schema.Literal<["ping"]>;
239
- }>, Schema.TaggedStruct<"WSMessage.Pong", {
160
+ }>, Schema.Struct<{
161
+ _tag: Schema.tag<"WSMessage.Pong">;
162
+ } & {
240
163
  requestId: Schema.Literal<["ping"]>;
241
- }>, Schema.TaggedStruct<"WSMessage.AdminResetRoomReq", {
164
+ }>, Schema.Struct<{
165
+ _tag: Schema.tag<"WSMessage.AdminResetRoomReq">;
166
+ } & {
242
167
  requestId: typeof Schema.String;
243
168
  adminSecret: typeof Schema.String;
244
- }>, Schema.TaggedStruct<"WSMessage.AdminResetRoomRes", {
169
+ }>, Schema.Struct<{
170
+ _tag: Schema.tag<"WSMessage.AdminResetRoomRes">;
171
+ } & {
245
172
  requestId: typeof Schema.String;
246
- }>, Schema.TaggedStruct<"WSMessage.AdminInfoReq", {
173
+ }>, Schema.Struct<{
174
+ _tag: Schema.tag<"WSMessage.AdminInfoReq">;
175
+ } & {
247
176
  requestId: typeof Schema.String;
248
177
  adminSecret: typeof Schema.String;
249
- }>, Schema.TaggedStruct<"WSMessage.AdminInfoRes", {
178
+ }>, Schema.Struct<{
179
+ _tag: Schema.tag<"WSMessage.AdminInfoRes">;
180
+ } & {
250
181
  requestId: typeof Schema.String;
251
182
  info: Schema.Struct<{
252
183
  durableObjectId: typeof Schema.String;
@@ -254,119 +185,85 @@ export declare const Message: Schema.Union<[Schema.TaggedStruct<"WSMessage.PullR
254
185
  }>]>;
255
186
  export type Message = typeof Message.Type;
256
187
  export type MessageEncoded = typeof Message.Encoded;
257
- export declare const BackendToClientMessage: Schema.Union<[Schema.TaggedStruct<"WSMessage.PullRes", {
258
- requestId: typeof Schema.String;
259
- events: Schema.Array$<Schema.Struct<{
260
- mutationEventEncoded: Schema.SchemaClass<{
261
- readonly id: {
262
- readonly global: number;
263
- readonly local: number;
264
- };
265
- readonly mutation: string;
266
- readonly args: any;
267
- readonly parentId: {
268
- readonly global: number;
269
- readonly local: number;
270
- };
271
- }, {
272
- readonly id: {
273
- readonly global: number;
274
- readonly local: number;
275
- };
276
- readonly mutation: string;
277
- readonly args: any;
278
- readonly parentId: {
279
- readonly global: number;
280
- readonly local: number;
281
- };
282
- }, never>;
188
+ export declare const BackendToClientMessage: Schema.Union<[Schema.Struct<{
189
+ _tag: Schema.tag<"WSMessage.PullRes">;
190
+ } & {
191
+ batch: Schema.Array$<Schema.Struct<{
192
+ eventEncoded: Schema.Struct<{
193
+ name: typeof Schema.String;
194
+ args: typeof Schema.Any;
195
+ id: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
196
+ parentId: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
197
+ clientId: typeof Schema.String;
198
+ sessionId: typeof Schema.String;
199
+ }>;
283
200
  metadata: Schema.Option<Schema.Struct<{
284
201
  /** ISO date format */
285
202
  createdAt: typeof Schema.String;
286
203
  }>>;
287
204
  }>>;
205
+ requestId: Schema.Struct<{
206
+ context: Schema.Literal<["pull", "push"]>;
207
+ requestId: typeof Schema.String;
208
+ }>;
288
209
  remaining: typeof Schema.Number;
289
- }>, Schema.TaggedStruct<"WSMessage.PushBroadcast", {
290
- mutationEventEncoded: Schema.SchemaClass<{
291
- readonly id: {
292
- readonly global: number;
293
- readonly local: number;
294
- };
295
- readonly mutation: string;
296
- readonly args: any;
297
- readonly parentId: {
298
- readonly global: number;
299
- readonly local: number;
300
- };
301
- }, {
302
- readonly id: {
303
- readonly global: number;
304
- readonly local: number;
305
- };
306
- readonly mutation: string;
307
- readonly args: any;
308
- readonly parentId: {
309
- readonly global: number;
310
- readonly local: number;
311
- };
312
- }, never>;
313
- metadata: Schema.Option<Schema.Struct<{
314
- /** ISO date format */
315
- createdAt: typeof Schema.String;
316
- }>>;
317
- }>, Schema.TaggedStruct<"WSMessage.PushAck", {
210
+ }>, Schema.Struct<{
211
+ _tag: Schema.tag<"WSMessage.PushAck">;
212
+ } & {
318
213
  requestId: typeof Schema.String;
319
- mutationId: typeof Schema.Number;
320
- }>, Schema.TaggedStruct<"WSMessage.AdminResetRoomRes", {
214
+ }>, Schema.Struct<{
215
+ _tag: Schema.tag<"WSMessage.AdminResetRoomRes">;
216
+ } & {
321
217
  requestId: typeof Schema.String;
322
- }>, Schema.TaggedStruct<"WSMessage.AdminInfoRes", {
218
+ }>, Schema.Struct<{
219
+ _tag: Schema.tag<"WSMessage.AdminInfoRes">;
220
+ } & {
323
221
  requestId: typeof Schema.String;
324
222
  info: Schema.Struct<{
325
223
  durableObjectId: typeof Schema.String;
326
224
  }>;
327
- }>, Schema.TaggedStruct<"WSMessage.Error", {
225
+ }>, Schema.Struct<{
226
+ _tag: Schema.tag<"WSMessage.Error">;
227
+ } & {
328
228
  requestId: typeof Schema.String;
329
229
  message: typeof Schema.String;
330
- }>, Schema.TaggedStruct<"WSMessage.Pong", {
230
+ }>, Schema.Struct<{
231
+ _tag: Schema.tag<"WSMessage.Pong">;
232
+ } & {
331
233
  requestId: Schema.Literal<["ping"]>;
332
234
  }>]>;
333
235
  export type BackendToClientMessage = typeof BackendToClientMessage.Type;
334
- export declare const ClientToBackendMessage: Schema.Union<[Schema.TaggedStruct<"WSMessage.PullReq", {
236
+ export declare const ClientToBackendMessage: Schema.Union<[Schema.Struct<{
237
+ _tag: Schema.tag<"WSMessage.PullReq">;
238
+ } & {
335
239
  requestId: typeof Schema.String;
336
240
  /** Omitting the cursor will start from the beginning */
337
241
  cursor: Schema.optional<typeof Schema.Number>;
338
- }>, Schema.TaggedStruct<"WSMessage.PushReq", {
242
+ }>, Schema.Struct<{
243
+ _tag: Schema.tag<"WSMessage.PushReq">;
244
+ } & {
339
245
  requestId: typeof Schema.String;
340
- batch: Schema.Array$<Schema.SchemaClass<{
341
- readonly id: {
342
- readonly global: number;
343
- readonly local: number;
344
- };
345
- readonly mutation: string;
346
- readonly args: any;
347
- readonly parentId: {
348
- readonly global: number;
349
- readonly local: number;
350
- };
351
- }, {
352
- readonly id: {
353
- readonly global: number;
354
- readonly local: number;
355
- };
356
- readonly mutation: string;
357
- readonly args: any;
358
- readonly parentId: {
359
- readonly global: number;
360
- readonly local: number;
361
- };
362
- }, never>>;
363
- }>, Schema.TaggedStruct<"WSMessage.AdminResetRoomReq", {
246
+ batch: Schema.Array$<Schema.Struct<{
247
+ name: typeof Schema.String;
248
+ args: typeof Schema.Any;
249
+ id: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
250
+ parentId: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
251
+ clientId: typeof Schema.String;
252
+ sessionId: typeof Schema.String;
253
+ }>>;
254
+ }>, Schema.Struct<{
255
+ _tag: Schema.tag<"WSMessage.AdminResetRoomReq">;
256
+ } & {
364
257
  requestId: typeof Schema.String;
365
258
  adminSecret: typeof Schema.String;
366
- }>, Schema.TaggedStruct<"WSMessage.AdminInfoReq", {
259
+ }>, Schema.Struct<{
260
+ _tag: Schema.tag<"WSMessage.AdminInfoReq">;
261
+ } & {
367
262
  requestId: typeof Schema.String;
368
263
  adminSecret: typeof Schema.String;
369
- }>, Schema.TaggedStruct<"WSMessage.Ping", {
264
+ }>, Schema.Struct<{
265
+ _tag: Schema.tag<"WSMessage.Ping">;
266
+ } & {
370
267
  requestId: Schema.Literal<["ping"]>;
371
268
  }>]>;
372
269
  export type ClientToBackendMessage = typeof ClientToBackendMessage.Type;