@firtoz/drizzle-durable-sqlite 0.2.0 → 0.2.1

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,11 @@
1
1
  # @firtoz/drizzle-durable-sqlite
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8b839f2`](https://github.com/firtoz/fullstack-toolkit/commit/8b839f2227f50409af649aab87178e039aad55dc) Thanks [@firtoz](https://github.com/firtoz)! - Export collection helper types for Drizzle-backed TanStack DB collections so users can declare collection variables with preserved select and insert inference from table schemas.
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -79,6 +79,8 @@ Use `durableSqliteCollectionOptions` with tables built via `syncableTable` from
79
79
 
80
80
  If something else must finish before sync runs (e.g. a migration promise), pass `readyPromise`. When omitted, the collection treats storage as ready immediately (same as `Promise.resolve()`).
81
81
 
82
+ For explicit collection type annotations, use `DurableSqliteCollection<TTable>`. It preserves select output typing and insert input typing from your Drizzle table schema.
83
+
82
84
  Example `schema.ts`:
83
85
 
84
86
  ```typescript
@@ -107,13 +109,16 @@ import { createCollection } from "@tanstack/db";
107
109
  import type { DrizzleSqliteDODatabase } from "drizzle-orm/durable-sqlite";
108
110
  import { drizzle } from "drizzle-orm/durable-sqlite";
109
111
  import { migrate } from "drizzle-orm/durable-sqlite/migrator";
112
+ import {
113
+ durableSqliteCollectionOptions,
114
+ type DurableSqliteCollection,
115
+ } from "@firtoz/drizzle-durable-sqlite";
110
116
  import { Hono } from "hono";
111
117
  import { z } from "zod";
112
- import { durableSqliteCollectionOptions } from "@firtoz/drizzle-durable-sqlite";
113
118
  import migrations from "../drizzle/migrations.js";
114
119
  import * as schema from "./schema";
115
120
 
116
- type TodosCollection = ReturnType<typeof createCollection>;
121
+ type TodosCollection = DurableSqliteCollection<typeof schema.todosTable>;
117
122
 
118
123
  export class TodosDurableObject extends DurableObject<Env> {
119
124
  private db!: DrizzleSqliteDODatabase<typeof schema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firtoz/drizzle-durable-sqlite",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
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",
@@ -1,4 +1,6 @@
1
1
  import type {
2
+ Collection,
3
+ InferSchemaInput,
2
4
  InferSchemaOutput,
3
5
  SyncMode,
4
6
  CollectionConfig,
@@ -11,6 +13,7 @@ import type {
11
13
  InsertToSelectSchema,
12
14
  TableWithRequiredFields,
13
15
  BaseSyncConfig,
16
+ IdOf,
14
17
  } from "@firtoz/drizzle-utils";
15
18
  import {
16
19
  createSyncFunction,
@@ -59,8 +62,9 @@ export type ValidTableNames<TSchema extends Record<string, unknown>> = {
59
62
  export type DurableSqliteCollectionConfigResult<TTable extends Table> = Omit<
60
63
  CollectionConfig<
61
64
  InferSchemaOutput<SelectSchema<TTable>>,
62
- string,
63
- InsertToSelectSchema<TTable>
65
+ IdOf<TTable>,
66
+ InsertToSelectSchema<TTable>,
67
+ CollectionUtils<InferSchemaOutput<SelectSchema<TTable>>>
64
68
  >,
65
69
  "utils"
66
70
  > & {
@@ -68,6 +72,15 @@ export type DurableSqliteCollectionConfigResult<TTable extends Table> = Omit<
68
72
  utils: CollectionUtils<InferSchemaOutput<SelectSchema<TTable>>>;
69
73
  };
70
74
 
75
+ export type DurableSqliteCollection<TTable extends TableWithRequiredFields> =
76
+ Collection<
77
+ InferSchemaOutput<SelectSchema<TTable>>,
78
+ IdOf<TTable>,
79
+ CollectionUtils<InferSchemaOutput<SelectSchema<TTable>>>,
80
+ InsertToSelectSchema<TTable>,
81
+ InferSchemaInput<InsertToSelectSchema<TTable>>
82
+ >;
83
+
71
84
  /**
72
85
  * TanStack DB collection configuration for a table stored in Durable Object SQLite via Drizzle.
73
86
  *
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ export {
4
4
  type DurableDrizzleSchema,
5
5
  type DurableSqliteCollectionConfig,
6
6
  type DurableSqliteCollectionConfigResult,
7
+ type DurableSqliteCollection,
7
8
  type ValidTableNames,
8
9
  type SQLOperation,
9
10
  type SQLInterceptor,