@mordn/chat-widget 0.7.1 → 0.8.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.
@@ -0,0 +1,340 @@
1
+ import { d as ChatStore } from '../../chat-store-DERCPwhl.mjs';
2
+ import { drizzle } from 'drizzle-orm/postgres-js';
3
+ import * as ai from 'ai';
4
+ import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
5
+
6
+ /**
7
+ * Drizzle schema for the default ChatStore (v2, parts-first).
8
+ *
9
+ * This is the schema the *default* store uses. A BYO store may use any schema
10
+ * it likes — this one is not part of the public contract, the `ChatStore`
11
+ * interface is. It's exported so consumers on the default path can run
12
+ * `drizzle-kit` against it and so the migration can reference it.
13
+ *
14
+ * What changed from v0.7.1
15
+ * ------------------------
16
+ * The old schema stored a flattened `content: text` as the apparent source of
17
+ * truth and tucked the real AI SDK `parts` into a `metadata` jsonb blob. That
18
+ * inverted the actual authority — `parts` (text + reasoning + tool calls +
19
+ * sources + files) is what the AI SDK round-trips and what rendering needs;
20
+ * `content` was a lossy shadow.
21
+ *
22
+ * v2 makes that authority explicit:
23
+ * • `parts` — jsonb NOT NULL — the canonical AI SDK message parts. Source
24
+ * of truth for rendering and model replay.
25
+ * • `text` — text — a denormalised projection of the text parts, for
26
+ * cheap previews / titles / search. Never authoritative.
27
+ *
28
+ * A backfill migration populates these from the old columns so existing
29
+ * installs upgrade without data loss (see migrations/).
30
+ */
31
+ declare const conversations: drizzle_orm_pg_core.PgTableWithColumns<{
32
+ name: "chat_conversations";
33
+ schema: undefined;
34
+ columns: {
35
+ id: drizzle_orm_pg_core.PgColumn<{
36
+ name: "id";
37
+ tableName: "chat_conversations";
38
+ dataType: "string";
39
+ columnType: "PgText";
40
+ data: string;
41
+ driverParam: string;
42
+ notNull: true;
43
+ hasDefault: false;
44
+ isPrimaryKey: true;
45
+ isAutoincrement: false;
46
+ hasRuntimeDefault: false;
47
+ enumValues: [string, ...string[]];
48
+ baseColumn: never;
49
+ identity: undefined;
50
+ generated: undefined;
51
+ }, {}, {}>;
52
+ userId: drizzle_orm_pg_core.PgColumn<{
53
+ name: "user_id";
54
+ tableName: "chat_conversations";
55
+ dataType: "string";
56
+ columnType: "PgText";
57
+ data: string;
58
+ driverParam: string;
59
+ notNull: true;
60
+ hasDefault: false;
61
+ isPrimaryKey: false;
62
+ isAutoincrement: false;
63
+ hasRuntimeDefault: false;
64
+ enumValues: [string, ...string[]];
65
+ baseColumn: never;
66
+ identity: undefined;
67
+ generated: undefined;
68
+ }, {}, {}>;
69
+ title: drizzle_orm_pg_core.PgColumn<{
70
+ name: "title";
71
+ tableName: "chat_conversations";
72
+ dataType: "string";
73
+ columnType: "PgText";
74
+ data: string;
75
+ driverParam: string;
76
+ notNull: true;
77
+ hasDefault: true;
78
+ isPrimaryKey: false;
79
+ isAutoincrement: false;
80
+ hasRuntimeDefault: false;
81
+ enumValues: [string, ...string[]];
82
+ baseColumn: never;
83
+ identity: undefined;
84
+ generated: undefined;
85
+ }, {}, {}>;
86
+ metadata: drizzle_orm_pg_core.PgColumn<{
87
+ name: "metadata";
88
+ tableName: "chat_conversations";
89
+ dataType: "json";
90
+ columnType: "PgJsonb";
91
+ data: Record<string, unknown>;
92
+ driverParam: unknown;
93
+ notNull: false;
94
+ hasDefault: false;
95
+ isPrimaryKey: false;
96
+ isAutoincrement: false;
97
+ hasRuntimeDefault: false;
98
+ enumValues: undefined;
99
+ baseColumn: never;
100
+ identity: undefined;
101
+ generated: undefined;
102
+ }, {}, {
103
+ $type: Record<string, unknown>;
104
+ }>;
105
+ createdAt: drizzle_orm_pg_core.PgColumn<{
106
+ name: "created_at";
107
+ tableName: "chat_conversations";
108
+ dataType: "date";
109
+ columnType: "PgTimestamp";
110
+ data: Date;
111
+ driverParam: string;
112
+ notNull: true;
113
+ hasDefault: true;
114
+ isPrimaryKey: false;
115
+ isAutoincrement: false;
116
+ hasRuntimeDefault: false;
117
+ enumValues: undefined;
118
+ baseColumn: never;
119
+ identity: undefined;
120
+ generated: undefined;
121
+ }, {}, {}>;
122
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
123
+ name: "updated_at";
124
+ tableName: "chat_conversations";
125
+ dataType: "date";
126
+ columnType: "PgTimestamp";
127
+ data: Date;
128
+ driverParam: string;
129
+ notNull: true;
130
+ hasDefault: true;
131
+ isPrimaryKey: false;
132
+ isAutoincrement: false;
133
+ hasRuntimeDefault: false;
134
+ enumValues: undefined;
135
+ baseColumn: never;
136
+ identity: undefined;
137
+ generated: undefined;
138
+ }, {}, {}>;
139
+ };
140
+ dialect: "pg";
141
+ }>;
142
+ declare const messages: drizzle_orm_pg_core.PgTableWithColumns<{
143
+ name: "chat_messages";
144
+ schema: undefined;
145
+ columns: {
146
+ id: drizzle_orm_pg_core.PgColumn<{
147
+ name: "id";
148
+ tableName: "chat_messages";
149
+ dataType: "string";
150
+ columnType: "PgText";
151
+ data: string;
152
+ driverParam: string;
153
+ notNull: true;
154
+ hasDefault: false;
155
+ isPrimaryKey: true;
156
+ isAutoincrement: false;
157
+ hasRuntimeDefault: false;
158
+ enumValues: [string, ...string[]];
159
+ baseColumn: never;
160
+ identity: undefined;
161
+ generated: undefined;
162
+ }, {}, {}>;
163
+ conversationId: drizzle_orm_pg_core.PgColumn<{
164
+ name: "conversation_id";
165
+ tableName: "chat_messages";
166
+ dataType: "string";
167
+ columnType: "PgText";
168
+ data: string;
169
+ driverParam: string;
170
+ notNull: true;
171
+ hasDefault: false;
172
+ isPrimaryKey: false;
173
+ isAutoincrement: false;
174
+ hasRuntimeDefault: false;
175
+ enumValues: [string, ...string[]];
176
+ baseColumn: never;
177
+ identity: undefined;
178
+ generated: undefined;
179
+ }, {}, {}>;
180
+ role: drizzle_orm_pg_core.PgColumn<{
181
+ name: "role";
182
+ tableName: "chat_messages";
183
+ dataType: "string";
184
+ columnType: "PgText";
185
+ data: "user" | "assistant" | "system";
186
+ driverParam: string;
187
+ notNull: true;
188
+ hasDefault: false;
189
+ isPrimaryKey: false;
190
+ isAutoincrement: false;
191
+ hasRuntimeDefault: false;
192
+ enumValues: [string, ...string[]];
193
+ baseColumn: never;
194
+ identity: undefined;
195
+ generated: undefined;
196
+ }, {}, {
197
+ $type: "user" | "assistant" | "system";
198
+ }>;
199
+ parts: drizzle_orm_pg_core.PgColumn<{
200
+ name: "parts";
201
+ tableName: "chat_messages";
202
+ dataType: "json";
203
+ columnType: "PgJsonb";
204
+ data: ai.UIMessagePart<ai.UIDataTypes, ai.UITools>[];
205
+ driverParam: unknown;
206
+ notNull: true;
207
+ hasDefault: false;
208
+ isPrimaryKey: false;
209
+ isAutoincrement: false;
210
+ hasRuntimeDefault: false;
211
+ enumValues: undefined;
212
+ baseColumn: never;
213
+ identity: undefined;
214
+ generated: undefined;
215
+ }, {}, {
216
+ $type: ai.UIMessagePart<ai.UIDataTypes, ai.UITools>[];
217
+ }>;
218
+ text: drizzle_orm_pg_core.PgColumn<{
219
+ name: "text";
220
+ tableName: "chat_messages";
221
+ dataType: "string";
222
+ columnType: "PgText";
223
+ data: string;
224
+ driverParam: string;
225
+ notNull: true;
226
+ hasDefault: true;
227
+ isPrimaryKey: false;
228
+ isAutoincrement: false;
229
+ hasRuntimeDefault: false;
230
+ enumValues: [string, ...string[]];
231
+ baseColumn: never;
232
+ identity: undefined;
233
+ generated: undefined;
234
+ }, {}, {}>;
235
+ model: drizzle_orm_pg_core.PgColumn<{
236
+ name: "model";
237
+ tableName: "chat_messages";
238
+ dataType: "string";
239
+ columnType: "PgText";
240
+ data: string;
241
+ driverParam: string;
242
+ notNull: false;
243
+ hasDefault: false;
244
+ isPrimaryKey: false;
245
+ isAutoincrement: false;
246
+ hasRuntimeDefault: false;
247
+ enumValues: [string, ...string[]];
248
+ baseColumn: never;
249
+ identity: undefined;
250
+ generated: undefined;
251
+ }, {}, {}>;
252
+ createdAt: drizzle_orm_pg_core.PgColumn<{
253
+ name: "created_at";
254
+ tableName: "chat_messages";
255
+ dataType: "date";
256
+ columnType: "PgTimestamp";
257
+ data: Date;
258
+ driverParam: string;
259
+ notNull: true;
260
+ hasDefault: true;
261
+ isPrimaryKey: false;
262
+ isAutoincrement: false;
263
+ hasRuntimeDefault: false;
264
+ enumValues: undefined;
265
+ baseColumn: never;
266
+ identity: undefined;
267
+ generated: undefined;
268
+ }, {}, {}>;
269
+ };
270
+ dialect: "pg";
271
+ }>;
272
+ type ConversationRow = typeof conversations.$inferSelect;
273
+ type NewConversationRow = typeof conversations.$inferInsert;
274
+ type MessageRow = typeof messages.$inferSelect;
275
+ type NewMessageRow = typeof messages.$inferInsert;
276
+
277
+ type schema_ConversationRow = ConversationRow;
278
+ type schema_MessageRow = MessageRow;
279
+ type schema_NewConversationRow = NewConversationRow;
280
+ type schema_NewMessageRow = NewMessageRow;
281
+ declare const schema_conversations: typeof conversations;
282
+ declare const schema_messages: typeof messages;
283
+ declare namespace schema {
284
+ export { type schema_ConversationRow as ConversationRow, type schema_MessageRow as MessageRow, type schema_NewConversationRow as NewConversationRow, type schema_NewMessageRow as NewMessageRow, schema_conversations as conversations, schema_messages as messages };
285
+ }
286
+
287
+ /**
288
+ * Postgres connection for the default Drizzle store.
289
+ *
290
+ * Carries forward the connection hygiene the original package got right:
291
+ * • cache the client on globalThis so Next.js dev HMR doesn't leak a fresh
292
+ * pool on every reload (which eventually exhausts Supabase's pooler),
293
+ * • `prepare: false` for the Supabase transaction-mode pooler,
294
+ * • a small, bounded pool.
295
+ *
296
+ * The connection string is read from `DATABASE_URL` by default but can be
297
+ * passed explicitly so a host app with multiple databases stays in control.
298
+ */
299
+
300
+ type DrizzleDb = ReturnType<typeof drizzle<typeof schema>>;
301
+ interface DrizzleClientOptions {
302
+ /** Postgres connection string. Defaults to `process.env.DATABASE_URL`. */
303
+ connectionString?: string;
304
+ /** Max pool connections. Defaults to 5 (dev-friendly; raise in prod). */
305
+ max?: number;
306
+ }
307
+ /**
308
+ * Get (or lazily create + cache) a Drizzle db for a connection string. Cached
309
+ * by connection string so multiple stores over the same DB share one pool.
310
+ */
311
+ declare function getDrizzleDb(options?: DrizzleClientOptions): DrizzleDb;
312
+
313
+ /**
314
+ * Default ChatStore implementation, on Postgres via Drizzle.
315
+ *
316
+ * This is the "hosted/default" persistence the widget ships with. It is just
317
+ * one implementation of the `ChatStore` interface — the interface, not this
318
+ * file, is the contract. Every method here upholds the interface's security
319
+ * invariants:
320
+ *
321
+ * • The store is bound to one `userId` (constructor arg from the verified
322
+ * server session). No method takes a userId.
323
+ * • Reads are implicitly scoped to that user. `getConversation` /
324
+ * `listMessages` return null/[] for rows the user doesn't own — never
325
+ * another user's data, and not distinguishable from "not found".
326
+ * • Mutations verify ownership and throw `ConversationOwnershipError` on a
327
+ * foreign row.
328
+ * • `saveTurn` is idempotent on message id and bumps `updatedAt`.
329
+ */
330
+
331
+ /**
332
+ * Create a `ChatStoreFactory` backed by the default Drizzle/Postgres store.
333
+ *
334
+ * Pass to `createChatHandler({ store: createDrizzleChatStore() })`. The
335
+ * factory binds each store instance to the verified `userId` the handler
336
+ * provides per request. The underlying connection pool is shared.
337
+ */
338
+ declare function createDrizzleChatStore(options?: DrizzleClientOptions): (userId: string) => ChatStore;
339
+
340
+ export { type ConversationRow, type DrizzleClientOptions, type DrizzleDb, type MessageRow, type NewConversationRow, type NewMessageRow, createDrizzleChatStore, getDrizzleDb, schema };
@@ -0,0 +1,340 @@
1
+ import { d as ChatStore } from '../../chat-store-DERCPwhl.js';
2
+ import { drizzle } from 'drizzle-orm/postgres-js';
3
+ import * as ai from 'ai';
4
+ import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
5
+
6
+ /**
7
+ * Drizzle schema for the default ChatStore (v2, parts-first).
8
+ *
9
+ * This is the schema the *default* store uses. A BYO store may use any schema
10
+ * it likes — this one is not part of the public contract, the `ChatStore`
11
+ * interface is. It's exported so consumers on the default path can run
12
+ * `drizzle-kit` against it and so the migration can reference it.
13
+ *
14
+ * What changed from v0.7.1
15
+ * ------------------------
16
+ * The old schema stored a flattened `content: text` as the apparent source of
17
+ * truth and tucked the real AI SDK `parts` into a `metadata` jsonb blob. That
18
+ * inverted the actual authority — `parts` (text + reasoning + tool calls +
19
+ * sources + files) is what the AI SDK round-trips and what rendering needs;
20
+ * `content` was a lossy shadow.
21
+ *
22
+ * v2 makes that authority explicit:
23
+ * • `parts` — jsonb NOT NULL — the canonical AI SDK message parts. Source
24
+ * of truth for rendering and model replay.
25
+ * • `text` — text — a denormalised projection of the text parts, for
26
+ * cheap previews / titles / search. Never authoritative.
27
+ *
28
+ * A backfill migration populates these from the old columns so existing
29
+ * installs upgrade without data loss (see migrations/).
30
+ */
31
+ declare const conversations: drizzle_orm_pg_core.PgTableWithColumns<{
32
+ name: "chat_conversations";
33
+ schema: undefined;
34
+ columns: {
35
+ id: drizzle_orm_pg_core.PgColumn<{
36
+ name: "id";
37
+ tableName: "chat_conversations";
38
+ dataType: "string";
39
+ columnType: "PgText";
40
+ data: string;
41
+ driverParam: string;
42
+ notNull: true;
43
+ hasDefault: false;
44
+ isPrimaryKey: true;
45
+ isAutoincrement: false;
46
+ hasRuntimeDefault: false;
47
+ enumValues: [string, ...string[]];
48
+ baseColumn: never;
49
+ identity: undefined;
50
+ generated: undefined;
51
+ }, {}, {}>;
52
+ userId: drizzle_orm_pg_core.PgColumn<{
53
+ name: "user_id";
54
+ tableName: "chat_conversations";
55
+ dataType: "string";
56
+ columnType: "PgText";
57
+ data: string;
58
+ driverParam: string;
59
+ notNull: true;
60
+ hasDefault: false;
61
+ isPrimaryKey: false;
62
+ isAutoincrement: false;
63
+ hasRuntimeDefault: false;
64
+ enumValues: [string, ...string[]];
65
+ baseColumn: never;
66
+ identity: undefined;
67
+ generated: undefined;
68
+ }, {}, {}>;
69
+ title: drizzle_orm_pg_core.PgColumn<{
70
+ name: "title";
71
+ tableName: "chat_conversations";
72
+ dataType: "string";
73
+ columnType: "PgText";
74
+ data: string;
75
+ driverParam: string;
76
+ notNull: true;
77
+ hasDefault: true;
78
+ isPrimaryKey: false;
79
+ isAutoincrement: false;
80
+ hasRuntimeDefault: false;
81
+ enumValues: [string, ...string[]];
82
+ baseColumn: never;
83
+ identity: undefined;
84
+ generated: undefined;
85
+ }, {}, {}>;
86
+ metadata: drizzle_orm_pg_core.PgColumn<{
87
+ name: "metadata";
88
+ tableName: "chat_conversations";
89
+ dataType: "json";
90
+ columnType: "PgJsonb";
91
+ data: Record<string, unknown>;
92
+ driverParam: unknown;
93
+ notNull: false;
94
+ hasDefault: false;
95
+ isPrimaryKey: false;
96
+ isAutoincrement: false;
97
+ hasRuntimeDefault: false;
98
+ enumValues: undefined;
99
+ baseColumn: never;
100
+ identity: undefined;
101
+ generated: undefined;
102
+ }, {}, {
103
+ $type: Record<string, unknown>;
104
+ }>;
105
+ createdAt: drizzle_orm_pg_core.PgColumn<{
106
+ name: "created_at";
107
+ tableName: "chat_conversations";
108
+ dataType: "date";
109
+ columnType: "PgTimestamp";
110
+ data: Date;
111
+ driverParam: string;
112
+ notNull: true;
113
+ hasDefault: true;
114
+ isPrimaryKey: false;
115
+ isAutoincrement: false;
116
+ hasRuntimeDefault: false;
117
+ enumValues: undefined;
118
+ baseColumn: never;
119
+ identity: undefined;
120
+ generated: undefined;
121
+ }, {}, {}>;
122
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
123
+ name: "updated_at";
124
+ tableName: "chat_conversations";
125
+ dataType: "date";
126
+ columnType: "PgTimestamp";
127
+ data: Date;
128
+ driverParam: string;
129
+ notNull: true;
130
+ hasDefault: true;
131
+ isPrimaryKey: false;
132
+ isAutoincrement: false;
133
+ hasRuntimeDefault: false;
134
+ enumValues: undefined;
135
+ baseColumn: never;
136
+ identity: undefined;
137
+ generated: undefined;
138
+ }, {}, {}>;
139
+ };
140
+ dialect: "pg";
141
+ }>;
142
+ declare const messages: drizzle_orm_pg_core.PgTableWithColumns<{
143
+ name: "chat_messages";
144
+ schema: undefined;
145
+ columns: {
146
+ id: drizzle_orm_pg_core.PgColumn<{
147
+ name: "id";
148
+ tableName: "chat_messages";
149
+ dataType: "string";
150
+ columnType: "PgText";
151
+ data: string;
152
+ driverParam: string;
153
+ notNull: true;
154
+ hasDefault: false;
155
+ isPrimaryKey: true;
156
+ isAutoincrement: false;
157
+ hasRuntimeDefault: false;
158
+ enumValues: [string, ...string[]];
159
+ baseColumn: never;
160
+ identity: undefined;
161
+ generated: undefined;
162
+ }, {}, {}>;
163
+ conversationId: drizzle_orm_pg_core.PgColumn<{
164
+ name: "conversation_id";
165
+ tableName: "chat_messages";
166
+ dataType: "string";
167
+ columnType: "PgText";
168
+ data: string;
169
+ driverParam: string;
170
+ notNull: true;
171
+ hasDefault: false;
172
+ isPrimaryKey: false;
173
+ isAutoincrement: false;
174
+ hasRuntimeDefault: false;
175
+ enumValues: [string, ...string[]];
176
+ baseColumn: never;
177
+ identity: undefined;
178
+ generated: undefined;
179
+ }, {}, {}>;
180
+ role: drizzle_orm_pg_core.PgColumn<{
181
+ name: "role";
182
+ tableName: "chat_messages";
183
+ dataType: "string";
184
+ columnType: "PgText";
185
+ data: "user" | "assistant" | "system";
186
+ driverParam: string;
187
+ notNull: true;
188
+ hasDefault: false;
189
+ isPrimaryKey: false;
190
+ isAutoincrement: false;
191
+ hasRuntimeDefault: false;
192
+ enumValues: [string, ...string[]];
193
+ baseColumn: never;
194
+ identity: undefined;
195
+ generated: undefined;
196
+ }, {}, {
197
+ $type: "user" | "assistant" | "system";
198
+ }>;
199
+ parts: drizzle_orm_pg_core.PgColumn<{
200
+ name: "parts";
201
+ tableName: "chat_messages";
202
+ dataType: "json";
203
+ columnType: "PgJsonb";
204
+ data: ai.UIMessagePart<ai.UIDataTypes, ai.UITools>[];
205
+ driverParam: unknown;
206
+ notNull: true;
207
+ hasDefault: false;
208
+ isPrimaryKey: false;
209
+ isAutoincrement: false;
210
+ hasRuntimeDefault: false;
211
+ enumValues: undefined;
212
+ baseColumn: never;
213
+ identity: undefined;
214
+ generated: undefined;
215
+ }, {}, {
216
+ $type: ai.UIMessagePart<ai.UIDataTypes, ai.UITools>[];
217
+ }>;
218
+ text: drizzle_orm_pg_core.PgColumn<{
219
+ name: "text";
220
+ tableName: "chat_messages";
221
+ dataType: "string";
222
+ columnType: "PgText";
223
+ data: string;
224
+ driverParam: string;
225
+ notNull: true;
226
+ hasDefault: true;
227
+ isPrimaryKey: false;
228
+ isAutoincrement: false;
229
+ hasRuntimeDefault: false;
230
+ enumValues: [string, ...string[]];
231
+ baseColumn: never;
232
+ identity: undefined;
233
+ generated: undefined;
234
+ }, {}, {}>;
235
+ model: drizzle_orm_pg_core.PgColumn<{
236
+ name: "model";
237
+ tableName: "chat_messages";
238
+ dataType: "string";
239
+ columnType: "PgText";
240
+ data: string;
241
+ driverParam: string;
242
+ notNull: false;
243
+ hasDefault: false;
244
+ isPrimaryKey: false;
245
+ isAutoincrement: false;
246
+ hasRuntimeDefault: false;
247
+ enumValues: [string, ...string[]];
248
+ baseColumn: never;
249
+ identity: undefined;
250
+ generated: undefined;
251
+ }, {}, {}>;
252
+ createdAt: drizzle_orm_pg_core.PgColumn<{
253
+ name: "created_at";
254
+ tableName: "chat_messages";
255
+ dataType: "date";
256
+ columnType: "PgTimestamp";
257
+ data: Date;
258
+ driverParam: string;
259
+ notNull: true;
260
+ hasDefault: true;
261
+ isPrimaryKey: false;
262
+ isAutoincrement: false;
263
+ hasRuntimeDefault: false;
264
+ enumValues: undefined;
265
+ baseColumn: never;
266
+ identity: undefined;
267
+ generated: undefined;
268
+ }, {}, {}>;
269
+ };
270
+ dialect: "pg";
271
+ }>;
272
+ type ConversationRow = typeof conversations.$inferSelect;
273
+ type NewConversationRow = typeof conversations.$inferInsert;
274
+ type MessageRow = typeof messages.$inferSelect;
275
+ type NewMessageRow = typeof messages.$inferInsert;
276
+
277
+ type schema_ConversationRow = ConversationRow;
278
+ type schema_MessageRow = MessageRow;
279
+ type schema_NewConversationRow = NewConversationRow;
280
+ type schema_NewMessageRow = NewMessageRow;
281
+ declare const schema_conversations: typeof conversations;
282
+ declare const schema_messages: typeof messages;
283
+ declare namespace schema {
284
+ export { type schema_ConversationRow as ConversationRow, type schema_MessageRow as MessageRow, type schema_NewConversationRow as NewConversationRow, type schema_NewMessageRow as NewMessageRow, schema_conversations as conversations, schema_messages as messages };
285
+ }
286
+
287
+ /**
288
+ * Postgres connection for the default Drizzle store.
289
+ *
290
+ * Carries forward the connection hygiene the original package got right:
291
+ * • cache the client on globalThis so Next.js dev HMR doesn't leak a fresh
292
+ * pool on every reload (which eventually exhausts Supabase's pooler),
293
+ * • `prepare: false` for the Supabase transaction-mode pooler,
294
+ * • a small, bounded pool.
295
+ *
296
+ * The connection string is read from `DATABASE_URL` by default but can be
297
+ * passed explicitly so a host app with multiple databases stays in control.
298
+ */
299
+
300
+ type DrizzleDb = ReturnType<typeof drizzle<typeof schema>>;
301
+ interface DrizzleClientOptions {
302
+ /** Postgres connection string. Defaults to `process.env.DATABASE_URL`. */
303
+ connectionString?: string;
304
+ /** Max pool connections. Defaults to 5 (dev-friendly; raise in prod). */
305
+ max?: number;
306
+ }
307
+ /**
308
+ * Get (or lazily create + cache) a Drizzle db for a connection string. Cached
309
+ * by connection string so multiple stores over the same DB share one pool.
310
+ */
311
+ declare function getDrizzleDb(options?: DrizzleClientOptions): DrizzleDb;
312
+
313
+ /**
314
+ * Default ChatStore implementation, on Postgres via Drizzle.
315
+ *
316
+ * This is the "hosted/default" persistence the widget ships with. It is just
317
+ * one implementation of the `ChatStore` interface — the interface, not this
318
+ * file, is the contract. Every method here upholds the interface's security
319
+ * invariants:
320
+ *
321
+ * • The store is bound to one `userId` (constructor arg from the verified
322
+ * server session). No method takes a userId.
323
+ * • Reads are implicitly scoped to that user. `getConversation` /
324
+ * `listMessages` return null/[] for rows the user doesn't own — never
325
+ * another user's data, and not distinguishable from "not found".
326
+ * • Mutations verify ownership and throw `ConversationOwnershipError` on a
327
+ * foreign row.
328
+ * • `saveTurn` is idempotent on message id and bumps `updatedAt`.
329
+ */
330
+
331
+ /**
332
+ * Create a `ChatStoreFactory` backed by the default Drizzle/Postgres store.
333
+ *
334
+ * Pass to `createChatHandler({ store: createDrizzleChatStore() })`. The
335
+ * factory binds each store instance to the verified `userId` the handler
336
+ * provides per request. The underlying connection pool is shared.
337
+ */
338
+ declare function createDrizzleChatStore(options?: DrizzleClientOptions): (userId: string) => ChatStore;
339
+
340
+ export { type ConversationRow, type DrizzleClientOptions, type DrizzleDb, type MessageRow, type NewConversationRow, type NewMessageRow, createDrizzleChatStore, getDrizzleDb, schema };