@livestore/sync-cf 0.3.0-dev.5 → 0.3.0-dev.51
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/dist/.tsbuildinfo +1 -1
- package/dist/cf-worker/durable-object.d.ts +60 -46
- package/dist/cf-worker/durable-object.d.ts.map +1 -1
- package/dist/cf-worker/durable-object.js +230 -148
- package/dist/cf-worker/durable-object.js.map +1 -1
- package/dist/cf-worker/mod.d.ts +3 -0
- package/dist/cf-worker/mod.d.ts.map +1 -0
- package/dist/cf-worker/mod.js +3 -0
- package/dist/cf-worker/mod.js.map +1 -0
- package/dist/cf-worker/worker.d.ts +40 -0
- package/dist/cf-worker/worker.d.ts.map +1 -0
- package/dist/cf-worker/worker.js +92 -0
- package/dist/cf-worker/worker.js.map +1 -0
- package/dist/common/mod.d.ts +7 -0
- package/dist/common/mod.d.ts.map +1 -0
- package/dist/common/mod.js +7 -0
- package/dist/common/mod.js.map +1 -0
- package/dist/common/ws-message-types.d.ts +148 -98
- package/dist/common/ws-message-types.d.ts.map +1 -1
- package/dist/common/ws-message-types.js +19 -24
- package/dist/common/ws-message-types.js.map +1 -1
- package/dist/sync-impl/mod.d.ts +2 -0
- package/dist/sync-impl/mod.d.ts.map +1 -0
- package/dist/sync-impl/mod.js +2 -0
- package/dist/sync-impl/mod.js.map +1 -0
- package/dist/sync-impl/ws-impl.d.ts +3 -15
- package/dist/sync-impl/ws-impl.d.ts.map +1 -1
- package/dist/sync-impl/ws-impl.js +89 -36
- package/dist/sync-impl/ws-impl.js.map +1 -1
- package/package.json +15 -13
- package/src/cf-worker/durable-object.ts +311 -165
- package/src/cf-worker/mod.ts +2 -0
- package/src/cf-worker/worker.ts +129 -0
- package/src/common/mod.ts +8 -0
- package/src/common/ws-message-types.ts +22 -36
- package/src/sync-impl/ws-impl.ts +146 -100
- package/dist/cf-worker/index.d.ts +0 -8
- package/dist/cf-worker/index.d.ts.map +0 -1
- package/dist/cf-worker/index.js +0 -67
- package/dist/cf-worker/index.js.map +0 -1
- package/dist/common/index.d.ts +0 -2
- package/dist/common/index.d.ts.map +0 -1
- package/dist/common/index.js +0 -2
- package/dist/common/index.js.map +0 -1
- package/dist/sync-impl/index.d.ts +0 -2
- package/dist/sync-impl/index.d.ts.map +0 -1
- package/dist/sync-impl/index.js +0 -2
- package/dist/sync-impl/index.js.map +0 -1
- package/src/cf-worker/index.ts +0 -84
- package/src/common/index.ts +0 -1
- /package/src/sync-impl/{index.ts → mod.ts} +0 -0
|
@@ -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,40 @@
|
|
|
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
|
+
/**
|
|
13
|
+
* Handles `/websocket` endpoint.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const validatePayload = (payload: Schema.JsonValue | undefined) => {
|
|
18
|
+
* if (payload?.authToken !== 'insecure-token-change-me') {
|
|
19
|
+
* throw new Error('Invalid auth token')
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* export default {
|
|
24
|
+
* fetch: async (request, env, ctx) => {
|
|
25
|
+
* if (request.url.endsWith('/websocket')) {
|
|
26
|
+
* return handleWebSocket(request, env, ctx, { headers: {}, validatePayload })
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* return new Response('Invalid path', { status: 400, headers: corsHeaders })
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @throws {UnexpectedError} If the payload is invalid
|
|
35
|
+
*/
|
|
36
|
+
export declare const handleWebSocket: (request: Request, env: Env, _ctx: ExecutionContext, options: {
|
|
37
|
+
headers?: HeadersInit;
|
|
38
|
+
validatePayload?: (payload: Schema.JsonValue | undefined) => void | Promise<void>;
|
|
39
|
+
}) => Promise<Response>;
|
|
40
|
+
//# 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,QA2C5D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,OAAO,EAChB,KAAK,GAAG,EACR,MAAM,gBAAgB,EACtB,SAAS;IAAE,OAAO,CAAC,EAAE,WAAW,CAAC;IAAC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,KACpH,OAAO,CAAC,QAAQ,CAqCmC,CAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
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) => {
|
|
7
|
+
const url = new URL(request.url);
|
|
8
|
+
if (request.method === 'GET' && url.pathname === '/') {
|
|
9
|
+
return new Response('Info: WebSocket sync backend endpoint for @livestore/sync-cf.', {
|
|
10
|
+
status: 200,
|
|
11
|
+
headers: { 'Content-Type': 'text/plain' },
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const corsHeaders = options.enableCORS
|
|
15
|
+
? {
|
|
16
|
+
'Access-Control-Allow-Origin': '*',
|
|
17
|
+
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
|
|
18
|
+
'Access-Control-Allow-Headers': request.headers.get('Access-Control-Request-Headers') ?? '*',
|
|
19
|
+
}
|
|
20
|
+
: {};
|
|
21
|
+
if (request.method === 'OPTIONS' && options.enableCORS) {
|
|
22
|
+
return new Response(null, {
|
|
23
|
+
status: 204,
|
|
24
|
+
headers: corsHeaders,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (url.pathname.endsWith('/websocket')) {
|
|
28
|
+
return handleWebSocket(request, env, _ctx, { headers: corsHeaders, validatePayload: options.validatePayload });
|
|
29
|
+
}
|
|
30
|
+
console.error('Invalid path', url.pathname);
|
|
31
|
+
return new Response('Invalid path', {
|
|
32
|
+
status: 400,
|
|
33
|
+
statusText: 'Bad Request',
|
|
34
|
+
headers: {
|
|
35
|
+
...corsHeaders,
|
|
36
|
+
'Content-Type': 'text/plain',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Handles `/websocket` endpoint.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const validatePayload = (payload: Schema.JsonValue | undefined) => {
|
|
48
|
+
* if (payload?.authToken !== 'insecure-token-change-me') {
|
|
49
|
+
* throw new Error('Invalid auth token')
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* export default {
|
|
54
|
+
* fetch: async (request, env, ctx) => {
|
|
55
|
+
* if (request.url.endsWith('/websocket')) {
|
|
56
|
+
* return handleWebSocket(request, env, ctx, { headers: {}, validatePayload })
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* return new Response('Invalid path', { status: 400, headers: corsHeaders })
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @throws {UnexpectedError} If the payload is invalid
|
|
65
|
+
*/
|
|
66
|
+
export const handleWebSocket = (request, env, _ctx, options) => Effect.gen(function* () {
|
|
67
|
+
const url = new URL(request.url);
|
|
68
|
+
const urlParams = UrlParams.fromInput(url.searchParams);
|
|
69
|
+
const paramsResult = yield* UrlParams.schemaStruct(SearchParamsSchema)(urlParams).pipe(Effect.either);
|
|
70
|
+
if (paramsResult._tag === 'Left') {
|
|
71
|
+
return new Response(`Invalid search params: ${paramsResult.left.toString()}`, {
|
|
72
|
+
status: 500,
|
|
73
|
+
headers: options?.headers,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const { storeId, payload } = paramsResult.right;
|
|
77
|
+
if (options.validatePayload !== undefined) {
|
|
78
|
+
const result = yield* Effect.promise(async () => options.validatePayload(payload)).pipe(UnexpectedError.mapToUnexpectedError, Effect.either);
|
|
79
|
+
if (result._tag === 'Left') {
|
|
80
|
+
console.error('Invalid payload', result.left);
|
|
81
|
+
return new Response(result.left.toString(), { status: 400, headers: options.headers });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const id = env.WEBSOCKET_SERVER.idFromName(storeId);
|
|
85
|
+
const durableObject = env.WEBSOCKET_SERVER.get(id);
|
|
86
|
+
const upgradeHeader = request.headers.get('Upgrade');
|
|
87
|
+
if (!upgradeHeader || upgradeHeader !== 'websocket') {
|
|
88
|
+
return new Response('Durable Object expected Upgrade: websocket', { status: 426, headers: options?.headers });
|
|
89
|
+
}
|
|
90
|
+
return yield* Effect.promise(() => durableObject.fetch(request));
|
|
91
|
+
}).pipe(Effect.tapCauseLogPretty, Effect.runPromise);
|
|
92
|
+
//# 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,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YAClC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YAEhC,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,IAAI,GAAG,CAAC,QAAQ,KAAK,GAAG,EAAE,CAAC;gBACrD,OAAO,IAAI,QAAQ,CAAC,+DAA+D,EAAE;oBACnF,MAAM,EAAE,GAAG;oBACX,OAAO,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE;iBA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AgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAElD,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACpD,IAAI,CAAC,aAAa,IAAI,aAAa,KAAK,WAAW,EAAE,CAAC;QACpD,OAAO,IAAI,QAAQ,CAAC,4CAA4C,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;IAC/G,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;AAClE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,UAAU,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.
|
|
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,141 +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.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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;
|
|
18
21
|
args: typeof Schema.Any;
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
23
|
+
parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
24
|
+
clientId: typeof Schema.String;
|
|
25
|
+
sessionId: typeof Schema.String;
|
|
21
26
|
}>;
|
|
22
27
|
metadata: Schema.Option<Schema.Struct<{
|
|
23
28
|
/** ISO date format */
|
|
24
29
|
createdAt: typeof Schema.String;
|
|
25
30
|
}>>;
|
|
26
31
|
}>>;
|
|
32
|
+
requestId: Schema.Struct<{
|
|
33
|
+
context: Schema.Literal<["pull", "push"]>;
|
|
34
|
+
requestId: typeof Schema.String;
|
|
35
|
+
}>;
|
|
27
36
|
remaining: typeof Schema.Number;
|
|
28
37
|
}>;
|
|
29
38
|
export type PullRes = typeof PullRes.Type;
|
|
30
|
-
export declare const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
args: typeof Schema.Any;
|
|
34
|
-
id: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
|
|
35
|
-
parentId: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
|
|
36
|
-
}>;
|
|
37
|
-
metadata: Schema.Option<Schema.Struct<{
|
|
38
|
-
/** ISO date format */
|
|
39
|
-
createdAt: typeof Schema.String;
|
|
40
|
-
}>>;
|
|
41
|
-
}>;
|
|
42
|
-
export type PushBroadcast = typeof PushBroadcast.Type;
|
|
43
|
-
export declare const PushReq: Schema.TaggedStruct<"WSMessage.PushReq", {
|
|
39
|
+
export declare const PushReq: Schema.Struct<{
|
|
40
|
+
_tag: Schema.tag<"WSMessage.PushReq">;
|
|
41
|
+
} & {
|
|
44
42
|
requestId: typeof Schema.String;
|
|
45
43
|
batch: Schema.Array$<Schema.Struct<{
|
|
46
|
-
|
|
44
|
+
name: typeof Schema.String;
|
|
47
45
|
args: typeof Schema.Any;
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
47
|
+
parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
48
|
+
clientId: typeof Schema.String;
|
|
49
|
+
sessionId: typeof Schema.String;
|
|
50
50
|
}>>;
|
|
51
51
|
}>;
|
|
52
52
|
export type PushReq = typeof PushReq.Type;
|
|
53
|
-
export declare const PushAck: Schema.
|
|
53
|
+
export declare const PushAck: Schema.Struct<{
|
|
54
|
+
_tag: Schema.tag<"WSMessage.PushAck">;
|
|
55
|
+
} & {
|
|
54
56
|
requestId: typeof Schema.String;
|
|
55
|
-
mutationId: typeof Schema.Number;
|
|
56
57
|
}>;
|
|
57
58
|
export type PushAck = typeof PushAck.Type;
|
|
58
|
-
export declare const Error: Schema.
|
|
59
|
+
export declare const Error: Schema.Struct<{
|
|
60
|
+
_tag: Schema.tag<"WSMessage.Error">;
|
|
61
|
+
} & {
|
|
59
62
|
requestId: typeof Schema.String;
|
|
60
63
|
message: typeof Schema.String;
|
|
61
64
|
}>;
|
|
62
|
-
export
|
|
65
|
+
export type Error = typeof Error.Type;
|
|
66
|
+
export declare const Ping: Schema.Struct<{
|
|
67
|
+
_tag: Schema.tag<"WSMessage.Ping">;
|
|
68
|
+
} & {
|
|
63
69
|
requestId: Schema.Literal<["ping"]>;
|
|
64
70
|
}>;
|
|
65
71
|
export type Ping = typeof Ping.Type;
|
|
66
|
-
export declare const Pong: Schema.
|
|
72
|
+
export declare const Pong: Schema.Struct<{
|
|
73
|
+
_tag: Schema.tag<"WSMessage.Pong">;
|
|
74
|
+
} & {
|
|
67
75
|
requestId: Schema.Literal<["ping"]>;
|
|
68
76
|
}>;
|
|
69
77
|
export type Pong = typeof Pong.Type;
|
|
70
|
-
export declare const AdminResetRoomReq: Schema.
|
|
78
|
+
export declare const AdminResetRoomReq: Schema.Struct<{
|
|
79
|
+
_tag: Schema.tag<"WSMessage.AdminResetRoomReq">;
|
|
80
|
+
} & {
|
|
71
81
|
requestId: typeof Schema.String;
|
|
72
82
|
adminSecret: typeof Schema.String;
|
|
73
83
|
}>;
|
|
74
84
|
export type AdminResetRoomReq = typeof AdminResetRoomReq.Type;
|
|
75
|
-
export declare const AdminResetRoomRes: Schema.
|
|
85
|
+
export declare const AdminResetRoomRes: Schema.Struct<{
|
|
86
|
+
_tag: Schema.tag<"WSMessage.AdminResetRoomRes">;
|
|
87
|
+
} & {
|
|
76
88
|
requestId: typeof Schema.String;
|
|
77
89
|
}>;
|
|
78
90
|
export type AdminResetRoomRes = typeof AdminResetRoomRes.Type;
|
|
79
|
-
export declare const AdminInfoReq: Schema.
|
|
91
|
+
export declare const AdminInfoReq: Schema.Struct<{
|
|
92
|
+
_tag: Schema.tag<"WSMessage.AdminInfoReq">;
|
|
93
|
+
} & {
|
|
80
94
|
requestId: typeof Schema.String;
|
|
81
95
|
adminSecret: typeof Schema.String;
|
|
82
96
|
}>;
|
|
83
97
|
export type AdminInfoReq = typeof AdminInfoReq.Type;
|
|
84
|
-
export declare const AdminInfoRes: Schema.
|
|
98
|
+
export declare const AdminInfoRes: Schema.Struct<{
|
|
99
|
+
_tag: Schema.tag<"WSMessage.AdminInfoRes">;
|
|
100
|
+
} & {
|
|
85
101
|
requestId: typeof Schema.String;
|
|
86
102
|
info: Schema.Struct<{
|
|
87
103
|
durableObjectId: typeof Schema.String;
|
|
88
104
|
}>;
|
|
89
105
|
}>;
|
|
90
106
|
export type AdminInfoRes = typeof AdminInfoRes.Type;
|
|
91
|
-
export declare const Message: Schema.Union<[Schema.
|
|
107
|
+
export declare const Message: Schema.Union<[Schema.Struct<{
|
|
108
|
+
_tag: Schema.tag<"WSMessage.PullReq">;
|
|
109
|
+
} & {
|
|
92
110
|
requestId: typeof Schema.String;
|
|
93
111
|
/** Omitting the cursor will start from the beginning */
|
|
94
112
|
cursor: Schema.optional<typeof Schema.Number>;
|
|
95
|
-
}>, Schema.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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;
|
|
100
119
|
args: typeof Schema.Any;
|
|
101
|
-
|
|
102
|
-
|
|
120
|
+
seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
121
|
+
parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
122
|
+
clientId: typeof Schema.String;
|
|
123
|
+
sessionId: typeof Schema.String;
|
|
103
124
|
}>;
|
|
104
125
|
metadata: Schema.Option<Schema.Struct<{
|
|
105
126
|
/** ISO date format */
|
|
106
127
|
createdAt: typeof Schema.String;
|
|
107
128
|
}>>;
|
|
108
129
|
}>>;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
mutation: typeof Schema.String;
|
|
113
|
-
args: typeof Schema.Any;
|
|
114
|
-
id: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
|
|
115
|
-
parentId: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
|
|
130
|
+
requestId: Schema.Struct<{
|
|
131
|
+
context: Schema.Literal<["pull", "push"]>;
|
|
132
|
+
requestId: typeof Schema.String;
|
|
116
133
|
}>;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}>, Schema.TaggedStruct<"WSMessage.PushReq", {
|
|
134
|
+
remaining: typeof Schema.Number;
|
|
135
|
+
}>, Schema.Struct<{
|
|
136
|
+
_tag: Schema.tag<"WSMessage.PushReq">;
|
|
137
|
+
} & {
|
|
122
138
|
requestId: typeof Schema.String;
|
|
123
139
|
batch: Schema.Array$<Schema.Struct<{
|
|
124
|
-
|
|
140
|
+
name: typeof Schema.String;
|
|
125
141
|
args: typeof Schema.Any;
|
|
126
|
-
|
|
127
|
-
|
|
142
|
+
seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
143
|
+
parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
144
|
+
clientId: typeof Schema.String;
|
|
145
|
+
sessionId: typeof Schema.String;
|
|
128
146
|
}>>;
|
|
129
|
-
}>, Schema.
|
|
147
|
+
}>, Schema.Struct<{
|
|
148
|
+
_tag: Schema.tag<"WSMessage.PushAck">;
|
|
149
|
+
} & {
|
|
130
150
|
requestId: typeof Schema.String;
|
|
131
|
-
|
|
132
|
-
|
|
151
|
+
}>, Schema.Struct<{
|
|
152
|
+
_tag: Schema.tag<"WSMessage.Error">;
|
|
153
|
+
} & {
|
|
133
154
|
requestId: typeof Schema.String;
|
|
134
155
|
message: typeof Schema.String;
|
|
135
|
-
}>, Schema.
|
|
156
|
+
}>, Schema.Struct<{
|
|
157
|
+
_tag: Schema.tag<"WSMessage.Ping">;
|
|
158
|
+
} & {
|
|
136
159
|
requestId: Schema.Literal<["ping"]>;
|
|
137
|
-
}>, Schema.
|
|
160
|
+
}>, Schema.Struct<{
|
|
161
|
+
_tag: Schema.tag<"WSMessage.Pong">;
|
|
162
|
+
} & {
|
|
138
163
|
requestId: Schema.Literal<["ping"]>;
|
|
139
|
-
}>, Schema.
|
|
164
|
+
}>, Schema.Struct<{
|
|
165
|
+
_tag: Schema.tag<"WSMessage.AdminResetRoomReq">;
|
|
166
|
+
} & {
|
|
140
167
|
requestId: typeof Schema.String;
|
|
141
168
|
adminSecret: typeof Schema.String;
|
|
142
|
-
}>, Schema.
|
|
169
|
+
}>, Schema.Struct<{
|
|
170
|
+
_tag: Schema.tag<"WSMessage.AdminResetRoomRes">;
|
|
171
|
+
} & {
|
|
143
172
|
requestId: typeof Schema.String;
|
|
144
|
-
}>, Schema.
|
|
173
|
+
}>, Schema.Struct<{
|
|
174
|
+
_tag: Schema.tag<"WSMessage.AdminInfoReq">;
|
|
175
|
+
} & {
|
|
145
176
|
requestId: typeof Schema.String;
|
|
146
177
|
adminSecret: typeof Schema.String;
|
|
147
|
-
}>, Schema.
|
|
178
|
+
}>, Schema.Struct<{
|
|
179
|
+
_tag: Schema.tag<"WSMessage.AdminInfoRes">;
|
|
180
|
+
} & {
|
|
148
181
|
requestId: typeof Schema.String;
|
|
149
182
|
info: Schema.Struct<{
|
|
150
183
|
durableObjectId: typeof Schema.String;
|
|
@@ -152,68 +185,85 @@ export declare const Message: Schema.Union<[Schema.TaggedStruct<"WSMessage.PullR
|
|
|
152
185
|
}>]>;
|
|
153
186
|
export type Message = typeof Message.Type;
|
|
154
187
|
export type MessageEncoded = typeof Message.Encoded;
|
|
155
|
-
export declare const BackendToClientMessage: Schema.Union<[Schema.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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;
|
|
160
194
|
args: typeof Schema.Any;
|
|
161
|
-
|
|
162
|
-
|
|
195
|
+
seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
196
|
+
parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
197
|
+
clientId: typeof Schema.String;
|
|
198
|
+
sessionId: typeof Schema.String;
|
|
163
199
|
}>;
|
|
164
200
|
metadata: Schema.Option<Schema.Struct<{
|
|
165
201
|
/** ISO date format */
|
|
166
202
|
createdAt: typeof Schema.String;
|
|
167
203
|
}>>;
|
|
168
204
|
}>>;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
mutation: typeof Schema.String;
|
|
173
|
-
args: typeof Schema.Any;
|
|
174
|
-
id: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
|
|
175
|
-
parentId: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
|
|
205
|
+
requestId: Schema.Struct<{
|
|
206
|
+
context: Schema.Literal<["pull", "push"]>;
|
|
207
|
+
requestId: typeof Schema.String;
|
|
176
208
|
}>;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}>, Schema.TaggedStruct<"WSMessage.PushAck", {
|
|
209
|
+
remaining: typeof Schema.Number;
|
|
210
|
+
}>, Schema.Struct<{
|
|
211
|
+
_tag: Schema.tag<"WSMessage.PushAck">;
|
|
212
|
+
} & {
|
|
182
213
|
requestId: typeof Schema.String;
|
|
183
|
-
|
|
184
|
-
|
|
214
|
+
}>, Schema.Struct<{
|
|
215
|
+
_tag: Schema.tag<"WSMessage.AdminResetRoomRes">;
|
|
216
|
+
} & {
|
|
185
217
|
requestId: typeof Schema.String;
|
|
186
|
-
}>, Schema.
|
|
218
|
+
}>, Schema.Struct<{
|
|
219
|
+
_tag: Schema.tag<"WSMessage.AdminInfoRes">;
|
|
220
|
+
} & {
|
|
187
221
|
requestId: typeof Schema.String;
|
|
188
222
|
info: Schema.Struct<{
|
|
189
223
|
durableObjectId: typeof Schema.String;
|
|
190
224
|
}>;
|
|
191
|
-
}>, Schema.
|
|
225
|
+
}>, Schema.Struct<{
|
|
226
|
+
_tag: Schema.tag<"WSMessage.Error">;
|
|
227
|
+
} & {
|
|
192
228
|
requestId: typeof Schema.String;
|
|
193
229
|
message: typeof Schema.String;
|
|
194
|
-
}>, Schema.
|
|
230
|
+
}>, Schema.Struct<{
|
|
231
|
+
_tag: Schema.tag<"WSMessage.Pong">;
|
|
232
|
+
} & {
|
|
195
233
|
requestId: Schema.Literal<["ping"]>;
|
|
196
234
|
}>]>;
|
|
197
235
|
export type BackendToClientMessage = typeof BackendToClientMessage.Type;
|
|
198
|
-
export declare const ClientToBackendMessage: Schema.Union<[Schema.
|
|
236
|
+
export declare const ClientToBackendMessage: Schema.Union<[Schema.Struct<{
|
|
237
|
+
_tag: Schema.tag<"WSMessage.PullReq">;
|
|
238
|
+
} & {
|
|
199
239
|
requestId: typeof Schema.String;
|
|
200
240
|
/** Omitting the cursor will start from the beginning */
|
|
201
241
|
cursor: Schema.optional<typeof Schema.Number>;
|
|
202
|
-
}>, Schema.
|
|
242
|
+
}>, Schema.Struct<{
|
|
243
|
+
_tag: Schema.tag<"WSMessage.PushReq">;
|
|
244
|
+
} & {
|
|
203
245
|
requestId: typeof Schema.String;
|
|
204
246
|
batch: Schema.Array$<Schema.Struct<{
|
|
205
|
-
|
|
247
|
+
name: typeof Schema.String;
|
|
206
248
|
args: typeof Schema.Any;
|
|
207
|
-
|
|
208
|
-
|
|
249
|
+
seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
250
|
+
parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
251
|
+
clientId: typeof Schema.String;
|
|
252
|
+
sessionId: typeof Schema.String;
|
|
209
253
|
}>>;
|
|
210
|
-
}>, Schema.
|
|
254
|
+
}>, Schema.Struct<{
|
|
255
|
+
_tag: Schema.tag<"WSMessage.AdminResetRoomReq">;
|
|
256
|
+
} & {
|
|
211
257
|
requestId: typeof Schema.String;
|
|
212
258
|
adminSecret: typeof Schema.String;
|
|
213
|
-
}>, Schema.
|
|
259
|
+
}>, Schema.Struct<{
|
|
260
|
+
_tag: Schema.tag<"WSMessage.AdminInfoReq">;
|
|
261
|
+
} & {
|
|
214
262
|
requestId: typeof Schema.String;
|
|
215
263
|
adminSecret: typeof Schema.String;
|
|
216
|
-
}>, Schema.
|
|
264
|
+
}>, Schema.Struct<{
|
|
265
|
+
_tag: Schema.tag<"WSMessage.Ping">;
|
|
266
|
+
} & {
|
|
217
267
|
requestId: Schema.Literal<["ping"]>;
|
|
218
268
|
}>]>;
|
|
219
269
|
export type ClientToBackendMessage = typeof ClientToBackendMessage.Type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-message-types.d.ts","sourceRoot":"","sources":["../../src/common/ws-message-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"ws-message-types.d.ts","sourceRoot":"","sources":["../../src/common/ws-message-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,eAAO,MAAM,OAAO;;;;IAElB,wDAAwD;;EAEH,CAAA;AAEvD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,eAAO,MAAM,YAAY;IACvB,sBAAsB;;EAEoC,CAAA;AAE5D,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAEnD,eAAO,MAAM,OAAO;;;;;;;;;;;;;YANlB,sBAAsB;;;;;;;;;EAe+B,CAAA;AAEvD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,eAAO,MAAM,OAAO;;;;;;;;;;;;EAGmC,CAAA;AAEvD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA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iG0F,CAAA;AAClH,MAAM,MAAM,sBAAsB,GAAG,OAAO,sBAAsB,CAAC,IAAI,CAAA;AAEvE,eAAO,MAAM,sBAAsB;;;;IA3GjC,wDAAwD;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2GiD,CAAA;AAC3G,MAAM,MAAM,sBAAsB,GAAG,OAAO,sBAAsB,CAAC,IAAI,CAAA"}
|
|
@@ -1,62 +1,57 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LiveStoreEvent } from '@livestore/common/schema';
|
|
2
2
|
import { Schema } from '@livestore/utils/effect';
|
|
3
3
|
export const PullReq = Schema.TaggedStruct('WSMessage.PullReq', {
|
|
4
4
|
requestId: Schema.String,
|
|
5
5
|
/** Omitting the cursor will start from the beginning */
|
|
6
6
|
cursor: Schema.optional(Schema.Number),
|
|
7
|
-
});
|
|
7
|
+
}).annotations({ title: '@livestore/sync-cf:PullReq' });
|
|
8
8
|
export const SyncMetadata = Schema.Struct({
|
|
9
9
|
/** ISO date format */
|
|
10
10
|
createdAt: Schema.String,
|
|
11
|
-
});
|
|
11
|
+
}).annotations({ title: '@livestore/sync-cf:SyncMetadata' });
|
|
12
12
|
export const PullRes = Schema.TaggedStruct('WSMessage.PullRes', {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
mutationEventEncoded: MutationEvent.AnyEncodedGlobal,
|
|
13
|
+
batch: Schema.Array(Schema.Struct({
|
|
14
|
+
eventEncoded: LiveStoreEvent.AnyEncodedGlobal,
|
|
16
15
|
metadata: Schema.Option(SyncMetadata),
|
|
17
16
|
})),
|
|
17
|
+
requestId: Schema.Struct({ context: Schema.Literal('pull', 'push'), requestId: Schema.String }),
|
|
18
18
|
remaining: Schema.Number,
|
|
19
|
-
});
|
|
20
|
-
export const PushBroadcast = Schema.TaggedStruct('WSMessage.PushBroadcast', {
|
|
21
|
-
mutationEventEncoded: MutationEvent.AnyEncodedGlobal,
|
|
22
|
-
metadata: Schema.Option(SyncMetadata),
|
|
23
|
-
});
|
|
19
|
+
}).annotations({ title: '@livestore/sync-cf:PullRes' });
|
|
24
20
|
export const PushReq = Schema.TaggedStruct('WSMessage.PushReq', {
|
|
25
21
|
requestId: Schema.String,
|
|
26
|
-
batch: Schema.Array(
|
|
27
|
-
});
|
|
22
|
+
batch: Schema.Array(LiveStoreEvent.AnyEncodedGlobal),
|
|
23
|
+
}).annotations({ title: '@livestore/sync-cf:PushReq' });
|
|
28
24
|
export const PushAck = Schema.TaggedStruct('WSMessage.PushAck', {
|
|
29
25
|
requestId: Schema.String,
|
|
30
|
-
|
|
31
|
-
});
|
|
26
|
+
}).annotations({ title: '@livestore/sync-cf:PushAck' });
|
|
32
27
|
export const Error = Schema.TaggedStruct('WSMessage.Error', {
|
|
33
28
|
requestId: Schema.String,
|
|
34
29
|
message: Schema.String,
|
|
35
|
-
});
|
|
30
|
+
}).annotations({ title: '@livestore/sync-cf:Error' });
|
|
36
31
|
export const Ping = Schema.TaggedStruct('WSMessage.Ping', {
|
|
37
32
|
requestId: Schema.Literal('ping'),
|
|
38
|
-
});
|
|
33
|
+
}).annotations({ title: '@livestore/sync-cf:Ping' });
|
|
39
34
|
export const Pong = Schema.TaggedStruct('WSMessage.Pong', {
|
|
40
35
|
requestId: Schema.Literal('ping'),
|
|
41
|
-
});
|
|
36
|
+
}).annotations({ title: '@livestore/sync-cf:Pong' });
|
|
42
37
|
export const AdminResetRoomReq = Schema.TaggedStruct('WSMessage.AdminResetRoomReq', {
|
|
43
38
|
requestId: Schema.String,
|
|
44
39
|
adminSecret: Schema.String,
|
|
45
|
-
});
|
|
40
|
+
}).annotations({ title: '@livestore/sync-cf:AdminResetRoomReq' });
|
|
46
41
|
export const AdminResetRoomRes = Schema.TaggedStruct('WSMessage.AdminResetRoomRes', {
|
|
47
42
|
requestId: Schema.String,
|
|
48
|
-
});
|
|
43
|
+
}).annotations({ title: '@livestore/sync-cf:AdminResetRoomRes' });
|
|
49
44
|
export const AdminInfoReq = Schema.TaggedStruct('WSMessage.AdminInfoReq', {
|
|
50
45
|
requestId: Schema.String,
|
|
51
46
|
adminSecret: Schema.String,
|
|
52
|
-
});
|
|
47
|
+
}).annotations({ title: '@livestore/sync-cf:AdminInfoReq' });
|
|
53
48
|
export const AdminInfoRes = Schema.TaggedStruct('WSMessage.AdminInfoRes', {
|
|
54
49
|
requestId: Schema.String,
|
|
55
50
|
info: Schema.Struct({
|
|
56
51
|
durableObjectId: Schema.String,
|
|
57
52
|
}),
|
|
58
|
-
});
|
|
59
|
-
export const Message = Schema.Union(PullReq, PullRes,
|
|
60
|
-
export const BackendToClientMessage = Schema.Union(PullRes,
|
|
53
|
+
}).annotations({ title: '@livestore/sync-cf:AdminInfoRes' });
|
|
54
|
+
export const Message = Schema.Union(PullReq, PullRes, PushReq, PushAck, Error, Ping, Pong, AdminResetRoomReq, AdminResetRoomRes, AdminInfoReq, AdminInfoRes).annotations({ title: '@livestore/sync-cf:Message' });
|
|
55
|
+
export const BackendToClientMessage = Schema.Union(PullRes, PushAck, AdminResetRoomRes, AdminInfoRes, Error, Pong);
|
|
61
56
|
export const ClientToBackendMessage = Schema.Union(PullReq, PushReq, AdminResetRoomReq, AdminInfoReq, Ping);
|
|
62
57
|
//# sourceMappingURL=ws-message-types.js.map
|