@supabase/lite 0.9.0 → 0.9.1-next.2

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.
Files changed (64) hide show
  1. package/FEATURES.md +176 -0
  2. package/LIMITATIONS.md +9 -6
  3. package/PATTERNS.md +66 -6
  4. package/README.md +16 -8
  5. package/STATUS.md +33 -20
  6. package/dist/{Connection-ZWTDByQ5.d.ts → Connection-f_d5HhQ0.d.ts} +301 -293
  7. package/dist/cli/index.js +127 -124
  8. package/dist/cli/lib.d.ts +1 -12
  9. package/dist/cli/lib.js +44 -39
  10. package/dist/db/fallback.d.ts +1 -1
  11. package/dist/db/postgres/PostgresConnection.js +18 -18
  12. package/dist/db/postgres/pglite/PgliteConnection.js +17 -17
  13. package/dist/index.d.ts +116 -40
  14. package/dist/index.js +181 -73
  15. package/dist/static/.vite/manifest.json +34 -2
  16. package/dist/static/assets/InterVariable-Dx4kXJAl.woff2 +0 -0
  17. package/dist/static/assets/InterVariable-Italic-DpCbqKDY.woff2 +0 -0
  18. package/dist/static/assets/SourceCodePro-Variable-BP8Zz55n.woff2 +0 -0
  19. package/dist/static/assets/SourceCodePro-Variable-Italic-eALmlzX7.woff2 +0 -0
  20. package/dist/static/assets/main-BY4iigay.css +1 -0
  21. package/dist/static/assets/main-BnQ-v4V9.js +199 -0
  22. package/dist/static/assets/manrope-latin-ext-wght-normal-Ch3YOpNY.woff2 +0 -0
  23. package/dist/static/assets/manrope-latin-wght-normal-DHIcAJRg.woff2 +0 -0
  24. package/dist/vite/index.d.ts +627 -31
  25. package/dist/vite/index.js +2 -2
  26. package/docs/auth/email.mdx +214 -0
  27. package/docs/auth/not-supported.mdx +57 -0
  28. package/docs/auth/overview.mdx +52 -0
  29. package/docs/auth/supported-flows.mdx +120 -0
  30. package/docs/cli/overview.mdx +112 -0
  31. package/docs/cli/telemetry.mdx +34 -0
  32. package/docs/compatibility.mdx +115 -0
  33. package/docs/database/backends.mdx +118 -0
  34. package/docs/database/data-api.mdx +90 -0
  35. package/docs/database/functions-triggers.mdx +93 -0
  36. package/docs/database/migrations.mdx +95 -0
  37. package/docs/database/overview.mdx +66 -0
  38. package/docs/database/postgres-sqlite-translation.mdx +130 -0
  39. package/docs/database/rls.mdx +161 -0
  40. package/docs/database/schemas.mdx +58 -0
  41. package/docs/index.mdx +49 -0
  42. package/docs/integrations/embedded.mdx +100 -0
  43. package/docs/integrations/frameworks.mdx +83 -0
  44. package/docs/integrations/vite.mdx +87 -0
  45. package/docs/llms.txt +52 -0
  46. package/docs/other/edge-functions.mdx +34 -0
  47. package/docs/other/realtime.mdx +22 -0
  48. package/docs/quickstart.mdx +150 -0
  49. package/docs/running.mdx +127 -0
  50. package/docs/storage/adapters.mdx +75 -0
  51. package/docs/storage/limitations.mdx +21 -0
  52. package/docs/storage/overview.mdx +88 -0
  53. package/docs/upgrade.mdx +108 -0
  54. package/package.json +5 -1
  55. package/skills/supalite/SKILL.md +6 -4
  56. package/dist/static/assets/main-1bwWb_1q.js +0 -40996
  57. package/dist/static/assets/main-BDsRycsc.css +0 -4045
  58. package/dist/static/fonts/CustomFont-Black.woff2 +0 -0
  59. package/dist/static/fonts/CustomFont-BlackItalic.woff2 +0 -0
  60. package/dist/static/fonts/CustomFont-Bold.woff2 +0 -0
  61. package/dist/static/fonts/CustomFont-BoldItalic.woff2 +0 -0
  62. package/dist/static/fonts/CustomFont-Book.woff2 +0 -0
  63. package/dist/static/fonts/CustomFont-BookItalic.woff2 +0 -0
  64. package/dist/static/fonts/CustomFont-Medium.woff2 +0 -0
