@supabase/lite 0.0.1-next.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.
Files changed (37) hide show
  1. package/dist/Connection-rAPmec1m.d.ts +710 -0
  2. package/dist/cli/index.d.ts +1 -0
  3. package/dist/cli/index.js +30950 -0
  4. package/dist/cli/lib.d.ts +158 -0
  5. package/dist/cli/lib.js +18598 -0
  6. package/dist/db/browser/index.d.ts +550 -0
  7. package/dist/db/browser/index.js +16112 -0
  8. package/dist/db/bun/index.d.ts +548 -0
  9. package/dist/db/bun/index.js +16100 -0
  10. package/dist/db/fallback.d.ts +182 -0
  11. package/dist/db/fallback.js +15996 -0
  12. package/dist/db/node/index.d.ts +547 -0
  13. package/dist/db/node/index.js +16093 -0
  14. package/dist/db/postgres/BasePostgresConnection-B7zHDAib.d.ts +24 -0
  15. package/dist/db/postgres/PostgresConnection.d.ts +16 -0
  16. package/dist/db/postgres/PostgresConnection.js +611 -0
  17. package/dist/db/postgres/pglite/PgliteConnection.d.ts +38 -0
  18. package/dist/db/postgres/pglite/PgliteConnection.js +890 -0
  19. package/dist/db/workerd/index.d.ts +570 -0
  20. package/dist/db/workerd/index.js +16218 -0
  21. package/dist/index-xv_pDjEt.d.ts +769 -0
  22. package/dist/index.d.ts +2498 -0
  23. package/dist/index.js +32305 -0
  24. package/dist/static/.vite/manifest.json +11 -0
  25. package/dist/static/assets/main-BsWx0q9l.js +40913 -0
  26. package/dist/static/assets/main-DexXgo9R.css +4002 -0
  27. package/dist/static/favicon.ico +0 -0
  28. package/dist/static/fonts/CustomFont-Black.woff2 +0 -0
  29. package/dist/static/fonts/CustomFont-BlackItalic.woff2 +0 -0
  30. package/dist/static/fonts/CustomFont-Bold.woff2 +0 -0
  31. package/dist/static/fonts/CustomFont-BoldItalic.woff2 +0 -0
  32. package/dist/static/fonts/CustomFont-Book.woff2 +0 -0
  33. package/dist/static/fonts/CustomFont-BookItalic.woff2 +0 -0
  34. package/dist/static/fonts/CustomFont-Medium.woff2 +0 -0
  35. package/dist/vite/index.d.ts +3017 -0
  36. package/dist/vite/index.js +1923 -0
  37. package/package.json +195 -0
