@livestore/sync-cf 0.2.0 → 0.3.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/dist/.tsbuildinfo +1 -1
- package/dist/cf-worker/durable-object.d.ts +40 -34
- package/dist/cf-worker/durable-object.d.ts.map +1 -1
- package/dist/cf-worker/durable-object.js +158 -123
- package/dist/cf-worker/durable-object.js.map +1 -1
- package/dist/cf-worker/index.d.ts +1 -6
- package/dist/cf-worker/index.d.ts.map +1 -1
- package/dist/cf-worker/index.js +30 -64
- package/dist/cf-worker/index.js.map +1 -1
- package/dist/cf-worker/make-worker.d.ts +6 -0
- package/dist/cf-worker/make-worker.d.ts.map +1 -0
- package/dist/cf-worker/make-worker.js +31 -0
- package/dist/cf-worker/make-worker.js.map +1 -0
- 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/types.d.ts +2 -0
- package/dist/cf-worker/types.d.ts.map +1 -0
- package/dist/cf-worker/types.js +2 -0
- package/dist/cf-worker/types.js.map +1 -0
- package/dist/cf-worker/worker.d.ts +6 -0
- package/dist/cf-worker/worker.d.ts.map +1 -0
- package/dist/cf-worker/worker.js +29 -0
- package/dist/cf-worker/worker.js.map +1 -0
- package/dist/common/mod.d.ts +2 -0
- package/dist/common/mod.d.ts.map +1 -0
- package/dist/common/mod.js +2 -0
- package/dist/common/mod.js.map +1 -0
- package/dist/common/ws-message-types.d.ts +92 -216
- package/dist/common/ws-message-types.d.ts.map +1 -1
- package/dist/common/ws-message-types.js +13 -9
- 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 +5 -13
- package/dist/sync-impl/ws-impl.d.ts.map +1 -1
- package/dist/sync-impl/ws-impl.js +69 -69
- package/dist/sync-impl/ws-impl.js.map +1 -1
- package/package.json +17 -8
- package/src/cf-worker/durable-object.ts +233 -153
- package/src/cf-worker/mod.ts +2 -0
- package/src/cf-worker/worker.ts +39 -0
- package/src/common/ws-message-types.ts +18 -9
- package/src/sync-impl/ws-impl.ts +120 -121
- package/.netlify/state.json +0 -3
- package/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/8ee300993f9a2c909aede59646369fa0cc28d25304b9b9af94f54d4543ad60f4.sqlite +0 -0
- package/.wrangler/state/v3/do/websocket-server-WebSocketServer/2c3676d859102e448b271e1b4336b1e40778992b14728e2a2bd642c0f225e9c5.sqlite +0 -0
- package/.wrangler/state/v3/do/websocket-server-WebSocketServer/6eb1111cecdc6ae7e3a38c3d7db0f3ec7de5b318e682cdcf0ff0dc881cbbcee7.sqlite +0 -0
- package/.wrangler/state/v3/do/websocket-server-WebSocketServer/c4aa0e61dcd784604bee52282348e0538ab69ec76e1652322bbccd539d9ff3ee.sqlite +0 -0
- package/.wrangler/state/v3/do/websocket-server-WebSocketServer/d87433156774c933da83e962eba16107cf02ade2f133d7205963558fe47db3ff.sqlite +0 -0
- package/.wrangler/tmp/dev-33iU4b/index.js +0 -42167
- package/.wrangler/tmp/dev-33iU4b/index.js.map +0 -8
- package/.wrangler/tmp/dev-9rcIR8/index.js +0 -18887
- package/.wrangler/tmp/dev-9rcIR8/index.js.map +0 -8
- package/.wrangler/tmp/dev-rI63Kk/index.js +0 -42165
- package/.wrangler/tmp/dev-rI63Kk/index.js.map +0 -8
- package/.wrangler/tmp/dev-txPodK/index.js +0 -42118
- package/.wrangler/tmp/dev-txPodK/index.js.map +0 -8
- package/src/cf-worker/index.ts +0 -84
- package/tsconfig.json +0 -12
- package/wrangler.toml +0 -21
- /package/src/common/{index.ts → mod.ts} +0 -0
- /package/src/sync-impl/{index.ts → mod.ts} +0 -0
|
@@ -1,44 +1,50 @@
|
|
|
1
|
-
import { DbSchema
|
|
2
|
-
import { Schema } from '@livestore/utils/effect';
|
|
1
|
+
import { DbSchema } from '@livestore/common/schema';
|
|
2
|
+
import { Effect, Option, Schema } from '@livestore/utils/effect';
|
|
3
3
|
import { DurableObject } from 'cloudflare:workers';
|
|
4
|
+
import { WSMessage } from '../common/mod.js';
|
|
4
5
|
export interface Env {
|
|
5
|
-
WEBSOCKET_SERVER: DurableObjectNamespace
|
|
6
|
+
WEBSOCKET_SERVER: DurableObjectNamespace;
|
|
6
7
|
DB: D1Database;
|
|
7
8
|
ADMIN_SECRET: string;
|
|
8
9
|
}
|
|
9
|
-
type WebSocketClient = WebSocket;
|
|
10
10
|
export declare const mutationLogTable: DbSchema.TableDef<{
|
|
11
11
|
name: "__unused";
|
|
12
12
|
columns: {
|
|
13
|
-
|
|
13
|
+
id: {
|
|
14
14
|
columnType: "integer";
|
|
15
|
-
schema: Schema.Schema<number
|
|
16
|
-
default:
|
|
15
|
+
schema: Schema.Schema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
|
|
16
|
+
default: Option.None<never>;
|
|
17
17
|
nullable: false;
|
|
18
18
|
primaryKey: true;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
parentId: {
|
|
21
21
|
columnType: "integer";
|
|
22
|
-
schema: Schema.Schema<number
|
|
23
|
-
default:
|
|
22
|
+
schema: Schema.Schema<number & import("effect/Brand").Brand<"GlobalEventId">, number, never>;
|
|
23
|
+
default: Option.None<never>;
|
|
24
24
|
nullable: false;
|
|
25
25
|
primaryKey: false;
|
|
26
26
|
};
|
|
27
27
|
mutation: {
|
|
28
28
|
columnType: "text";
|
|
29
29
|
schema: Schema.Schema<string, string, never>;
|
|
30
|
-
default:
|
|
30
|
+
default: Option.None<never>;
|
|
31
31
|
nullable: false;
|
|
32
32
|
primaryKey: false;
|
|
33
33
|
};
|
|
34
34
|
args: {
|
|
35
35
|
columnType: "text";
|
|
36
36
|
schema: Schema.Schema<any, string, never>;
|
|
37
|
-
default:
|
|
37
|
+
default: Option.None<never>;
|
|
38
|
+
nullable: false;
|
|
39
|
+
primaryKey: false;
|
|
40
|
+
};
|
|
41
|
+
createdAt: {
|
|
42
|
+
columnType: "text";
|
|
43
|
+
schema: Schema.Schema<string, string, never>;
|
|
44
|
+
default: Option.None<never>;
|
|
38
45
|
nullable: false;
|
|
39
46
|
primaryKey: false;
|
|
40
47
|
};
|
|
41
|
-
id: DbSchema.SqliteDsl.ColumnDefinition<string, string>;
|
|
42
48
|
};
|
|
43
49
|
indexes?: ReadonlyArray<DbSchema.SqliteDsl.Index>;
|
|
44
50
|
ast: import("@livestore/db-schema/dist/ast/sqlite.js").Table;
|
|
@@ -47,32 +53,32 @@ export declare const mutationLogTable: DbSchema.TableDef<{
|
|
|
47
53
|
disableAutomaticIdColumn: false;
|
|
48
54
|
deriveMutations: never;
|
|
49
55
|
isSingleColumn: false;
|
|
50
|
-
requiredInsertColumnNames: "
|
|
56
|
+
requiredInsertColumnNames: "createdAt" | "mutation" | "args" | "id" | "parentId";
|
|
51
57
|
}, Schema.Schema<{
|
|
52
|
-
readonly
|
|
53
|
-
readonly
|
|
58
|
+
readonly id: number & import("effect/Brand").Brand<"GlobalEventId">;
|
|
59
|
+
readonly parentId: number & import("effect/Brand").Brand<"GlobalEventId">;
|
|
54
60
|
readonly mutation: string;
|
|
55
61
|
readonly args: any;
|
|
56
|
-
readonly
|
|
62
|
+
readonly createdAt: string;
|
|
57
63
|
}, {
|
|
58
|
-
readonly
|
|
59
|
-
readonly
|
|
64
|
+
readonly id: number;
|
|
65
|
+
readonly parentId: number;
|
|
60
66
|
readonly mutation: string;
|
|
61
67
|
readonly args: string;
|
|
62
|
-
readonly
|
|
68
|
+
readonly createdAt: string;
|
|
63
69
|
}, never>>;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
export
|
|
70
|
+
/**
|
|
71
|
+
* Needs to be bumped when the storage format changes (e.g. mutationLogTable schema changes)
|
|
72
|
+
*
|
|
73
|
+
* Changing this version number will lead to a "soft reset".
|
|
74
|
+
*/
|
|
75
|
+
export declare const PERSISTENCE_FORMAT_VERSION = 2;
|
|
76
|
+
export type MakeDurableObjectClassOptions = {
|
|
77
|
+
onPush?: (message: WSMessage.PushReq) => Effect.Effect<void> | Promise<void>;
|
|
78
|
+
onPull?: (message: WSMessage.PullReq) => Effect.Effect<void> | Promise<void>;
|
|
79
|
+
};
|
|
80
|
+
export type MakeDurableObjectClass = (options?: MakeDurableObjectClassOptions) => {
|
|
81
|
+
new (ctx: DurableObjectState, env: Env): DurableObject<Env>;
|
|
82
|
+
};
|
|
83
|
+
export declare const makeDurableObject: MakeDurableObjectClass;
|
|
78
84
|
//# sourceMappingURL=durable-object.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable-object.d.ts","sourceRoot":"","sources":["../../src/cf-worker/durable-object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"durable-object.d.ts","sourceRoot":"","sources":["../../src/cf-worker/durable-object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAA+B,MAAM,0BAA0B,CAAA;AAEhF,OAAO,EAAE,MAAM,EAAoB,MAAM,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAG5C,MAAM,WAAW,GAAG;IAClB,gBAAgB,EAAE,sBAAsB,CAAA;IACxC,EAAE,EAAE,UAAU,CAAA;IACd,YAAY,EAAE,MAAM,CAAA;CACrB;AASD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAO3B,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAA;AAE3C,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5E,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7E,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,CAAC,EAAE,6BAA6B,KAAK;IAChF,KAAK,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;CAC5D,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,sBAkM/B,CAAA"}
|
|
@@ -1,166 +1,201 @@
|
|
|
1
|
-
import { makeColumnSpec
|
|
2
|
-
import { DbSchema,
|
|
1
|
+
import { makeColumnSpec } from '@livestore/common';
|
|
2
|
+
import { DbSchema, EventId } from '@livestore/common/schema';
|
|
3
3
|
import { shouldNeverHappen } from '@livestore/utils';
|
|
4
|
-
import { Effect, Schema } from '@livestore/utils/effect';
|
|
4
|
+
import { Effect, Logger, LogLevel, Option, Schema } from '@livestore/utils/effect';
|
|
5
5
|
import { DurableObject } from 'cloudflare:workers';
|
|
6
|
-
import { WSMessage } from '../common/
|
|
6
|
+
import { WSMessage } from '../common/mod.js';
|
|
7
7
|
const encodeOutgoingMessage = Schema.encodeSync(Schema.parseJson(WSMessage.BackendToClientMessage));
|
|
8
8
|
const encodeIncomingMessage = Schema.encodeSync(Schema.parseJson(WSMessage.ClientToBackendMessage));
|
|
9
9
|
const decodeIncomingMessage = Schema.decodeUnknownEither(Schema.parseJson(WSMessage.ClientToBackendMessage));
|
|
10
|
+
// NOTE actual table name is determined at runtime by `WebSocketServer.dbName`
|
|
10
11
|
export const mutationLogTable = DbSchema.table('__unused', {
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
id: DbSchema.integer({ primaryKey: true, schema: EventId.GlobalEventId }),
|
|
13
|
+
parentId: DbSchema.integer({ schema: EventId.GlobalEventId }),
|
|
13
14
|
mutation: DbSchema.text({}),
|
|
14
15
|
args: DbSchema.text({ schema: Schema.parseJson(Schema.Any) }),
|
|
16
|
+
/** ISO date format. Currently only used for debugging purposes. */
|
|
17
|
+
createdAt: DbSchema.text({}),
|
|
15
18
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.ctx.setWebSocketAutoResponse(new WebSocketRequestResponsePair(encodeIncomingMessage(WSMessage.Ping.make({ requestId: 'ping' })), encodeOutgoingMessage(WSMessage.Pong.make({ requestId: 'ping' }))));
|
|
28
|
-
const colSpec = makeColumnSpec(mutationLogTable.sqliteDef.ast);
|
|
29
|
-
this.env.DB.exec(`CREATE TABLE IF NOT EXISTS ${this.dbName} (${colSpec}) strict`);
|
|
30
|
-
return new Response(null, {
|
|
31
|
-
status: 101,
|
|
32
|
-
webSocket: client,
|
|
33
|
-
});
|
|
34
|
-
}).pipe(Effect.tapCauseLogPretty, Effect.runPromise);
|
|
35
|
-
webSocketMessage = async (ws, message) => {
|
|
36
|
-
const decodedMessageRes = decodeIncomingMessage(message);
|
|
37
|
-
if (decodedMessageRes._tag === 'Left') {
|
|
38
|
-
console.error('Invalid message received', decodedMessageRes.left);
|
|
39
|
-
return;
|
|
19
|
+
/**
|
|
20
|
+
* Needs to be bumped when the storage format changes (e.g. mutationLogTable schema changes)
|
|
21
|
+
*
|
|
22
|
+
* Changing this version number will lead to a "soft reset".
|
|
23
|
+
*/
|
|
24
|
+
export const PERSISTENCE_FORMAT_VERSION = 2;
|
|
25
|
+
export const makeDurableObject = (options) => {
|
|
26
|
+
return class WebSocketServerBase extends DurableObject {
|
|
27
|
+
storage = undefined;
|
|
28
|
+
constructor(ctx, env) {
|
|
29
|
+
super(ctx, env);
|
|
40
30
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
31
|
+
fetch = async (request) => Effect.gen(this, function* () {
|
|
32
|
+
if (this.storage === undefined) {
|
|
33
|
+
const storeId = getStoreId(request);
|
|
34
|
+
const dbName = `mutation_log_${PERSISTENCE_FORMAT_VERSION}_${toValidTableName(storeId)}`;
|
|
35
|
+
this.storage = makeStorage(this.ctx, this.env, dbName);
|
|
36
|
+
}
|
|
37
|
+
const { 0: client, 1: server } = new WebSocketPair();
|
|
38
|
+
// See https://developers.cloudflare.com/durable-objects/examples/websocket-hibernation-server
|
|
39
|
+
this.ctx.acceptWebSocket(server);
|
|
40
|
+
this.ctx.setWebSocketAutoResponse(new WebSocketRequestResponsePair(encodeIncomingMessage(WSMessage.Ping.make({ requestId: 'ping' })), encodeOutgoingMessage(WSMessage.Pong.make({ requestId: 'ping' }))));
|
|
41
|
+
const colSpec = makeColumnSpec(mutationLogTable.sqliteDef.ast);
|
|
42
|
+
this.env.DB.exec(`CREATE TABLE IF NOT EXISTS ${this.storage.dbName} (${colSpec}) strict`);
|
|
43
|
+
return new Response(null, {
|
|
44
|
+
status: 101,
|
|
45
|
+
webSocket: client,
|
|
46
|
+
});
|
|
47
|
+
}).pipe(Effect.tapCauseLogPretty, Effect.runPromise);
|
|
48
|
+
webSocketMessage = (ws, message) => Effect.gen(this, function* () {
|
|
49
|
+
const decodedMessageRes = decodeIncomingMessage(message);
|
|
50
|
+
if (decodedMessageRes._tag === 'Left') {
|
|
51
|
+
console.error('Invalid message received', decodedMessageRes.left);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const decodedMessage = decodedMessageRes.right;
|
|
55
|
+
const requestId = decodedMessage.requestId;
|
|
56
|
+
const storage = this.storage;
|
|
57
|
+
if (storage === undefined) {
|
|
58
|
+
throw new Error('storage not initialized');
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
switch (decodedMessage._tag) {
|
|
62
|
+
case 'WSMessage.PullReq': {
|
|
63
|
+
if (options?.onPull) {
|
|
64
|
+
yield* Effect.tryAll(() => options.onPull(decodedMessage));
|
|
65
|
+
}
|
|
66
|
+
const cursor = decodedMessage.cursor;
|
|
67
|
+
const CHUNK_SIZE = 100;
|
|
68
|
+
// TODO use streaming
|
|
69
|
+
const remainingEvents = [...(yield* Effect.promise(() => storage.getEvents(cursor)))];
|
|
70
|
+
// NOTE we want to make sure the WS server responds at least once with `InitRes` even if `events` is empty
|
|
71
|
+
while (true) {
|
|
72
|
+
const events = remainingEvents.splice(0, CHUNK_SIZE);
|
|
73
|
+
ws.send(encodeOutgoingMessage(WSMessage.PullRes.make({ events, remaining: remainingEvents.length, requestId })));
|
|
74
|
+
if (remainingEvents.length === 0) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
58
77
|
}
|
|
78
|
+
break;
|
|
59
79
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
80
|
+
case 'WSMessage.PushReq': {
|
|
81
|
+
if (options?.onPush) {
|
|
82
|
+
yield* Effect.tryAll(() => options.onPush(decodedMessage));
|
|
83
|
+
}
|
|
84
|
+
// TODO check whether we could use the Durable Object storage for this to speed up the lookup
|
|
85
|
+
const latestEvent = yield* Effect.promise(() => storage.getLatestEvent());
|
|
86
|
+
const expectedParentId = latestEvent?.id ?? EventId.ROOT.global;
|
|
87
|
+
let i = 0;
|
|
88
|
+
for (const mutationEventEncoded of decodedMessage.batch) {
|
|
89
|
+
if (mutationEventEncoded.parentId !== expectedParentId + i) {
|
|
90
|
+
const err = WSMessage.Error.make({
|
|
91
|
+
message: `Invalid parent id. Received ${mutationEventEncoded.parentId} but expected ${expectedParentId}`,
|
|
92
|
+
requestId,
|
|
93
|
+
});
|
|
94
|
+
yield* Effect.fail(err).pipe(Effect.ignoreLogged);
|
|
95
|
+
ws.send(encodeOutgoingMessage(err));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// TODO handle clientId unique conflict
|
|
99
|
+
const createdAt = new Date().toISOString();
|
|
100
|
+
// NOTE we're currently not blocking on this to allow broadcasting right away
|
|
101
|
+
const storePromise = storage.appendEvent(mutationEventEncoded, createdAt);
|
|
102
|
+
ws.send(encodeOutgoingMessage(WSMessage.PushAck.make({ mutationId: mutationEventEncoded.id, requestId })));
|
|
103
|
+
// console.debug(`Broadcasting mutation event to ${this.subscribedWebSockets.size} clients`)
|
|
104
|
+
const connectedClients = this.ctx.getWebSockets();
|
|
105
|
+
if (connectedClients.length > 0) {
|
|
106
|
+
const broadcastMessage = encodeOutgoingMessage(
|
|
107
|
+
// TODO refactor to batch api
|
|
108
|
+
WSMessage.PushBroadcast.make({
|
|
109
|
+
mutationEventEncoded,
|
|
110
|
+
metadata: Option.some({ createdAt }),
|
|
111
|
+
}));
|
|
112
|
+
for (const conn of connectedClients) {
|
|
113
|
+
console.log('Broadcasting to client', conn === ws ? 'self' : 'other');
|
|
114
|
+
// if (conn !== ws) {
|
|
115
|
+
conn.send(broadcastMessage);
|
|
116
|
+
// }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
yield* Effect.promise(() => storePromise);
|
|
120
|
+
i++;
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
72
123
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
: Promise.resolve();
|
|
78
|
-
ws.send(encodeOutgoingMessage(WSMessage.PushAck.make({ mutationId: decodedMessage.mutationEventEncoded.id.global, requestId })));
|
|
79
|
-
// console.debug(`Broadcasting mutation event to ${this.subscribedWebSockets.size} clients`)
|
|
80
|
-
const connectedClients = this.ctx.getWebSockets();
|
|
81
|
-
if (connectedClients.length > 0) {
|
|
82
|
-
const broadcastMessage = encodeOutgoingMessage(WSMessage.PushBroadcast.make({
|
|
83
|
-
mutationEventEncoded: decodedMessage.mutationEventEncoded,
|
|
84
|
-
persisted: decodedMessage.persisted,
|
|
85
|
-
}));
|
|
86
|
-
for (const conn of connectedClients) {
|
|
87
|
-
console.log('Broadcasting to client', conn === ws ? 'self' : 'other');
|
|
88
|
-
// if (conn !== ws) {
|
|
89
|
-
conn.send(broadcastMessage);
|
|
90
|
-
// }
|
|
124
|
+
case 'WSMessage.AdminResetRoomReq': {
|
|
125
|
+
if (decodedMessage.adminSecret !== this.env.ADMIN_SECRET) {
|
|
126
|
+
ws.send(encodeOutgoingMessage(WSMessage.Error.make({ message: 'Invalid admin secret', requestId })));
|
|
127
|
+
return;
|
|
91
128
|
}
|
|
129
|
+
yield* Effect.promise(() => storage.resetRoom());
|
|
130
|
+
ws.send(encodeOutgoingMessage(WSMessage.AdminResetRoomRes.make({ requestId })));
|
|
131
|
+
break;
|
|
92
132
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
ws.send(encodeOutgoingMessage(WSMessage.
|
|
99
|
-
|
|
133
|
+
case 'WSMessage.AdminInfoReq': {
|
|
134
|
+
if (decodedMessage.adminSecret !== this.env.ADMIN_SECRET) {
|
|
135
|
+
ws.send(encodeOutgoingMessage(WSMessage.Error.make({ message: 'Invalid admin secret', requestId })));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
ws.send(encodeOutgoingMessage(WSMessage.AdminInfoRes.make({ requestId, info: { durableObjectId: this.ctx.id.toString() } })));
|
|
139
|
+
break;
|
|
100
140
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
case 'WSMessage.AdminInfoReq': {
|
|
106
|
-
if (decodedMessage.adminSecret !== this.env.ADMIN_SECRET) {
|
|
107
|
-
ws.send(encodeOutgoingMessage(WSMessage.Error.make({ message: 'Invalid admin secret', requestId })));
|
|
108
|
-
return;
|
|
141
|
+
default: {
|
|
142
|
+
console.error('unsupported message', decodedMessage);
|
|
143
|
+
return shouldNeverHappen();
|
|
109
144
|
}
|
|
110
|
-
ws.send(encodeOutgoingMessage(WSMessage.AdminInfoRes.make({ requestId, info: { durableObjectId: this.ctx.id.toString() } })));
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
default: {
|
|
114
|
-
console.error('unsupported message', decodedMessage);
|
|
115
|
-
return shouldNeverHappen();
|
|
116
145
|
}
|
|
117
146
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
147
|
+
catch (error) {
|
|
148
|
+
ws.send(encodeOutgoingMessage(WSMessage.Error.make({ message: error.message, requestId })));
|
|
149
|
+
}
|
|
150
|
+
}).pipe(Effect.withSpan('@livestore/sync-cf:durable-object:webSocketMessage'), Effect.tapCauseLogPretty, Logger.withMinimumLogLevel(LogLevel.Debug), Effect.provide(Logger.pretty), Effect.runPromise);
|
|
151
|
+
webSocketClose = async (ws, code, _reason, _wasClean) => {
|
|
152
|
+
// If the client closes the connection, the runtime will invoke the webSocketClose() handler.
|
|
153
|
+
ws.close(code, 'Durable Object is closing WebSocket');
|
|
154
|
+
};
|
|
126
155
|
};
|
|
127
|
-
}
|
|
156
|
+
};
|
|
128
157
|
const makeStorage = (ctx, env, dbName) => {
|
|
129
158
|
const getLatestEvent = async () => {
|
|
130
|
-
const rawEvents = await env.DB.prepare(`SELECT * FROM ${dbName} ORDER BY
|
|
159
|
+
const rawEvents = await env.DB.prepare(`SELECT * FROM ${dbName} ORDER BY id DESC LIMIT 1`).all();
|
|
131
160
|
if (rawEvents.error) {
|
|
132
161
|
throw new Error(rawEvents.error);
|
|
133
162
|
}
|
|
134
|
-
const events = Schema.decodeUnknownSync(Schema.Array(mutationLogTable.schema))(rawEvents.results)
|
|
135
|
-
...e,
|
|
136
|
-
id: { global: e.idGlobal, local: 0 },
|
|
137
|
-
parentId: { global: e.parentIdGlobal, local: 0 },
|
|
138
|
-
}));
|
|
163
|
+
const events = Schema.decodeUnknownSync(Schema.Array(mutationLogTable.schema))(rawEvents.results);
|
|
139
164
|
return events[0];
|
|
140
165
|
};
|
|
141
166
|
const getEvents = async (cursor) => {
|
|
142
|
-
const whereClause = cursor ? `WHERE
|
|
167
|
+
const whereClause = cursor === undefined ? '' : `WHERE id > ${cursor}`;
|
|
168
|
+
const sql = `SELECT * FROM ${dbName} ${whereClause} ORDER BY id ASC`;
|
|
143
169
|
// TODO handle case where `cursor` was not found
|
|
144
|
-
const rawEvents = await env.DB.prepare(
|
|
170
|
+
const rawEvents = await env.DB.prepare(sql).all();
|
|
145
171
|
if (rawEvents.error) {
|
|
146
172
|
throw new Error(rawEvents.error);
|
|
147
173
|
}
|
|
148
|
-
const events = Schema.decodeUnknownSync(Schema.Array(mutationLogTable.schema))(rawEvents.results).map((
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
parentId: { global: e.parentIdGlobal, local: 0 },
|
|
174
|
+
const events = Schema.decodeUnknownSync(Schema.Array(mutationLogTable.schema))(rawEvents.results).map(({ createdAt, ...mutationEventEncoded }) => ({
|
|
175
|
+
mutationEventEncoded,
|
|
176
|
+
metadata: Option.some({ createdAt }),
|
|
152
177
|
}));
|
|
153
178
|
return events;
|
|
154
179
|
};
|
|
155
|
-
const appendEvent = async (event) => {
|
|
156
|
-
const sql = `INSERT INTO ${dbName} (
|
|
180
|
+
const appendEvent = async (event, createdAt) => {
|
|
181
|
+
const sql = `INSERT INTO ${dbName} (id, parentId, args, mutation, createdAt) VALUES (?, ?, ?, ?, ?)`;
|
|
157
182
|
await env.DB.prepare(sql)
|
|
158
|
-
.bind(event.id
|
|
183
|
+
.bind(event.id, event.parentId, JSON.stringify(event.args), event.mutation, createdAt)
|
|
159
184
|
.run();
|
|
160
185
|
};
|
|
161
186
|
const resetRoom = async () => {
|
|
162
187
|
await ctx.storage.deleteAll();
|
|
163
188
|
};
|
|
164
|
-
return { getLatestEvent, getEvents, appendEvent, resetRoom };
|
|
189
|
+
return { dbName, getLatestEvent, getEvents, appendEvent, resetRoom };
|
|
190
|
+
};
|
|
191
|
+
const getStoreId = (request) => {
|
|
192
|
+
const url = new URL(request.url);
|
|
193
|
+
const searchParams = url.searchParams;
|
|
194
|
+
const storeId = searchParams.get('storeId');
|
|
195
|
+
if (storeId === null) {
|
|
196
|
+
throw new Error('storeId search param is required');
|
|
197
|
+
}
|
|
198
|
+
return storeId;
|
|
165
199
|
};
|
|
200
|
+
const toValidTableName = (str) => str.replaceAll(/[^a-zA-Z0-9]/g, '_');
|
|
166
201
|
//# sourceMappingURL=durable-object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable-object.js","sourceRoot":"","sources":["../../src/cf-worker/durable-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"durable-object.js","sourceRoot":"","sources":["../../src/cf-worker/durable-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAsB,MAAM,0BAA0B,CAAA;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAClF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AS,CAAC;aACrF,GAAG,EAAE,CAAA;IACV,CAAC,CAAA;IAED,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;QAC3B,MAAM,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAA;IAC/B,CAAC,CAAA;IAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,CAAA;AACtE,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAE,EAAE;IACtC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAChC,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,CAAA;IACrC,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IAC3C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;IACrD,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG,CAAC,CAAA"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
/// <reference no-default-lib="true"/>
|
|
2
|
-
|
|
3
|
-
export * from './durable-object.js';
|
|
4
|
-
declare const _default: {
|
|
5
|
-
fetch: (request: Request, env: Env, _ctx: ExecutionContext) => Promise<Response>;
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
2
|
+
export {};
|
|
8
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cf-worker/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cf-worker/index.ts"],"names":[],"mappings":""}
|