@@ -9,264 +9,6 @@ interface CacheDriver {
9
9
  delete(key: string): Promise<void>;
10
10
  }
11
11
 
12
- /**
13
- * Nested object for runtime variable substitution.
14
- * Paths are resolved via lodash-style dot-path access (e.g. "auth.jwt.role" → vars.auth.jwt.role).
15
- * e.g. { auth: { uid: "uuid-here", role: "authenticated", jwt: { role: "admin" } } }
16
- */
17
- type VarsContext = Record<string, unknown>;
18
-
19
- type ASTType = "query" | "insert" | "update" | "delete" | "upsert" | "put" | "rpc";
20
- type QbSelect = SelectQueryBuilder<any, any, any>;
21
- type QbInsert = InsertQueryBuilder<any, any, any>;
22
- type QbUpdate = UpdateQueryBuilder<any, any, any, any>;
23
- type QbDelete = DeleteQueryBuilder<any, any, any>;
24
- type Qb = QbSelect | QbInsert | QbUpdate | QbDelete;
25
- type ColumnDef = {
26
- column?: string;
27
- cast?: string;
28
- preCast?: string;
29
- aggregate?: AggregateFunction;
30
- bareCount?: boolean;
31
- path?: string;
32
- /** True when the trailing JSON-path operator was `->>` (text extract). */
33
- pathText?: boolean;
34
- /** First key reached after an earlier `->>` text extraction. */
35
- invalidJsonTextTraversalKey?: string;
36
- };
37
- type EmbedDef = {
38
- select?: SelectEntry[];
39
- where?: Where;
40
- order?: OrderEntry[];
41
- limit?: number;
42
- offset?: number;
43
- spread?: boolean;
44
- join?: JoinMap;
45
- };
46
- type SelectEntry = string | Record<string, ColumnDef | EmbedDef>;
47
- type JoinDef = {
48
- from?: string;
49
- type?: "inner" | "left";
50
- hint?: string;
51
- on?: Where;
52
- };
53
- type JoinMap = Record<string, JoinDef>;
54
- type ColumnRef = {
55
- $ref: string;
56
- };
57
- declare function isRef(val: unknown): val is ColumnRef;
58
- type WhereValue = {
59
- [op: string]: unknown;
60
- };
61
- type Where = Record<string, unknown>;
62
- type OrderEntry = {
63
- column: string;
64
- direction?: "asc" | "desc";
65
- nullsFirst?: boolean;
66
- /** For ordering by embedded resource column: embed alias */
67
- embed?: string;
68
- };
69
- type TextSearchValue = {
70
- query: string;
71
- type?: "plain" | "phrase" | "websearch";
72
- config?: string;
73
- };
74
- type ExplainOptions = {
75
- analyze?: boolean;
76
- verbose?: boolean;
77
- settings?: boolean;
78
- buffers?: boolean;
79
- wal?: boolean;
80
- };
81
- type Meta = {
82
- cardinality?: "one" | "maybe" | "many";
83
- count?: "exact" | "planned" | "estimated";
84
- head?: boolean;
85
- maxAffected?: number;
86
- rollback?: boolean;
87
- missing?: "null" | "default";
88
- handling?: "strict" | "lenient";
89
- timezone?: string;
90
- columns?: string[];
91
- stripNulls?: boolean;
92
- explain?: ExplainOptions;
93
- headers?: Record<string, string>;
94
- return?: "minimal" | "headers-only" | "representation";
95
- tx?: "commit" | "rollback";
96
- };
97
- interface BaseAST {
98
- from: string;
99
- schema?: string;
100
- select?: SelectEntry[];
101
- $meta?: Meta;
102
- }
103
- interface QueryAST extends BaseAST {
104
- type: "query";
105
- join?: JoinMap;
106
- where?: Where;
107
- order?: OrderEntry[];
108
- limit?: number;
109
- offset?: number;
110
- group?: string[];
111
- }
112
- interface InsertAST extends BaseAST {
113
- type: "insert";
114
- values: object | object[];
115
- }
116
- interface UpdateAST extends BaseAST {
117
- type: "update";
118
- values: object;
119
- where?: Where;
120
- order?: OrderEntry[];
121
- limit?: number;
122
- offset?: number;
123
- }
124
- interface DeleteAST extends BaseAST {
125
- type: "delete";
126
- where?: Where;
127
- order?: OrderEntry[];
128
- limit?: number;
129
- offset?: number;
130
- }
131
- interface UpsertAST extends BaseAST {
132
- type: "upsert" | "put";
133
- values: object;
134
- onConflict?: string[];
135
- ignoreDuplicates?: boolean;
136
- }
137
- interface RpcAST extends BaseAST {
138
- type: "rpc";
139
- function: string;
140
- args?: object | unknown[];
141
- /** Embed joins, when `select=` embeds related tables on a `SETOF <table>` result. */
142
- join?: JoinMap;
143
- where?: Where;
144
- order?: OrderEntry[];
145
- limit?: number;
146
- offset?: number;
147
- httpMethod?: "GET" | "POST";
148
- paramsType?: "named" | "positional";
149
- inputType?: "json" | "text" | "binary" | "xml";
150
- }
151
- type AST = QueryAST | InsertAST | UpdateAST | DeleteAST | UpsertAST | RpcAST;
152
- type AnyAST = {
153
- type?: string;
154
- from?: string;
155
- function?: string;
156
- schema?: string;
157
- join?: JoinMap;
158
- select?: SelectEntry[];
159
- where?: Where;
160
- values?: object | object[];
161
- args?: object | unknown[];
162
- order?: OrderEntry[];
163
- limit?: number;
164
- offset?: number;
165
- group?: string[];
166
- onConflict?: string[];
167
- ignoreDuplicates?: boolean;
168
- httpMethod?: "GET" | "POST";
169
- paramsType?: "named" | "positional";
170
- inputType?: "json" | "text" | "binary" | "xml";
171
- $meta?: Meta;
172
- };
173
- type AggregateFunction = "count" | "sum" | "avg" | "min" | "max";
174
- type RouteResult = {
175
- from?: string;
176
- function?: string;
177
- isRpc: boolean;
178
- };
179
- type PreferToken = {
180
- key: "count";
181
- value: "exact" | "planned" | "estimated";
182
- } | {
183
- key: "resolution";
184
- value: "merge-duplicates" | "ignore-duplicates";
185
- } | {
186
- key: "return";
187
- value: "minimal" | "headers-only" | "representation";
188
- } | {
189
- key: "tx";
190
- value: "commit" | "rollback";
191
- } | {
192
- key: "missing";
193
- value: "default" | "null";
194
- } | {
195
- key: "handling";
196
- value: "strict" | "lenient";
197
- } | {
198
- key: "max-affected";
199
- value: number;
200
- } | {
201
- key: "timezone";
202
- value: string;
203
- } | {
204
- key: "params";
205
- value: "single-object" | "multiple-objects";
206
- };
207
- type HeadersResult = {
208
- schema?: string;
209
- preferTokens: PreferToken[];
210
- accept: string;
211
- };
212
- type SelectResult = {
213
- select: SelectEntry[];
214
- join: JoinMap;
215
- embeddedAliases: Set<string>;
216
- };
217
- type BodyResult = {
218
- values?: object | object[];
219
- args?: object;
220
- raw?: string;
221
- };
222
- type QueryParamsResult = Map<string, string[]>;
223
- type FiltersResult = {
224
- where: Where;
225
- embeddedWheres: Record<string, Where>;
226
- };
227
- type EmbedTransform = {
228
- order?: OrderEntry[];
229
- limit?: number;
230
- offset?: number;
231
- _nested?: Record<string, {
232
- order?: OrderEntry[];
233
- limit?: number;
234
- offset?: number;
235
- }>;
236
- };
237
- type TransformsResult = {
238
- order?: OrderEntry[];
239
- limit?: number;
240
- offset?: number;
241
- embeddedTransforms: Record<string, EmbedTransform>;
242
- };
243
- type RpcResult = {
244
- args?: object | unknown[];
245
- httpMethod?: "GET" | "POST";
246
- paramsType?: "named" | "positional";
247
- inputType?: "json" | "text" | "binary" | "xml";
248
- };
249
- type UpsertResult = {
250
- onConflict?: string[];
251
- ignoreDuplicates: boolean;
252
- };
253
- type TranslatorConfig = {
254
- parseRoute?: (req: Request) => RouteResult;
255
- parseHeaders?: (req: Request) => HeadersResult;
256
- parseSelect?: (req: Request) => SelectResult;
257
- parseBody?: (req: Request) => Promise<BodyResult>;
258
- parseQueryParams?: (req: Request) => QueryParamsResult;
259
- resolveType?: (route: RouteResult, method: string, headers: HeadersResult) => ASTType;
260
- resolveFilters?: (queryParams: QueryParamsResult, embeddedAliases: Set<string>, fromTable?: string, parentColumns?: ReadonlySet<string>) => FiltersResult;
261
- /** Physical columns on the request table (for embed/column homonym filters). */
262
- parentColumns?: ReadonlySet<string>;
263
- resolveTransforms?: (queryParams: QueryParamsResult, embeddedAliases: Set<string>) => TransformsResult;
264
- resolveMeta?: (headers: HeadersResult, queryParams: QueryParamsResult, method: string) => Meta;
265
- resolveRpcParams?: (route: RouteResult, method: string, queryParams: QueryParamsResult, body: BodyResult) => RpcResult;
266
- resolveUpsertParams?: (queryParams: QueryParamsResult, headers: HeadersResult) => UpsertResult;
267
- basePath?: string;
268
- };
269
-
270
12
  interface TableInfo {
271
13
  name: string;
272
14
  sql: string;
@@ -308,6 +50,7 @@ interface IndexInfo {
308
50
  unique: boolean;
309
51
  columns: string[];
310
52
  schema: string;
53
+ sql?: string;
311
54
  }
312
55
  interface ForeignKeyInfo {
313
56
  table: string;
@@ -545,46 +288,304 @@ interface DataLossWarning {
545
288
  table: string;
546
289
  reason: string;
547
290
  }
548
- interface PlanResult {
549
- steps: PlanStep[];
550
- warnings?: DataLossWarning[];
551
- unsafe: boolean;
291
+ interface PlanResult {
292
+ steps: PlanStep[];
293
+ warnings?: DataLossWarning[];
294
+ unsafe: boolean;
295
+ }
296
+ declare class DataLossError extends Error {
297
+ warnings: DataLossWarning[];
298
+ constructor(warnings: DataLossWarning[]);
299
+ }
300
+ declare class MigrationError extends Error {
301
+ stepIndex: number;
302
+ sql: string;
303
+ cause: Error;
304
+ constructor(stepIndex: number, sql: string, cause: Error);
305
+ }
306
+ interface SchemaDiffResult {
307
+ current?: IntrospectResult;
308
+ desired?: IntrospectResult;
309
+ diff: DiffResult | string;
310
+ plan: PlanResult;
311
+ }
312
+ /**
313
+ * Restricts a diff/migrate to a set of schemas (LITE-291). When set, both the
314
+ * current and desired catalogs are filtered to these schemas, so out-of-scope
315
+ * (e.g. user-land `public`) objects are invisible to the diff and are never
316
+ * dropped. Used by `App.ensureSystemSchema()` to reconcile only system schemas.
317
+ */
318
+ interface MigrateScope {
319
+ schemas?: string[];
320
+ }
321
+ interface ConnectionMigrator {
322
+ diff(scope?: MigrateScope): Promise<SchemaDiffResult>;
323
+ migrate(opts?: {
324
+ force?: boolean;
325
+ } & MigrateScope): Promise<SchemaDiffResult>;
326
+ migratePlan(planResult: PlanResult, opts?: {
327
+ force?: boolean;
328
+ }): Promise<void>;
329
+ safeSortPlanSteps(steps: PlanStep[]): PlanStep[];
330
+ }
331
+
332
+ /**
333
+ * Nested object for runtime variable substitution.
334
+ * Paths are resolved via lodash-style dot-path access (e.g. "auth.jwt.role" → vars.auth.jwt.role).
335
+ * e.g. { auth: { uid: "uuid-here", role: "authenticated", jwt: { role: "admin" } } }
336
+ */
337
+ type VarsContext = Record<string, unknown>;
338
+
339
+ type ASTType = "query" | "insert" | "update" | "delete" | "upsert" | "put" | "rpc";
340
+ type QbSelect = SelectQueryBuilder<any, any, any>;
341
+ type QbInsert = InsertQueryBuilder<any, any, any>;
342
+ type QbUpdate = UpdateQueryBuilder<any, any, any, any>;
343
+ type QbDelete = DeleteQueryBuilder<any, any, any>;
344
+ type Qb = QbSelect | QbInsert | QbUpdate | QbDelete;
345
+ type ColumnDef = {
346
+ column?: string;
347
+ cast?: string;
348
+ preCast?: string;
349
+ aggregate?: AggregateFunction;
350
+ bareCount?: boolean;
351
+ path?: string;
352
+ /** True when the trailing JSON-path operator was `->>` (text extract). */
353
+ pathText?: boolean;
354
+ /** First key reached after an earlier `->>` text extraction. */
355
+ invalidJsonTextTraversalKey?: string;
356
+ };
357
+ type EmbedDef = {
358
+ select?: SelectEntry[];
359
+ where?: Where;
360
+ order?: OrderEntry[];
361
+ limit?: number;
362
+ offset?: number;
363
+ spread?: boolean;
364
+ join?: JoinMap;
365
+ };
366
+ type SelectEntry = string | Record<string, ColumnDef | EmbedDef>;
367
+ type JoinDef = {
368
+ from?: string;
369
+ type?: "inner" | "left";
370
+ hint?: string;
371
+ on?: Where;
372
+ };
373
+ type JoinMap = Record<string, JoinDef>;
374
+ type ColumnRef = {
375
+ $ref: string;
376
+ };
377
+ declare function isRef(val: unknown): val is ColumnRef;
378
+ type WhereValue = {
379
+ [op: string]: unknown;
380
+ };
381
+ type Where = Record<string, unknown>;
382
+ type OrderEntry = {
383
+ column: string;
384
+ direction?: "asc" | "desc";
385
+ nullsFirst?: boolean;
386
+ /** For ordering by embedded resource column: embed alias */
387
+ embed?: string;
388
+ };
389
+ type TextSearchValue = {
390
+ query: string;
391
+ type?: "plain" | "phrase" | "websearch";
392
+ config?: string;
393
+ };
394
+ type ExplainOptions = {
395
+ analyze?: boolean;
396
+ verbose?: boolean;
397
+ settings?: boolean;
398
+ buffers?: boolean;
399
+ wal?: boolean;
400
+ };
401
+ type Meta = {
402
+ cardinality?: "one" | "maybe" | "many";
403
+ count?: "exact" | "planned" | "estimated";
404
+ head?: boolean;
405
+ maxAffected?: number;
406
+ rollback?: boolean;
407
+ missing?: "null" | "default";
408
+ handling?: "strict" | "lenient";
409
+ timezone?: string;
410
+ columns?: string[];
411
+ stripNulls?: boolean;
412
+ explain?: ExplainOptions;
413
+ headers?: Record<string, string>;
414
+ return?: "minimal" | "headers-only" | "representation";
415
+ tx?: "commit" | "rollback";
416
+ };
417
+ interface BaseAST {
418
+ from: string;
419
+ schema?: string;
420
+ select?: SelectEntry[];
421
+ $meta?: Meta;
422
+ }
423
+ interface QueryAST extends BaseAST {
424
+ type: "query";
425
+ join?: JoinMap;
426
+ where?: Where;
427
+ order?: OrderEntry[];
428
+ limit?: number;
429
+ offset?: number;
430
+ group?: string[];
552
431
  }
553
- declare class DataLossError extends Error {
554
- warnings: DataLossWarning[];
555
- constructor(warnings: DataLossWarning[]);
432
+ interface InsertAST extends BaseAST {
433
+ type: "insert";
434
+ values: object | object[];
556
435
  }
557
- declare class MigrationError extends Error {
558
- stepIndex: number;
559
- sql: string;
560
- cause: Error;
561
- constructor(stepIndex: number, sql: string, cause: Error);
436
+ interface UpdateAST extends BaseAST {
437
+ type: "update";
438
+ values: object;
439
+ where?: Where;
440
+ order?: OrderEntry[];
441
+ limit?: number;
442
+ offset?: number;
562
443
  }
563
- interface SchemaDiffResult {
564
- current?: IntrospectResult;
565
- desired?: IntrospectResult;
566
- diff: DiffResult | string;
567
- plan: PlanResult;
444
+ interface DeleteAST extends BaseAST {
445
+ type: "delete";
446
+ where?: Where;
447
+ order?: OrderEntry[];
448
+ limit?: number;
449
+ offset?: number;
568
450
  }
569
- /**
570
- * Restricts a diff/migrate to a set of schemas (LITE-291). When set, both the
571
- * current and desired catalogs are filtered to these schemas, so out-of-scope
572
- * (e.g. user-land `public`) objects are invisible to the diff and are never
573
- * dropped. Used by `App.ensureSystemSchema()` to reconcile only system schemas.
574
- */
575
- interface MigrateScope {
576
- schemas?: string[];
451
+ interface UpsertAST extends BaseAST {
452
+ type: "upsert" | "put";
453
+ values: object;
454
+ onConflict?: string[];
455
+ ignoreDuplicates?: boolean;
577
456
  }
578
- interface ConnectionMigrator {
579
- diff(scope?: MigrateScope): Promise<SchemaDiffResult>;
580
- migrate(opts?: {
581
- force?: boolean;
582
- } & MigrateScope): Promise<SchemaDiffResult>;
583
- migratePlan(planResult: PlanResult, opts?: {
584
- force?: boolean;
585
- }): Promise<void>;
586
- safeSortPlanSteps(steps: PlanStep[]): PlanStep[];
457
+ interface RpcAST extends BaseAST {
458
+ type: "rpc";
459
+ function: string;
460
+ args?: object | unknown[];
461
+ /** Embed joins, when `select=` embeds related tables on a `SETOF <table>` result. */
462
+ join?: JoinMap;
463
+ where?: Where;
464
+ order?: OrderEntry[];
465
+ limit?: number;
466
+ offset?: number;
467
+ httpMethod?: "GET" | "POST";
468
+ paramsType?: "named" | "positional";
469
+ inputType?: "json" | "text" | "binary" | "xml";
587
470
  }
471
+ type AST = QueryAST | InsertAST | UpdateAST | DeleteAST | UpsertAST | RpcAST;
472
+ type AnyAST = {
473
+ type?: string;
474
+ from?: string;
475
+ function?: string;
476
+ schema?: string;
477
+ join?: JoinMap;
478
+ select?: SelectEntry[];
479
+ where?: Where;
480
+ values?: object | object[];
481
+ args?: object | unknown[];
482
+ order?: OrderEntry[];
483
+ limit?: number;
484
+ offset?: number;
485
+ group?: string[];
486
+ onConflict?: string[];
487
+ ignoreDuplicates?: boolean;
488
+ httpMethod?: "GET" | "POST";
489
+ paramsType?: "named" | "positional";
490
+ inputType?: "json" | "text" | "binary" | "xml";
491
+ $meta?: Meta;
492
+ };
493
+ type AggregateFunction = "count" | "sum" | "avg" | "min" | "max";
494
+ type RouteResult = {
495
+ from?: string;
496
+ function?: string;
497
+ isRpc: boolean;
498
+ };
499
+ type PreferToken = {
500
+ key: "count";
501
+ value: "exact" | "planned" | "estimated";
502
+ } | {
503
+ key: "resolution";
504
+ value: "merge-duplicates" | "ignore-duplicates";
505
+ } | {
506
+ key: "return";
507
+ value: "minimal" | "headers-only" | "representation";
508
+ } | {
509
+ key: "tx";
510
+ value: "commit" | "rollback";
511
+ } | {
512
+ key: "missing";
513
+ value: "default" | "null";
514
+ } | {
515
+ key: "handling";
516
+ value: "strict" | "lenient";
517
+ } | {
518
+ key: "max-affected";
519
+ value: number;
520
+ } | {
521
+ key: "timezone";
522
+ value: string;
523
+ } | {
524
+ key: "params";
525
+ value: "single-object" | "multiple-objects";
526
+ };
527
+ type HeadersResult = {
528
+ schema?: string;
529
+ preferTokens: PreferToken[];
530
+ accept: string;
531
+ };
532
+ type SelectResult = {
533
+ select: SelectEntry[];
534
+ join: JoinMap;
535
+ embeddedAliases: Set<string>;
536
+ };
537
+ type BodyResult = {
538
+ values?: object | object[];
539
+ args?: object;
540
+ raw?: string;
541
+ };
542
+ type QueryParamsResult = Map<string, string[]>;
543
+ type FiltersResult = {
544
+ where: Where;
545
+ embeddedWheres: Record<string, Where>;
546
+ };
547
+ type EmbedTransform = {
548
+ order?: OrderEntry[];
549
+ limit?: number;
550
+ offset?: number;
551
+ _nested?: Record<string, {
552
+ order?: OrderEntry[];
553
+ limit?: number;
554
+ offset?: number;
555
+ }>;
556
+ };
557
+ type TransformsResult = {
558
+ order?: OrderEntry[];
559
+ limit?: number;
560
+ offset?: number;
561
+ embeddedTransforms: Record<string, EmbedTransform>;
562
+ };
563
+ type RpcResult = {
564
+ args?: object | unknown[];
565
+ httpMethod?: "GET" | "POST";
566
+ paramsType?: "named" | "positional";
567
+ inputType?: "json" | "text" | "binary" | "xml";
568
+ };
569
+ type UpsertResult = {
570
+ onConflict?: string[];
571
+ ignoreDuplicates: boolean;
572
+ };
573
+ type TranslatorConfig = {
574
+ parseRoute?: (req: Request) => RouteResult;
575
+ parseHeaders?: (req: Request) => HeadersResult;
576
+ parseSelect?: (req: Request) => SelectResult;
577
+ parseBody?: (req: Request) => Promise<BodyResult>;
578
+ parseQueryParams?: (req: Request) => QueryParamsResult;
579
+ resolveType?: (route: RouteResult, method: string, headers: HeadersResult) => ASTType;
580
+ resolveFilters?: (queryParams: QueryParamsResult, embeddedAliases: Set<string>, fromTable?: string, parentColumns?: ReadonlySet<string>) => FiltersResult;
581
+ /** Physical columns on the request table (for embed/column homonym filters). */
582
+ parentColumns?: ReadonlySet<string>;
583
+ resolveTransforms?: (queryParams: QueryParamsResult, embeddedAliases: Set<string>) => TransformsResult;
584
+ resolveMeta?: (headers: HeadersResult, queryParams: QueryParamsResult, method: string) => Meta;
585
+ resolveRpcParams?: (route: RouteResult, method: string, queryParams: QueryParamsResult, body: BodyResult) => RpcResult;
586
+ resolveUpsertParams?: (queryParams: QueryParamsResult, headers: HeadersResult) => UpsertResult;
587
+ basePath?: string;
588
+ };
588
589
 
589
590
  interface IConnectionConfig extends Partial<KyselyConfig> {
590
591
  url?: string;
@@ -596,6 +597,11 @@ interface IConnectionConfig extends Partial<KyselyConfig> {
596
597
  * This is useful for when auth is enabled, and auth schema must be present.
597
598
  */
598
599
  baseSchema?: string;
600
+ /** System-owned tables whose own schema enables RLS. */
601
+ systemRls?: Array<{
602
+ schema: string;
603
+ tables: string[];
604
+ }>;
599
605
  }
600
606
  type Dialect = "sqlite" | "postgres";
601
607
  type TransactionOptions = {
@@ -603,6 +609,8 @@ type TransactionOptions = {
603
609
  };
604
610
  type ConnectionContextOptions = {
605
611
  forceRollback?: boolean;
612
+ /** Reuse an existing transaction so trusted preflights and scoped writes stay atomic. */
613
+ transaction?: Kysely<any>;
606
614
  /**
607
615
  * Present for RPC (`/rpc/*`) requests on the postgres backend only. Forces the
608
616
  * call into one explicit transaction so request.* GUC injection, GET read-only
@@ -686,7 +694,7 @@ declare abstract class Connection<Driver = unknown, DB = any, Config extends ICo
686
694
  * For Postgres: wraps in a transaction with SET LOCAL role/claims.
687
695
  * Default: pass-through.
688
696
  */
689
- withContext<T>(_vars: VarsContext | undefined, fn: (db: Kysely<any>) => Promise<T>, _opts?: ConnectionContextOptions): Promise<T>;
697
+ withContext<T>(_vars: VarsContext | undefined, fn: (db: Kysely<any>) => Promise<T>, opts?: ConnectionContextOptions): Promise<T>;
690
698
  /**
691
699
  * Whether this connection serves RPC (stored functions). SQLite-backed
692
700
  * connections have none; the data route uses this to gate `/rpc/*`.