tanstack-db-pglite 1.1.3 → 1.1.5

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/drizzle.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import type { CollectionConfig, DeleteMutationFnParams, InsertMutationFnParams, SyncConfig, UpdateMutationFnParams } from '@tanstack/db';
1
+ import type { DeleteMutationFnParams, InsertMutationFnParams, SyncConfig, UpdateMutationFnParams } from '@tanstack/db';
2
2
  import type { IndexColumn, PgTable } from 'drizzle-orm/pg-core';
3
3
  import type { PgliteDatabase } from 'drizzle-orm/pglite';
4
4
  import type { BuildSchema } from 'drizzle-zod';
5
5
  type SyncParams<Table extends PgTable> = Parameters<SyncConfig<Table['$inferSelect'], string>['sync']>[0];
6
- type Schema<Table extends PgTable> = BuildSchema<'select', Table['_']['columns'], undefined, true>;
7
6
  export declare function drizzleCollectionOptions<Table extends PgTable>({ startSync, ...config }: {
8
7
  db: PgliteDatabase<any>;
9
8
  table: Table;
@@ -14,9 +13,34 @@ export declare function drizzleCollectionOptions<Table extends PgTable>({ startS
14
13
  startSync?: boolean;
15
14
  prepare?: () => Promise<unknown> | unknown;
16
15
  sync?: (params: Pick<SyncParams<Table>, 'write' | 'collection'>) => Promise<void>;
17
- }): CollectionConfig<Table['$inferSelect'], string, Schema<Table>, {
18
- runSync: () => Promise<void>;
19
- }> & {
20
- schema: Schema<Table>;
16
+ }): {
17
+ startSync: true;
18
+ sync: {
19
+ sync: (params: {
20
+ collection: import("@tanstack/db").Collection<Table["$inferSelect"], string, any, any, any>;
21
+ begin: (options?: {
22
+ immediate?: boolean;
23
+ }) => void;
24
+ write: (message: import("@tanstack/db").ChangeMessageOrDeleteKeyMessage<Table["$inferSelect"], string>) => void;
25
+ commit: () => void;
26
+ markReady: () => void;
27
+ truncate: () => void;
28
+ }) => void;
29
+ };
30
+ gcTime: number;
31
+ schema: BuildSchema<"select", Table["_"]["columns"], undefined, undefined>;
32
+ getKey: (t: Table["$inferSelect"]) => string;
33
+ onInsert: (params: InsertMutationFnParams<Table["$inferSelect"], string, {
34
+ runSync: () => Promise<void>;
35
+ }>) => Promise<void>;
36
+ onUpdate: (params: UpdateMutationFnParams<Table["$inferSelect"], string, {
37
+ runSync: () => Promise<void>;
38
+ }>) => Promise<void>;
39
+ onDelete: (params: DeleteMutationFnParams<Table["$inferSelect"], string, {
40
+ runSync: () => Promise<void>;
41
+ }>) => Promise<void>;
42
+ utils: {
43
+ runSync: () => Promise<void>;
44
+ };
21
45
  };
22
46
  export {};
package/dist/drizzle.js CHANGED
@@ -86,6 +86,7 @@ export function drizzleCollectionOptions({ startSync = true, ...config }) {
86
86
  .from(config.table)
87
87
  .where(eq(config.primaryColumn, m.key))));
88
88
  }
89
+ const schema = createSelectSchema(config.table);
89
90
  return {
90
91
  startSync: true,
91
92
  sync: {
@@ -112,7 +113,7 @@ export function drizzleCollectionOptions({ startSync = true, ...config }) {
112
113
  },
113
114
  },
114
115
  gcTime: 0,
115
- schema: createSelectSchema(config.table),
116
+ schema,
116
117
  getKey: t => t[config.primaryColumn.name],
117
118
  onInsert: async (params) => {
118
119
  await config.db.transaction(async (tx) => {
package/dist/sql.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { PGlite } from '@electric-sql/pglite';
2
2
  import type { PGliteWorker } from '@electric-sql/pglite/worker';
3
3
  import type { StandardSchemaV1 } from '@standard-schema/spec';
4
- import type { CollectionConfig, DeleteMutationFnParams, InsertMutationFnParams, SyncConfig, UpdateMutationFnParams } from '@tanstack/db';
4
+ import type { DeleteMutationFnParams, InsertMutationFnParams, SyncConfig, UpdateMutationFnParams } from '@tanstack/db';
5
5
  type Output<T extends StandardSchemaV1> = StandardSchemaV1.InferOutput<T>;
6
6
  type SyncParams<ItemType extends Record<string, unknown>> = Parameters<SyncConfig<ItemType, string>['sync']>[0];
7
7
  export declare function sqlCollectionOptions<Schema extends StandardSchemaV1<Record<string, unknown>>>({ startSync, ...config }: {
@@ -16,9 +16,34 @@ export declare function sqlCollectionOptions<Schema extends StandardSchemaV1<Rec
16
16
  startSync?: boolean;
17
17
  prepare?: () => Promise<unknown> | unknown;
18
18
  sync?: (params: Pick<SyncParams<Output<Schema>>, 'write' | 'collection'>) => Promise<void>;
19
- }): CollectionConfig<Output<Schema>, string, Schema, {
20
- runSync: () => Promise<void>;
21
- }> & {
19
+ }): {
20
+ startSync: boolean;
21
+ sync: {
22
+ sync: (params: {
23
+ collection: import("@tanstack/db").Collection<Output<Schema>, string, any, any, any>;
24
+ begin: (options?: {
25
+ immediate?: boolean;
26
+ }) => void;
27
+ write: (message: import("@tanstack/db").ChangeMessageOrDeleteKeyMessage<Output<Schema>, string>) => void;
28
+ commit: () => void;
29
+ markReady: () => void;
30
+ truncate: () => void;
31
+ }) => void;
32
+ };
33
+ gcTime: number;
22
34
  schema: Schema;
35
+ getKey: (row: Output<Schema>) => string;
36
+ onInsert: (params: InsertMutationFnParams<Output<Schema>, string, {
37
+ runSync: () => Promise<void>;
38
+ }>) => Promise<void>;
39
+ onUpdate: (params: UpdateMutationFnParams<Output<Schema>, string, {
40
+ runSync: () => Promise<void>;
41
+ }>) => Promise<void>;
42
+ onDelete: (params: DeleteMutationFnParams<Output<Schema>, string, {
43
+ runSync: () => Promise<void>;
44
+ }>) => Promise<void>;
45
+ utils: {
46
+ runSync: () => Promise<void>;
47
+ };
23
48
  };
24
49
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tanstack-db-pglite",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "packageManager": "pnpm@10.32.1",
5
5
  "description": "",
6
6
  "author": "Valerii Strilets",