@@ -0,0 +1,710 @@
1
+ import { ParseResult } from 'libpg-query';
2
+ import { DeparserOptions } from 'pgsql-deparser';
3
+ import { SelectQueryBuilder, InsertQueryBuilder, UpdateQueryBuilder, DeleteQueryBuilder, KyselyConfig, Kysely } from 'kysely';
4
+
5
+ /**
6
+ * Nested object for runtime variable substitution.
7
+ * Paths are resolved via lodash-style dot-path access (e.g. "auth.jwt.role" → vars.auth.jwt.role).
8
+ * e.g. { auth: { uid: "uuid-here", role: "authenticated", jwt: { role: "admin" } } }
9
+ */
10
+ type VarsContext = Record<string, unknown>;
11
+
12
+ type ASTType = "query" | "insert" | "update" | "delete" | "upsert" | "put" | "rpc";
13
+ type QbSelect = SelectQueryBuilder<any, any, any>;
14
+ type QbInsert = InsertQueryBuilder<any, any, any>;
15
+ type QbUpdate = UpdateQueryBuilder<any, any, any, any>;
16
+ type QbDelete = DeleteQueryBuilder<any, any, any>;
17
+ type Qb = QbSelect | QbInsert | QbUpdate | QbDelete;
18
+ type ColumnDef = {
19
+ column?: string;
20
+ cast?: string;
21
+ preCast?: string;
22
+ aggregate?: AggregateFunction;
23
+ bareCount?: boolean;
24
+ path?: string;
25
+ /** True when the trailing JSON-path operator was `->>` (text extract). */
26
+ pathText?: boolean;
27
+ /** First key reached after an earlier `->>` text extraction. */
28
+ invalidJsonTextTraversalKey?: string;
29
+ };
30
+ type EmbedDef = {
31
+ select?: SelectEntry[];
32
+ where?: Where;
33
+ order?: OrderEntry[];
34
+ limit?: number;
35
+ offset?: number;
36
+ spread?: boolean;
37
+ join?: JoinMap;
38
+ };
39
+ type SelectEntry = string | Record<string, ColumnDef | EmbedDef>;
40
+ type JoinDef = {
41
+ from?: string;
42
+ type?: "inner" | "left";
43
+ hint?: string;
44
+ on?: Where;
45
+ };
46
+ type JoinMap = Record<string, JoinDef>;
47
+ type ColumnRef = {
48
+ $ref: string;
49
+ };
50
+ declare function isRef(val: unknown): val is ColumnRef;
51
+ type WhereValue = {
52
+ [op: string]: unknown;
53
+ };
54
+ type Where = Record<string, unknown>;
55
+ type OrderEntry = {
56
+ column: string;
57
+ direction?: "asc" | "desc";
58
+ nullsFirst?: boolean;
59
+ /** For ordering by embedded resource column: embed alias */
60
+ embed?: string;
61
+ };
62
+ type TextSearchValue = {
63
+ query: string;
64
+ type?: "plain" | "phrase" | "websearch";
65
+ config?: string;
66
+ };
67
+ type ExplainOptions = {
68
+ analyze?: boolean;
69
+ verbose?: boolean;
70
+ settings?: boolean;
71
+ buffers?: boolean;
72
+ wal?: boolean;
73
+ };
74
+ type Meta = {
75
+ cardinality?: "one" | "maybe" | "many";
76
+ count?: "exact" | "planned" | "estimated";
77
+ head?: boolean;
78
+ maxAffected?: number;
79
+ rollback?: boolean;
80
+ missing?: "null" | "default";
81
+ handling?: "strict" | "lenient";
82
+ timezone?: string;
83
+ columns?: string[];
84
+ stripNulls?: boolean;
85
+ explain?: ExplainOptions;
86
+ headers?: Record<string, string>;
87
+ return?: "minimal" | "headers-only" | "representation";
88
+ tx?: "commit" | "rollback";
89
+ };
90
+ interface BaseAST {
91
+ from: string;
92
+ schema?: string;
93
+ select?: SelectEntry[];
94
+ $meta?: Meta;
95
+ }
96
+ interface QueryAST extends BaseAST {
97
+ type: "query";
98
+ join?: JoinMap;
99
+ where?: Where;
100
+ order?: OrderEntry[];
101
+ limit?: number;
102
+ offset?: number;
103
+ group?: string[];
104
+ }
105
+ interface InsertAST extends BaseAST {
106
+ type: "insert";
107
+ values: object | object[];
108
+ }
109
+ interface UpdateAST extends BaseAST {
110
+ type: "update";
111
+ values: object;
112
+ where?: Where;
113
+ order?: OrderEntry[];
114
+ limit?: number;
115
+ offset?: number;
116
+ }
117
+ interface DeleteAST extends BaseAST {
118
+ type: "delete";
119
+ where?: Where;
120
+ order?: OrderEntry[];
121
+ limit?: number;
122
+ offset?: number;
123
+ }
124
+ interface UpsertAST extends BaseAST {
125
+ type: "upsert" | "put";
126
+ values: object;
127
+ onConflict?: string[];
128
+ ignoreDuplicates?: boolean;
129
+ }
130
+ interface RpcAST extends BaseAST {
131
+ type: "rpc";
132
+ function: string;
133
+ args?: object | unknown[];
134
+ where?: Where;
135
+ order?: OrderEntry[];
136
+ limit?: number;
137
+ offset?: number;
138
+ httpMethod?: "GET" | "POST";
139
+ paramsType?: "named" | "positional";
140
+ inputType?: "json" | "text" | "binary" | "xml";
141
+ }
142
+ type AST = QueryAST | InsertAST | UpdateAST | DeleteAST | UpsertAST | RpcAST;
143
+ type AnyAST = {
144
+ type?: string;
145
+ from?: string;
146
+ function?: string;
147
+ schema?: string;
148
+ join?: JoinMap;
149
+ select?: SelectEntry[];
150
+ where?: Where;
151
+ values?: object | object[];
152
+ args?: object | unknown[];
153
+ order?: OrderEntry[];
154
+ limit?: number;
155
+ offset?: number;
156
+ group?: string[];
157
+ onConflict?: string[];
158
+ ignoreDuplicates?: boolean;
159
+ httpMethod?: "GET" | "POST";
160
+ paramsType?: "named" | "positional";
161
+ inputType?: "json" | "text" | "binary" | "xml";
162
+ $meta?: Meta;
163
+ };
164
+ type AggregateFunction = "count" | "sum" | "avg" | "min" | "max";
165
+ type RouteResult = {
166
+ from?: string;
167
+ function?: string;
168
+ isRpc: boolean;
169
+ };
170
+ type PreferToken = {
171
+ key: "count";
172
+ value: "exact" | "planned" | "estimated";
173
+ } | {
174
+ key: "resolution";
175
+ value: "merge-duplicates" | "ignore-duplicates";
176
+ } | {
177
+ key: "return";
178
+ value: "minimal" | "headers-only" | "representation";
179
+ } | {
180
+ key: "tx";
181
+ value: "commit" | "rollback";
182
+ } | {
183
+ key: "missing";
184
+ value: "default" | "null";
185
+ } | {
186
+ key: "handling";
187
+ value: "strict" | "lenient";
188
+ } | {
189
+ key: "max-affected";
190
+ value: number;
191
+ } | {
192
+ key: "timezone";
193
+ value: string;
194
+ } | {
195
+ key: "params";
196
+ value: "single-object" | "multiple-objects";
197
+ };
198
+ type HeadersResult = {
199
+ schema?: string;
200
+ preferTokens: PreferToken[];
201
+ accept: string;
202
+ };
203
+ type SelectResult = {
204
+ select: SelectEntry[];
205
+ join: JoinMap;
206
+ embeddedAliases: Set<string>;
207
+ };
208
+ type BodyResult = {
209
+ values?: object | object[];
210
+ args?: object;
211
+ raw?: string;
212
+ };
213
+ type QueryParamsResult = Map<string, string[]>;
214
+ type FiltersResult = {
215
+ where: Where;
216
+ embeddedWheres: Record<string, Where>;
217
+ };
218
+ type EmbedTransform = {
219
+ order?: OrderEntry[];
220
+ limit?: number;
221
+ offset?: number;
222
+ _nested?: Record<string, {
223
+ order?: OrderEntry[];
224
+ limit?: number;
225
+ offset?: number;
226
+ }>;
227
+ };
228
+ type TransformsResult = {
229
+ order?: OrderEntry[];
230
+ limit?: number;
231
+ offset?: number;
232
+ embeddedTransforms: Record<string, EmbedTransform>;
233
+ };
234
+ type RpcResult = {
235
+ args?: object | unknown[];
236
+ httpMethod?: "GET" | "POST";
237
+ paramsType?: "named" | "positional";
238
+ inputType?: "json" | "text" | "binary" | "xml";
239
+ };
240
+ type UpsertResult = {
241
+ onConflict?: string[];
242
+ ignoreDuplicates: boolean;
243
+ };
244
+ type TranslatorConfig = {
245
+ parseRoute?: (req: Request) => RouteResult;
246
+ parseHeaders?: (req: Request) => HeadersResult;
247
+ parseSelect?: (req: Request) => SelectResult;
248
+ parseBody?: (req: Request) => Promise<BodyResult>;
249
+ parseQueryParams?: (req: Request) => QueryParamsResult;
250
+ resolveType?: (route: RouteResult, method: string, headers: HeadersResult) => ASTType;
251
+ resolveFilters?: (queryParams: QueryParamsResult, embeddedAliases: Set<string>) => FiltersResult;
252
+ resolveTransforms?: (queryParams: QueryParamsResult, embeddedAliases: Set<string>) => TransformsResult;
253
+ resolveMeta?: (headers: HeadersResult, queryParams: QueryParamsResult, method: string) => Meta;
254
+ resolveRpcParams?: (route: RouteResult, method: string, queryParams: QueryParamsResult, body: BodyResult) => RpcResult;
255
+ resolveUpsertParams?: (queryParams: QueryParamsResult, headers: HeadersResult) => UpsertResult;
256
+ basePath?: string;
257
+ };
258
+
259
+ type TUnwrappedConst = string | number | boolean | null | undefined;
260
+
261
+ type PolicyCommand = "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "ALL";
262
+ type PolicyRole = "anon" | "authenticated" | string;
263
+ interface PolicyData {
264
+ name: string;
265
+ table: string;
266
+ schema?: string;
267
+ command: PolicyCommand;
268
+ permissive: boolean;
269
+ roles: PolicyRole[];
270
+ using?: Where;
271
+ withCheck?: Where;
272
+ }
273
+ declare class Policy {
274
+ readonly data: PolicyData;
275
+ constructor(data: PolicyData);
276
+ appliesTo(cmd: "SELECT" | "INSERT" | "UPDATE" | "DELETE"): boolean;
277
+ appliesToRole(role: string): boolean;
278
+ toJSON(): PolicyData;
279
+ static fromJSON(data: PolicyData): Policy;
280
+ }
281
+
282
+ declare class CheckConstraintError extends Error {
283
+ readonly table: string;
284
+ readonly column: string;
285
+ readonly constraint: string;
286
+ readonly value: unknown;
287
+ constructor(table: string, column: string, constraint: string, value: unknown);
288
+ }
289
+
290
+ type SqliteType = "INTEGER" | "REAL" | "TEXT" | "BLOB" | "ANY";
291
+ type DefaultFn = () => unknown;
292
+ interface ValidationResult {
293
+ status: "pass" | "warn" | "fail";
294
+ message: string | null;
295
+ action?: string;
296
+ }
297
+ interface FieldContext {
298
+ schema: string;
299
+ table: string;
300
+ column: string;
301
+ pgTypeName: string;
302
+ nullable: boolean;
303
+ defaultValue: string | null;
304
+ defaultFn?: DefaultFn | null;
305
+ isPrimaryKey: boolean;
306
+ isUnique: boolean;
307
+ isSerial: boolean;
308
+ isGenerated?: boolean;
309
+ fkRef?: {
310
+ refSchema?: string;
311
+ refTable: string;
312
+ refColumn: string;
313
+ constraintName?: string;
314
+ };
315
+ hasCheck?: boolean;
316
+ checkConstraintName?: string;
317
+ uniqueConstraintName?: string;
318
+ }
319
+ interface ColumnDDLOptions {
320
+ includeNullable?: boolean;
321
+ }
322
+ declare abstract class Field {
323
+ readonly context: FieldContext;
324
+ constructor(context: FieldContext);
325
+ abstract get sqliteType(): SqliteType;
326
+ get isShimBacked(): boolean;
327
+ checkConstraint(): string | null;
328
+ serialize(value: unknown): unknown;
329
+ deserialize(value: unknown): unknown;
330
+ validateStorage(_rawSqliteValue: unknown): ValidationResult;
331
+ protected validationFail(message: string, action?: string): ValidationResult;
332
+ protected validationPass(): ValidationResult;
333
+ protected isNullish(value: unknown): value is null | undefined;
334
+ toColumnDDL(options?: ColumnDDLOptions): string;
335
+ protected checkError(constraint: string, value: unknown): CheckConstraintError;
336
+ protected quoteIfNeeded(name: string): string;
337
+ }
338
+
339
+ type FunctionResolutionMode = "synthetic" | "translate" | "auto";
340
+
341
+ declare class TableSchema {
342
+ readonly table: string;
343
+ readonly schema: string;
344
+ private fields;
345
+ constructor(table: string, schema?: string, fields?: Map<string, Field>);
346
+ get(col: string): Field | undefined;
347
+ has(col: string): boolean;
348
+ set(col: string, field: Field): void;
349
+ columns(): string[];
350
+ all(): Field[];
351
+ serializeRow(row: Record<string, unknown>): Record<string, unknown>;
352
+ deserializeRow(row: Record<string, unknown>): Record<string, unknown>;
353
+ applyDefaults(row: Record<string, unknown>): Record<string, unknown>;
354
+ }
355
+
356
+ type CollectedEnums = Map<string, string[]>;
357
+ type CollectedVariable = {
358
+ local?: boolean;
359
+ value: TUnwrappedConst;
360
+ };
361
+ type CollectedVariables = Map<string, CollectedVariable>;
362
+ type CollectedRlsTables = Set<string>;
363
+ type CollectedSchema = Map<string, TableSchema>;
364
+ type CollectedTableConstraint = {
365
+ schema: string;
366
+ table: string;
367
+ kind: "unique" | "check" | "foreign_key";
368
+ name?: string;
369
+ columns: string[];
370
+ refSchema?: string;
371
+ refTable?: string;
372
+ refColumns?: string[];
373
+ };
374
+ type CollectedComment = {
375
+ schema: string;
376
+ table: string;
377
+ column?: string;
378
+ text: string;
379
+ };
380
+
381
+ interface TableInfo {
382
+ name: string;
383
+ sql: string;
384
+ schema: string;
385
+ type: "table" | "view";
386
+ rows: number;
387
+ engine: string;
388
+ collation: string;
389
+ }
390
+ interface ColumnInfo {
391
+ table: string;
392
+ name: string;
393
+ type: string;
394
+ nullable: boolean;
395
+ default_value: string | null;
396
+ is_primary_key: boolean;
397
+ schema: string;
398
+ ordinal_position: number;
399
+ collation: string;
400
+ character_maximum_length: string | null;
401
+ precision: {
402
+ precision: number | null;
403
+ scale: number | null;
404
+ } | null;
405
+ is_identity: boolean;
406
+ pg_type?: string;
407
+ is_generated?: boolean;
408
+ }
409
+ interface IndexInfo {
410
+ table: string;
411
+ name: string;
412
+ unique: boolean;
413
+ columns: string[];
414
+ schema: string;
415
+ }
416
+ interface ForeignKeyInfo {
417
+ table: string;
418
+ column: string;
419
+ ref_table: string;
420
+ ref_column: string;
421
+ on_update: string;
422
+ on_delete: string;
423
+ schema: string;
424
+ ref_schema?: string;
425
+ foreign_key_name: string;
426
+ fk_def: string;
427
+ is_visible?: boolean;
428
+ }
429
+ interface PrimaryKeyInfo {
430
+ table: string;
431
+ columns: string[];
432
+ schema: string;
433
+ field_count: number;
434
+ }
435
+ interface ViewInfo {
436
+ name: string;
437
+ sql: string;
438
+ schema: string;
439
+ }
440
+ interface CheckConstraintInfo {
441
+ schema: string;
442
+ table: string;
443
+ expression: string;
444
+ name?: string;
445
+ column?: string;
446
+ }
447
+ interface UniqueConstraintInfo {
448
+ schema: string;
449
+ table: string;
450
+ name: string;
451
+ columns: string[];
452
+ }
453
+ interface CommentInfo {
454
+ schema: string;
455
+ table: string;
456
+ column?: string;
457
+ text: string;
458
+ }
459
+ interface TriggerInfo {
460
+ table: string;
461
+ name: string;
462
+ sql: string;
463
+ schema: string;
464
+ }
465
+ interface CustomTypesInfo {
466
+ schema: string;
467
+ type: string;
468
+ kind: "enum" | "composite";
469
+ values?: string[];
470
+ fields?: {
471
+ name: string;
472
+ type: string;
473
+ }[];
474
+ }
475
+ type IntrospectOptions = {
476
+ exclude_tables?: string[];
477
+ name?: string;
478
+ version?: string;
479
+ };
480
+ interface IntrospectResult {
481
+ tables: TableInfo[];
482
+ columns: ColumnInfo[];
483
+ indexes: IndexInfo[];
484
+ foreign_keys: ForeignKeyInfo[];
485
+ primary_keys: PrimaryKeyInfo[];
486
+ views: ViewInfo[];
487
+ check_constraints: CheckConstraintInfo[];
488
+ unique_constraints: UniqueConstraintInfo[];
489
+ comments: CommentInfo[];
490
+ custom_types: CustomTypesInfo[];
491
+ triggers: TriggerInfo[];
492
+ database_name: string;
493
+ version: string;
494
+ ddl_dialect?: "postgres" | "sqlite";
495
+ schema_separator?: string;
496
+ }
497
+ interface TableDiff {
498
+ type: "added" | "removed" | "modified";
499
+ name: string;
500
+ sql?: string;
501
+ }
502
+ interface ColumnDiff {
503
+ type: "added" | "removed" | "modified";
504
+ table: string;
505
+ name: string;
506
+ changes?: {
507
+ type?: {
508
+ from: string;
509
+ to: string;
510
+ };
511
+ nullable?: {
512
+ from: boolean;
513
+ to: boolean;
514
+ };
515
+ default_value?: {
516
+ from: string | null;
517
+ to: string | null;
518
+ };
519
+ };
520
+ column?: ColumnInfo;
521
+ }
522
+ interface IndexDiff {
523
+ type: "added" | "removed";
524
+ table: string;
525
+ name: string;
526
+ unique: boolean;
527
+ columns: string[];
528
+ }
529
+ interface ForeignKeyDiff {
530
+ type: "added" | "removed";
531
+ table: string;
532
+ column: string;
533
+ ref_table: string;
534
+ ref_column: string;
535
+ on_update: string;
536
+ on_delete: string;
537
+ }
538
+ interface DiffResult {
539
+ tables: TableDiff[];
540
+ columns: ColumnDiff[];
541
+ indexes: IndexDiff[];
542
+ foreign_keys: ForeignKeyDiff[];
543
+ has_changes: boolean;
544
+ }
545
+ declare const enum PlanStepType {
546
+ DISABLE_FOREIGN_KEYS = "disable_foreign_keys",
547
+ ENABLE_FOREIGN_KEYS = "enable_foreign_keys",
548
+ BEGIN_TRANSACTION = "begin_transaction",
549
+ COMMIT_TRANSACTION = "commit_transaction",
550
+ CREATE_TABLE = "create_table",
551
+ ADD_COLUMN = "add_column",
552
+ DROP_COLUMN = "drop_column",
553
+ ADD_INDEX = "add_index",
554
+ DROP_INDEX = "drop_index",
555
+ DROP_TABLE = "drop_table",
556
+ RENAME_TABLE = "rename_table",
557
+ COPY_DATA = "copy_data",
558
+ CREATE_TRIGGER = "create_trigger"
559
+ }
560
+ interface PlanStep {
561
+ sql: string;
562
+ description?: string;
563
+ type?: PlanStepType;
564
+ }
565
+ interface DataLossWarning {
566
+ table: string;
567
+ reason: string;
568
+ }
569
+ interface PlanResult {
570
+ steps: PlanStep[];
571
+ warnings?: DataLossWarning[];
572
+ unsafe: boolean;
573
+ }
574
+ declare class DataLossError extends Error {
575
+ warnings: DataLossWarning[];
576
+ constructor(warnings: DataLossWarning[]);
577
+ }
578
+ declare class MigrationError extends Error {
579
+ stepIndex: number;
580
+ sql: string;
581
+ cause: Error;
582
+ constructor(stepIndex: number, sql: string, cause: Error);
583
+ }
584
+ interface SchemaDiffResult {
585
+ current?: IntrospectResult;
586
+ desired?: IntrospectResult;
587
+ diff: DiffResult | string;
588
+ plan: PlanResult;
589
+ }
590
+ interface ConnectionMigrator {
591
+ diff(): Promise<SchemaDiffResult>;
592
+ migrate(opts?: {
593
+ force?: boolean;
594
+ }): Promise<SchemaDiffResult>;
595
+ migratePlan(planResult: PlanResult, opts?: {
596
+ force?: boolean;
597
+ }): Promise<void>;
598
+ safeSortPlanSteps(steps: PlanStep[]): PlanStep[];
599
+ }
600
+
601
+ type SchemaHandling = "default" | "prefix";
602
+ interface DeparseOptions extends DeparserOptions {
603
+ schemaHandling?: SchemaHandling;
604
+ forceDefaultSchema?: string | false;
605
+ enums?: CollectedEnums;
606
+ /** Current DB introspection. Required for ALTER TABLE ops that need 12-step rebuild. */
607
+ introspection?: IntrospectResult;
608
+ functionResolution?: FunctionResolutionMode;
609
+ }
610
+
611
+ declare function translatePostgresDdl(pgSql: string, options?: DeparseOptions): Promise<string>;
612
+ declare function deparsePostgresDdl(pgSql: string, options?: DeparseOptions & {
613
+ strict?: boolean;
614
+ }): Promise<{
615
+ ddl: string;
616
+ enums: CollectedEnums;
617
+ rls: {
618
+ tables: CollectedRlsTables;
619
+ policies: Policy[];
620
+ };
621
+ schema: CollectedSchema;
622
+ vars: CollectedVariables;
623
+ tableConstraints: CollectedTableConstraint[];
624
+ comments: CollectedComment[];
625
+ ast: ParseResult;
626
+ }>;
627
+
628
+ interface CacheSetOptions {
629
+ ttl?: number;
630
+ }
631
+ interface CacheDriver {
632
+ get(key: string): Promise<string | undefined>;
633
+ set(key: string, value: string, options?: CacheSetOptions): Promise<void>;
634
+ delete(key: string): Promise<void>;
635
+ }
636
+
637
+ interface IConnectionConfig extends Partial<KyselyConfig> {
638
+ url?: string;
639
+ introspection?: IntrospectOptions;
640
+ schemaCache?: CacheDriver;
641
+ /**
642
+ * Base schema of the connection that is always prepended to any schema operations.
643
+ * E.g. when migrating to a desired schema, `baseSchema` is always prepended.
644
+ * This is useful for when auth is enabled, and auth schema must be present.
645
+ */
646
+ baseSchema?: string;
647
+ }
648
+ type Dialect = "sqlite" | "postgres";
649
+ type TransactionOptions = {
650
+ intent?: "migration";
651
+ };
652
+ type ConnectionContextOptions = {
653
+ forceRollback?: boolean;
654
+ };
655
+ declare class RelationNotFoundError extends Error {
656
+ readonly schema: string | undefined;
657
+ readonly relation: string;
658
+ constructor(schema: string | undefined, relation: string);
659
+ }
660
+ declare abstract class Connection<Driver = unknown, DB = any, Config extends IConnectionConfig = IConnectionConfig> {
661
+ config: Config;
662
+ kysely: Kysely<DB>;
663
+ abstract driver: Driver;
664
+ abstract dialect: Dialect;
665
+ protected introspection: IntrospectResult | undefined;
666
+ protected constructor(config: Config);
667
+ /**
668
+ * Connection-level DDL translation, mainly for SQLite connections to override.
669
+ */
670
+ translateDdl(ddl: string): Promise<unknown>;
671
+ clearSchemaCache(): Promise<void>;
672
+ protected readCachedIntrospection(options?: {
673
+ useCache?: boolean;
674
+ }): Promise<IntrospectResult | undefined>;
675
+ protected writeCachedIntrospection(result: IntrospectResult, options?: {
676
+ useDriver?: boolean;
677
+ }): Promise<void>;
678
+ protected deleteCachedIntrospection(): Promise<void>;
679
+ protected schemaCacheKey(): string;
680
+ exec<T = {
681
+ rows: unknown[];
682
+ } | void>(query: string, ...parameters: readonly unknown[]): Promise<T>;
683
+ ping(): Promise<boolean | void>;
684
+ abstract introspect(options?: {
685
+ useCache?: boolean;
686
+ }): Promise<IntrospectResult>;
687
+ transaction(_statements: string[], _opts?: TransactionOptions): Promise<void>;
688
+ abstract close(): Promise<void>;
689
+ createMigrator(_desiredSchema: string): ConnectionMigrator;
690
+ onPostgrestAST(ast: AnyAST, _vars?: VarsContext): Promise<AnyAST>;
691
+ /**
692
+ * Per-row response coercion run after schema-typed deserialization.
693
+ * Subclasses fix wire-protocol-shape quirks (e.g. JSON-as-text on
694
+ * Postgres `json_agg`, numeric-as-string from postgres.js). Default = no-op.
695
+ */
696
+ deserializeRow(row: Record<string, unknown>): Record<string, unknown>;
697
+ /**
698
+ * Normalize a database error into a PG-style error object.
699
+ * Override in subclasses to map dialect-specific error codes.
700
+ */
701
+ normalizeDbError(e: unknown): unknown;
702
+ /**
703
+ * Wrap PostgREST query execution with connection-specific context.
704
+ * For Postgres: wraps in a transaction with SET LOCAL role/claims.
705
+ * Default: pass-through.
706
+ */
707
+ withContext<T>(_vars: VarsContext | undefined, fn: (db: Kysely<any>) => Promise<T>, _opts?: ConnectionContextOptions): Promise<T>;
708
+ }
709
+
710
+ export { type QbDelete as $, type AnyAST as A, type BaseAST as B, Connection as C, DataLossError as D, type EmbedDef as E, type FiltersResult as F, type ForeignKeyInfo as G, type HeadersResult as H, type IntrospectResult as I, type IndexDiff as J, type IndexInfo as K, type InsertAST as L, type IntrospectOptions as M, type JoinDef as N, type JoinMap as O, type PolicyCommand as P, type Meta as Q, MigrationError as R, type OrderEntry as S, type TransactionOptions as T, type PlanResult as U, type VarsContext as V, type PlanStep as W, PlanStepType as X, type PreferToken as Y, type PrimaryKeyInfo as Z, type Qb as _, type IConnectionConfig as a, type QbInsert as a0, type QbSelect as a1, type QbUpdate as a2, type QueryAST as a3, type QueryParamsResult as a4, RelationNotFoundError as a5, type RouteResult as a6, type RpcAST as a7, type RpcResult as a8, type SchemaDiffResult as a9, type SelectEntry as aa, type SelectResult as ab, type TableDiff as ac, type TableInfo as ad, type TextSearchValue as ae, type TransformsResult as af, type TranslatorConfig as ag, type TriggerInfo as ah, type UniqueConstraintInfo as ai, type UpdateAST as aj, type UpsertAST as ak, type UpsertResult as al, type ViewInfo as am, type Where as an, type WhereValue as ao, isRef as ap, translatePostgresDdl as aq, type CacheDriver as b, type CacheSetOptions as c, deparsePostgresDdl as d, type PolicyRole as e, Policy as f, type AST as g, type ASTType as h, type AggregateFunction as i, type BodyResult as j, type CheckConstraintInfo as k, type ColumnDef as l, type ColumnDiff as m, type ColumnInfo as n, type ColumnRef as o, type CommentInfo as p, type ConnectionContextOptions as q, type ConnectionMigrator as r, type CustomTypesInfo as s, type DataLossWarning as t, type DeleteAST as u, type Dialect as v, type DiffResult as w, type EmbedTransform as x, type ExplainOptions as y, type ForeignKeyDiff as z };
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node