@firtoz/drizzle-durable-sqlite 1.0.3 → 2.0.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @firtoz/drizzle-durable-sqlite
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#70](https://github.com/firtoz/fullstack-toolkit/pull/70) [`e1c08cb`](https://github.com/firtoz/fullstack-toolkit/commit/e1c08cb803574654d5808a984e358258c4171698) Thanks [@firtoz](https://github.com/firtoz)! - **@firtoz/websocket-do:** `BaseSessionHandlers.handleClose` and `StandardSchemaSessionHandlers.handleClose` receive the session instance (aligned with DO teardown).
8
+
9
+ **@firtoz/drizzle-durable-sqlite:** `handleClose` handlers on bundled DO session wiring match the session-aware `BaseSession` contract.
10
+
11
+ ### Patch Changes
12
+
13
+ - [#70](https://github.com/firtoz/fullstack-toolkit/pull/70) [`d35e718`](https://github.com/firtoz/fullstack-toolkit/commit/d35e718bf3292258c2b0006affc7aad5ecc35208) Thanks [@firtoz](https://github.com/firtoz)! - **@firtoz/websocket-do:** Replace Zod-only `ZodSession`, `ZodWebSocketClient`, `ZodWebSocketDO`, and `zodMsgpack` with Standard Schema v1–based `StandardSchemaSession`, `StandardSchemaWebSocketClient`, `StandardSchemaWebSocketDO`, and `standardSchemaMsgpack`. Add `parseStandardSchema` and a direct dependency on `@standard-schema/spec`. Subpath `./zod-client` is removed; use `./schema-client`. Client `send` is now async (`Promise<void>`). Server session `send`/`broadcast` stay `void` with async validation under the hood. Remove the experimental `@firtoz/websocket-do/ws-rpc-protocol` export; use **`socka/core`** (`defineSocka`, typed RPC) instead.
14
+
15
+ **@firtoz/collection-sync:** `connectSync` / `connect-partial-sync` now use `StandardSchemaWebSocketClient` from `@firtoz/websocket-do/schema-client`.
16
+
17
+ **@firtoz/drizzle-durable-sqlite:** `SyncableDurableObject` and `QueryableDurableObject` extend `StandardSchemaWebSocketDO` / `StandardSchemaSession` and use `createStandardSchemaSession` / `standardSchemaSessionOptions` in constructors.
18
+
19
+ - Updated dependencies [[`ffee5b3`](https://github.com/firtoz/fullstack-toolkit/commit/ffee5b313d073366a10e049dc988c9a9c95719be), [`7eb49ad`](https://github.com/firtoz/fullstack-toolkit/commit/7eb49adb100ffc5187a1f858b013b151db82643f), [`e1c08cb`](https://github.com/firtoz/fullstack-toolkit/commit/e1c08cb803574654d5808a984e358258c4171698), [`d35e718`](https://github.com/firtoz/fullstack-toolkit/commit/d35e718bf3292258c2b0006affc7aad5ecc35208), [`138c394`](https://github.com/firtoz/fullstack-toolkit/commit/138c3944b491ebf2e76b7f2c00d651fd5d788bac), [`d35e718`](https://github.com/firtoz/fullstack-toolkit/commit/d35e718bf3292258c2b0006affc7aad5ecc35208)]:
20
+ - @firtoz/websocket-do@12.0.0
21
+ - @firtoz/collection-sync@5.0.0
22
+ - @firtoz/db-helpers@2.1.1
23
+ - @firtoz/drizzle-utils@1.2.1
24
+
25
+ ## 1.0.4
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies []:
30
+ - @firtoz/websocket-do@10.0.0
31
+ - @firtoz/collection-sync@4.0.0
32
+
3
33
  ## 1.0.3
4
34
 
5
35
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firtoz/drizzle-durable-sqlite",
3
- "version": "1.0.3",
3
+ "version": "2.0.0",
4
4
  "description": "TanStack DB collections backed by Drizzle on Cloudflare Durable Object SQLite",
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -62,21 +62,21 @@
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@cloudflare/workers-types": "^4.20260329.1",
65
- "@tanstack/db": "^0.6.1",
65
+ "@tanstack/db": "^0.6.4",
66
66
  "drizzle-orm": "^0.45.2",
67
67
  "drizzle-valibot": ">=0.4.0",
68
68
  "valibot": ">=1.3.1"
69
69
  },
70
70
  "dependencies": {
71
- "@firtoz/collection-sync": "^3.0.0",
72
- "@firtoz/db-helpers": "^2.1.0",
73
- "@firtoz/drizzle-utils": "^1.2.0",
71
+ "@firtoz/collection-sync": "^5.0.0",
72
+ "@firtoz/db-helpers": "^2.1.1",
73
+ "@firtoz/drizzle-utils": "^1.2.1",
74
74
  "@firtoz/maybe-error": "^1.5.2",
75
- "@firtoz/websocket-do": "^9.0.0"
75
+ "@firtoz/websocket-do": "^12.0.0"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@cloudflare/workers-types": "^4.20260329.1",
79
- "@tanstack/db": "^0.6.1",
79
+ "@tanstack/db": "^0.6.4",
80
80
  "drizzle-orm": "^0.45.2",
81
81
  "drizzle-valibot": "^0.4.2",
82
82
  "hono": "^4.12.9",
@@ -15,9 +15,9 @@ import {
15
15
  } from "@firtoz/collection-sync";
16
16
  import type { SyncMessage } from "@firtoz/db-helpers";
17
17
  import {
18
- ZodSession,
19
- ZodWebSocketDO,
20
- type ZodSessionOptions,
18
+ StandardSchemaSession,
19
+ StandardSchemaWebSocketDO,
20
+ type StandardSchemaSessionOptions,
21
21
  } from "@firtoz/websocket-do";
22
22
  import type { DrizzleSqliteDODatabase } from "drizzle-orm/durable-sqlite";
23
23
  import { drizzle } from "drizzle-orm/durable-sqlite";
@@ -42,7 +42,7 @@ function createSessionCodecOptions<TItem extends PartialSyncRowShape>(
42
42
  enableBufferMessages: boolean,
43
43
  serializeJson?: (value: unknown) => string,
44
44
  deserializeJson?: (raw: string) => unknown,
45
- ): ZodSessionOptions<SyncClientMessage, SyncServerMessage<TItem>> {
45
+ ): StandardSchemaSessionOptions<SyncClientMessage, SyncServerMessage<TItem>> {
46
46
  const clientSchema = createClientMessageSchema();
47
47
  const serverSchema = createServerMessageSchema<TItem>();
48
48
  if (!enableBufferMessages) {
@@ -87,7 +87,7 @@ async function routeQueryableClientMessage<TRow extends MutationSyncRow>(
87
87
  class QueryableSession<
88
88
  TItem extends PartialSyncRowShape,
89
89
  TEnv extends Cloudflare.Env,
90
- > extends ZodSession<
90
+ > extends StandardSchemaSession<
91
91
  SessionData,
92
92
  SyncServerMessage<TItem>,
93
93
  SyncClientMessage,
@@ -98,7 +98,10 @@ class QueryableSession<
98
98
  constructor(
99
99
  websocket: WebSocket,
100
100
  sessions: Map<WebSocket, QueryableSession<TItem, TEnv>>,
101
- options: ZodSessionOptions<SyncClientMessage, SyncServerMessage<TItem>>,
101
+ options: StandardSchemaSessionOptions<
102
+ SyncClientMessage,
103
+ SyncServerMessage<TItem>
104
+ >,
102
105
  private readonly sessionSlot: SessionSlot<TItem>,
103
106
  ) {
104
107
  const generatedClientId = crypto.randomUUID();
@@ -169,7 +172,7 @@ export abstract class QueryableDurableObject<
169
172
  TRow extends PartialSyncRowShape,
170
173
  TSchema extends Record<string, unknown>,
171
174
  TEnv extends Cloudflare.Env = Cloudflare.Env,
172
- > extends ZodWebSocketDO<
175
+ > extends StandardSchemaWebSocketDO<
173
176
  QueryableSession<TRow, TEnv>,
174
177
  SyncClientMessage,
175
178
  SyncServerMessage<TRow>,
@@ -189,7 +192,7 @@ export abstract class QueryableDurableObject<
189
192
  let bridgeRef!: PartialSyncServerBridge<TRow>;
190
193
  const sessionSlot: SessionSlot<TRow> = { pending: [] };
191
194
  super(ctx, env, {
192
- zodSessionOptions: (
195
+ standardSchemaSessionOptions: (
193
196
  sessionCtx: Context<{ Bindings: TEnv }> | undefined,
194
197
  ) => {
195
198
  const useMsgpack =
@@ -202,18 +205,18 @@ export abstract class QueryableDurableObject<
202
205
  config.deserializeJson,
203
206
  );
204
207
  },
205
- createZodSession: (
208
+ createStandardSchemaSession: (
206
209
  _sessionCtx: Context<{ Bindings: TEnv }> | undefined,
207
210
  websocket: WebSocket,
208
- options: ZodSessionOptions<
211
+ options: StandardSchemaSessionOptions<
209
212
  SyncClientMessage,
210
213
  SyncServerMessage<unknown>
211
214
  >,
212
215
  ) =>
213
216
  new QueryableSession<TRow, TEnv>(
214
217
  websocket,
215
- this.sessions as Map<WebSocket, QueryableSession<TRow, TEnv>>,
216
- options as ZodSessionOptions<
218
+ this.sessions,
219
+ options as StandardSchemaSessionOptions<
217
220
  SyncClientMessage,
218
221
  SyncServerMessage<TRow>
219
222
  >,
@@ -18,9 +18,9 @@ import type {
18
18
  TableWithRequiredFields,
19
19
  } from "@firtoz/drizzle-utils";
20
20
  import {
21
- ZodSession,
22
- ZodWebSocketDO,
23
- type ZodSessionOptions,
21
+ StandardSchemaSession,
22
+ StandardSchemaWebSocketDO,
23
+ type StandardSchemaSessionOptions,
24
24
  } from "@firtoz/websocket-do";
25
25
  import {
26
26
  durableSqliteCollectionOptions,
@@ -46,7 +46,7 @@ function createSessionCodecOptions<TItem extends PartialSyncRowShape>(
46
46
  enableBufferMessages: boolean,
47
47
  serializeJson?: (value: unknown) => string,
48
48
  deserializeJson?: (raw: string) => unknown,
49
- ): ZodSessionOptions<SyncClientMessage, SyncServerMessage<TItem>> {
49
+ ): StandardSchemaSessionOptions<SyncClientMessage, SyncServerMessage<TItem>> {
50
50
  const clientSchema = createClientMessageSchema();
51
51
  const serverSchema = createServerMessageSchema<TItem>();
52
52
  if (!enableBufferMessages) {
@@ -69,7 +69,7 @@ function createSessionCodecOptions<TItem extends PartialSyncRowShape>(
69
69
  class SyncTableSession<
70
70
  TItem extends PartialSyncRowShape,
71
71
  TEnv extends Cloudflare.Env,
72
- > extends ZodSession<
72
+ > extends StandardSchemaSession<
73
73
  SessionData,
74
74
  SyncServerMessage<TItem>,
75
75
  SyncClientMessage,
@@ -80,7 +80,10 @@ class SyncTableSession<
80
80
  constructor(
81
81
  websocket: WebSocket,
82
82
  sessions: Map<WebSocket, SyncTableSession<TItem, TEnv>>,
83
- options: ZodSessionOptions<SyncClientMessage, SyncServerMessage<TItem>>,
83
+ options: StandardSchemaSessionOptions<
84
+ SyncClientMessage,
85
+ SyncServerMessage<TItem>
86
+ >,
84
87
  bridge: SyncServerBridge<TItem>,
85
88
  ) {
86
89
  const generatedClientId = crypto.randomUUID();
@@ -115,8 +118,8 @@ export abstract class SyncableDurableObject<
115
118
  TSchema extends Record<string, unknown>,
116
119
  TTableName extends ValidTableNames<TSchema>,
117
120
  TEnv extends Cloudflare.Env = Cloudflare.Env,
118
- > extends ZodWebSocketDO<
119
- // biome-ignore lint/suspicious/noExplicitAny: ZodWebSocketDO session generic is internal; row type is fixed in constructor.
121
+ > extends StandardSchemaWebSocketDO<
122
+ // biome-ignore lint/suspicious/noExplicitAny: StandardSchemaWebSocketDO session generic is internal; row type is fixed in constructor.
120
123
  any,
121
124
  SyncClientMessage,
122
125
  SyncServerMessage<unknown>,
@@ -143,7 +146,7 @@ export abstract class SyncableDurableObject<
143
146
  let bridgeRef!: SyncServerBridge<TRow>;
144
147
 
145
148
  super(ctx, env, {
146
- zodSessionOptions: (
149
+ standardSchemaSessionOptions: (
147
150
  sessionCtx: Context<{ Bindings: TEnv }> | undefined,
148
151
  ) => {
149
152
  const useMsgpack =
@@ -156,18 +159,18 @@ export abstract class SyncableDurableObject<
156
159
  config.deserializeJson,
157
160
  );
158
161
  },
159
- createZodSession: (
162
+ createStandardSchemaSession: (
160
163
  _sessionCtx: Context<{ Bindings: TEnv }> | undefined,
161
164
  websocket: WebSocket,
162
- options: ZodSessionOptions<
165
+ options: StandardSchemaSessionOptions<
163
166
  SyncClientMessage,
164
167
  SyncServerMessage<unknown>
165
168
  >,
166
169
  ) => {
167
170
  return new SyncTableSession<TRow, TEnv>(
168
171
  websocket,
169
- this.sessions as Map<WebSocket, SyncTableSession<TRow, TEnv>>,
170
- options as ZodSessionOptions<
172
+ this.sessions,
173
+ options as StandardSchemaSessionOptions<
171
174
  SyncClientMessage,
172
175
  SyncServerMessage<TRow>
173
176
  >,