@firtoz/drizzle-sqlite-wasm 0.2.16 → 0.2.17

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-sqlite-wasm
2
2
 
3
+ ## 0.2.17
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.16
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -227,7 +227,11 @@ Create TanStack DB collections backed by SQLite:
227
227
 
228
228
  ```typescript
229
229
  import { createCollection } from "@tanstack/db";
230
- import { drizzleCollectionOptions } from "@firtoz/drizzle-sqlite-wasm/drizzleCollectionOptions";
230
+ import {
231
+ drizzleCollectionOptions,
232
+ type DrizzleSqliteCollection,
233
+ } from "@firtoz/drizzle-sqlite-wasm";
234
+ import * as schema from "./schema";
231
235
 
232
236
  const collection = createCollection(
233
237
  drizzleCollectionOptions({
@@ -249,12 +253,16 @@ const completed = await collection.find({
249
253
  orderBy: { createdAt: "desc" },
250
254
  });
251
255
 
256
+ type TodosCollection = DrizzleSqliteCollection<typeof schema.todoTable>;
257
+
252
258
  // Subscribe to changes
253
259
  collection.subscribe((todos) => {
254
260
  console.log("Todos updated:", todos);
255
261
  });
256
262
  ```
257
263
 
264
+ Use `DrizzleSqliteCollection<TTable>` when you want a reusable collection type alias that keeps inferred select/insert types from your table.
265
+
258
266
  ### Collection Options
259
267
 
260
268
  **Config:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firtoz/drizzle-sqlite-wasm",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "description": "Drizzle SQLite WASM bindings",
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,
@@ -67,8 +70,9 @@ export type ValidTableNames<TSchema extends Record<string, unknown>> = {
67
70
  export type SqliteCollectionConfig<TTable extends Table> = Omit<
68
71
  CollectionConfig<
69
72
  InferSchemaOutput<SelectSchema<TTable>>,
70
- string,
71
- InsertToSelectSchema<TTable>
73
+ IdOf<TTable>,
74
+ InsertToSelectSchema<TTable>,
75
+ CollectionUtils<InferSchemaOutput<SelectSchema<TTable>>>
72
76
  >,
73
77
  "utils"
74
78
  > & {
@@ -76,6 +80,15 @@ export type SqliteCollectionConfig<TTable extends Table> = Omit<
76
80
  utils: CollectionUtils<InferSchemaOutput<SelectSchema<TTable>>>;
77
81
  };
78
82
 
83
+ export type DrizzleSqliteCollection<TTable extends TableWithRequiredFields> =
84
+ Collection<
85
+ InferSchemaOutput<SelectSchema<TTable>>,
86
+ IdOf<TTable>,
87
+ CollectionUtils<InferSchemaOutput<SelectSchema<TTable>>>,
88
+ InsertToSelectSchema<TTable>,
89
+ InferSchemaInput<InsertToSelectSchema<TTable>>
90
+ >;
91
+
79
92
  export function sqliteCollectionOptions<
80
93
  const TDrizzle extends AnyDrizzleDatabase,
81
94
  const TTableName extends string & ValidTableNames<DrizzleSchema<TDrizzle>>,
package/src/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { drizzleSqliteWasm } from "./drizzle/direct";
2
2
  export {
3
3
  sqliteCollectionOptions as drizzleCollectionOptions,
4
+ type DrizzleSqliteCollection,
5
+ type SqliteCollectionConfig,
4
6
  type SQLOperation,
5
7
  type SQLInterceptor,
6
8
  } from "./collections/sqlite-collection";