@supabase/lite 0.9.1-next.1 → 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 (50) hide show
  1. package/FEATURES.md +6 -6
  2. package/LIMITATIONS.md +8 -6
  3. package/PATTERNS.md +66 -6
  4. package/README.md +15 -8
  5. package/STATUS.md +26 -19
  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 +4 -4
  13. package/dist/index.d.ts +90 -38
  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 +601 -29
  25. package/dist/vite/index.js +2 -2
  26. package/docs/auth/overview.mdx +1 -1
  27. package/docs/auth/supported-flows.mdx +4 -4
  28. package/docs/compatibility.mdx +4 -4
  29. package/docs/database/migrations.mdx +2 -0
  30. package/docs/database/rls.mdx +7 -5
  31. package/docs/database/schemas.mdx +1 -1
  32. package/docs/integrations/embedded.mdx +20 -3
  33. package/docs/integrations/frameworks.mdx +1 -1
  34. package/docs/integrations/vite.mdx +4 -2
  35. package/docs/llms.txt +2 -2
  36. package/docs/quickstart.mdx +2 -2
  37. package/docs/running.mdx +20 -10
  38. package/docs/storage/limitations.mdx +2 -11
  39. package/docs/storage/overview.mdx +8 -2
  40. package/package.json +2 -1
  41. package/skills/supalite/SKILL.md +1 -1
  42. package/dist/static/assets/main-1bwWb_1q.js +0 -40996
  43. package/dist/static/assets/main-BDsRycsc.css +0 -4045
  44. package/dist/static/fonts/CustomFont-Black.woff2 +0 -0
  45. package/dist/static/fonts/CustomFont-BlackItalic.woff2 +0 -0
  46. package/dist/static/fonts/CustomFont-Bold.woff2 +0 -0
  47. package/dist/static/fonts/CustomFont-BoldItalic.woff2 +0 -0
  48. package/dist/static/fonts/CustomFont-Book.woff2 +0 -0
  49. package/dist/static/fonts/CustomFont-BookItalic.woff2 +0 -0
  50. package/dist/static/fonts/CustomFont-Medium.woff2 +0 -0
@@ -2,13 +2,13 @@ import { Connect, Plugin } from 'vite';
2
2
  import * as _supabase_supabase_js from '@supabase/supabase-js';
3
3
  import { SupabaseClientOptions } from '@supabase/supabase-js';
4
4
  import * as s from 'jsonv-ts';
5
- import { Connection } from '@supabase/lite';
5
+ import { Connection as Connection$1 } from '@supabase/lite';
6
6
  import * as hono_hono_base from 'hono/hono-base';
7
7
  import * as hono_utils_http_status from 'hono/utils/http-status';
8
8
  import * as hono_utils_types from 'hono/utils/types';
9
9
  import * as hono_types from 'hono/types';
10
10
  import { Context, MiddlewareHandler } from 'hono';
11
- import { Kysely } from 'kysely';
11
+ import { Kysely, KyselyConfig } from 'kysely';
12
12
  import { ReadableStream as ReadableStream$1 } from 'node:stream/web';
13
13
 
14
14
  declare module "jsonv-ts" {
@@ -1331,7 +1331,7 @@ interface StorageAdapter<Options extends StorageAdapterOptions = StorageAdapterO
1331
1331
  uploadObject(bucketName: string, key: string, version: string | undefined, body: CrossReadableStream | Buffer | Uint8Array, contentType: string, cacheControl: string): Promise<ObjectMetadata>;
1332
1332
  deleteObject(bucket: string, key: string, version: string | undefined): Promise<void>;
1333
1333
  deleteObjects(bucket: string, prefixes: string[]): Promise<void>;
1334
- copyObject(bucket: string, source: string, version: string | undefined, destination: string, destinationVersion: string | undefined): Promise<Pick<ObjectMetadata, "httpStatusCode" | "eTag" | "lastModified">>;
1334
+ copyObject(sourceBucket: string, source: string, version: string | undefined, destinationBucket: string, destination: string, destinationVersion: string | undefined): Promise<Pick<ObjectMetadata, "httpStatusCode" | "eTag" | "lastModified">>;
1335
1335
  headObject(bucket: string, key: string, version: string | undefined): Promise<ObjectMetadata>;
1336
1336
  privateAssetUrl(bucket: string, key: string, version: string | undefined): Promise<string>;
1337
1337
  }
@@ -1371,7 +1371,534 @@ interface TransformationAdapter<Options extends TransformationAdapterOptions = T
1371
1371
  transformFromUrl?(url: string, options: TransformOptions): Promise<TransformResult>;
1372
1372
  }
1373
1373
 
1374
- type Dialect = "postgres" | "sqlite";
1374
+ interface TableInfo {
1375
+ name: string;
1376
+ sql: string;
1377
+ schema: string;
1378
+ type: "table" | "view";
1379
+ rows: number;
1380
+ engine: string;
1381
+ collation: string;
1382
+ }
1383
+ interface ColumnInfo {
1384
+ table: string;
1385
+ name: string;
1386
+ type: string;
1387
+ nullable: boolean;
1388
+ default_value: string | null;
1389
+ is_primary_key: boolean;
1390
+ schema: string;
1391
+ ordinal_position: number;
1392
+ collation: string;
1393
+ character_maximum_length: string | null;
1394
+ precision: {
1395
+ precision: number | null;
1396
+ scale: number | null;
1397
+ } | null;
1398
+ is_identity: boolean;
1399
+ pg_type?: string;
1400
+ /**
1401
+ * Schema of the column's data type (information_schema `udt_schema`). For a
1402
+ * composite/enum/domain typed column this is the schema the *type* lives in,
1403
+ * which can differ from the table's `schema` — used to resolve the type
1404
+ * against `custom_types` without cross-schema false matches. Postgres only.
1405
+ */
1406
+ udt_schema?: string;
1407
+ is_generated?: boolean;
1408
+ }
1409
+ interface IndexInfo {
1410
+ table: string;
1411
+ name: string;
1412
+ unique: boolean;
1413
+ columns: string[];
1414
+ schema: string;
1415
+ sql?: string;
1416
+ }
1417
+ interface ForeignKeyInfo {
1418
+ table: string;
1419
+ column: string;
1420
+ ref_table: string;
1421
+ ref_column: string;
1422
+ on_update: string;
1423
+ on_delete: string;
1424
+ schema: string;
1425
+ ref_schema?: string;
1426
+ foreign_key_name: string;
1427
+ /** Internal grouping key for derived FK paths that share a display constraint name. */
1428
+ foreign_key_group?: string;
1429
+ fk_def: string;
1430
+ is_visible?: boolean;
1431
+ }
1432
+ interface PrimaryKeyInfo {
1433
+ table: string;
1434
+ columns: string[];
1435
+ schema: string;
1436
+ field_count: number;
1437
+ }
1438
+ interface ViewInfo {
1439
+ name: string;
1440
+ sql: string;
1441
+ schema: string;
1442
+ }
1443
+ interface CheckConstraintInfo {
1444
+ schema: string;
1445
+ table: string;
1446
+ expression: string;
1447
+ name?: string;
1448
+ column?: string;
1449
+ }
1450
+ interface UniqueConstraintInfo {
1451
+ schema: string;
1452
+ table: string;
1453
+ name: string;
1454
+ columns: string[];
1455
+ }
1456
+ interface CommentInfo {
1457
+ schema: string;
1458
+ table: string;
1459
+ column?: string;
1460
+ text: string;
1461
+ }
1462
+ interface TriggerInfo {
1463
+ table: string;
1464
+ name: string;
1465
+ sql: string;
1466
+ schema: string;
1467
+ }
1468
+ interface CustomTypesInfo {
1469
+ schema: string;
1470
+ type: string;
1471
+ kind: "enum" | "composite";
1472
+ values?: string[];
1473
+ fields?: {
1474
+ name: string;
1475
+ type: string;
1476
+ }[];
1477
+ }
1478
+ interface FunctionInfo {
1479
+ schema: string;
1480
+ name: string;
1481
+ /** Input parameter names, in declaration order. Empty for unnamed-param functions. */
1482
+ arg_names: string[];
1483
+ /** Input parameter type names (format_type), aligned with proargtypes order. */
1484
+ arg_types: string[];
1485
+ /** Count of trailing input params that have a DEFAULT (pronargdefaults). */
1486
+ arg_defaults: number;
1487
+ /** True when the function has a VARIADIC parameter. */
1488
+ has_variadic: boolean;
1489
+ /** provolatile: 'i' immutable, 's' stable, 'v' volatile. */
1490
+ volatility: string;
1491
+ /** Formatted return type (e.g. "integer", "SETOF" is conveyed via return_is_setof). */
1492
+ return_type: string;
1493
+ /** proretset — function returns a set (SETOF / TABLE). */
1494
+ return_is_setof: boolean;
1495
+ /**
1496
+ * prorows — planner row-count estimate. A SETOF function declared `ROWS 1`
1497
+ * has prorows === 1, which PostgREST reads as a to-one computed relationship.
1498
+ * SETOF without ROWS defaults to 1000; non-set functions to 0.
1499
+ */
1500
+ return_rows?: number;
1501
+ /**
1502
+ * pg_type.typtype of the return type: 'b' base, 'c' composite, 'd' domain,
1503
+ * 'e' enum, 'p' pseudo (record/void), 'r' range, 'm' multirange. 'c'/'p'
1504
+ * indicate a row/record (object) result rather than a scalar.
1505
+ */
1506
+ return_typtype: string;
1507
+ /**
1508
+ * When the return type is a domain ('d'), the formatted name of its underlying
1509
+ * base type (pg_type.typbasetype via format_type) — e.g. a `"text/plain"`
1510
+ * domain over `text` carries `return_base_type: "text"`. Empty/undefined for
1511
+ * non-domain returns. Used to decode a media-type-domain RPC result as raw
1512
+ * text vs raw bytea. See server/data/response/media-domain.ts.
1513
+ */
1514
+ return_base_type?: string;
1515
+ /** True when the function has OUT/INOUT/TABLE output columns (object-shaped result). */
1516
+ has_out_args: boolean;
1517
+ }
1518
+ type IntrospectOptions = {
1519
+ exclude_tables?: string[];
1520
+ name?: string;
1521
+ version?: string;
1522
+ };
1523
+ interface IntrospectResult {
1524
+ tables: TableInfo[];
1525
+ columns: ColumnInfo[];
1526
+ indexes: IndexInfo[];
1527
+ foreign_keys: ForeignKeyInfo[];
1528
+ primary_keys: PrimaryKeyInfo[];
1529
+ views: ViewInfo[];
1530
+ check_constraints: CheckConstraintInfo[];
1531
+ unique_constraints: UniqueConstraintInfo[];
1532
+ comments: CommentInfo[];
1533
+ custom_types: CustomTypesInfo[];
1534
+ triggers: TriggerInfo[];
1535
+ /** Stored functions/procedures. Populated on the Postgres dialects only. */
1536
+ functions?: FunctionInfo[];
1537
+ /**
1538
+ * Individual table partitions and their partitioned parent. Populated on the
1539
+ * Postgres dialects only. Partitions are hidden from `tables`/`foreign_keys`
1540
+ * (like PostgREST), so this carries the partition→parent mapping used to emit
1541
+ * the "Perhaps you meant '<parent>'" hint when a partition is requested.
1542
+ */
1543
+ partitions?: {
1544
+ name: string;
1545
+ schema: string;
1546
+ parent: string;
1547
+ }[];
1548
+ database_name: string;
1549
+ version: string;
1550
+ ddl_dialect?: "postgres" | "sqlite";
1551
+ schema_separator?: string;
1552
+ /**
1553
+ * The API's configured default schema (PostgREST `db-schemas` head). Used to
1554
+ * resolve schema-sensitive catalog lookups (e.g. computed relationships/
1555
+ * columns) for requests that omit `Accept-/Content-Profile`, where the
1556
+ * deparser's `currentSchema` is undefined but the DB still reads this schema.
1557
+ */
1558
+ default_schema?: string;
1559
+ /**
1560
+ * Valid time-zone names from `pg_timezone_names`. Populated on the Postgres
1561
+ * dialects only and cached with the rest of the introspection. Mirrors
1562
+ * PostgREST's cached `TimezoneNames`: a `Prefer: timezone=` value with
1563
+ * `handling=strict` is rejected (PGRST122) unless it is a member. Absent on
1564
+ * sqlite (no such catalog), where the preference stays lenient. Stored as an
1565
+ * array (not a Set) so it survives the JSON schema-cache round-trip.
1566
+ */
1567
+ timezones?: readonly string[];
1568
+ }
1569
+ interface TableDiff {
1570
+ type: "added" | "removed" | "modified";
1571
+ name: string;
1572
+ sql?: string;
1573
+ }
1574
+ interface ColumnDiff {
1575
+ type: "added" | "removed" | "modified";
1576
+ table: string;
1577
+ name: string;
1578
+ changes?: {
1579
+ type?: {
1580
+ from: string;
1581
+ to: string;
1582
+ };
1583
+ nullable?: {
1584
+ from: boolean;
1585
+ to: boolean;
1586
+ };
1587
+ default_value?: {
1588
+ from: string | null;
1589
+ to: string | null;
1590
+ };
1591
+ };
1592
+ column?: ColumnInfo;
1593
+ }
1594
+ interface IndexDiff {
1595
+ type: "added" | "removed";
1596
+ table: string;
1597
+ name: string;
1598
+ unique: boolean;
1599
+ columns: string[];
1600
+ }
1601
+ interface ForeignKeyDiff {
1602
+ type: "added" | "removed";
1603
+ table: string;
1604
+ column: string;
1605
+ ref_table: string;
1606
+ ref_column: string;
1607
+ on_update: string;
1608
+ on_delete: string;
1609
+ }
1610
+ interface DiffResult {
1611
+ tables: TableDiff[];
1612
+ columns: ColumnDiff[];
1613
+ indexes: IndexDiff[];
1614
+ foreign_keys: ForeignKeyDiff[];
1615
+ has_changes: boolean;
1616
+ }
1617
+ declare const enum PlanStepType {
1618
+ DISABLE_FOREIGN_KEYS = "disable_foreign_keys",
1619
+ ENABLE_FOREIGN_KEYS = "enable_foreign_keys",
1620
+ BEGIN_TRANSACTION = "begin_transaction",
1621
+ COMMIT_TRANSACTION = "commit_transaction",
1622
+ CREATE_TABLE = "create_table",
1623
+ ADD_COLUMN = "add_column",
1624
+ DROP_COLUMN = "drop_column",
1625
+ ADD_INDEX = "add_index",
1626
+ DROP_INDEX = "drop_index",
1627
+ DROP_TABLE = "drop_table",
1628
+ RENAME_TABLE = "rename_table",
1629
+ COPY_DATA = "copy_data",
1630
+ CREATE_TRIGGER = "create_trigger"
1631
+ }
1632
+ interface PlanStep {
1633
+ sql: string;
1634
+ description?: string;
1635
+ type?: PlanStepType;
1636
+ /**
1637
+ * Commit the current transaction and begin a new one before running this
1638
+ * step. Set where the planner requires a commit boundary — a statement whose
1639
+ * effect is unusable until its transaction commits, e.g. `ALTER TYPE … ADD
1640
+ * VALUE` followed by anything that uses the new value.
1641
+ *
1642
+ * Execution metadata lives on the step (rather than alongside the plan) so it
1643
+ * survives cloning and JSON round-trips of a `PlanResult`.
1644
+ */
1645
+ newTransaction?: boolean;
1646
+ /** Run this step outside a transaction entirely (e.g. `CREATE INDEX CONCURRENTLY`). */
1647
+ nonTransactional?: boolean;
1648
+ }
1649
+ interface DataLossWarning {
1650
+ table: string;
1651
+ reason: string;
1652
+ }
1653
+ interface PlanResult {
1654
+ steps: PlanStep[];
1655
+ warnings?: DataLossWarning[];
1656
+ unsafe: boolean;
1657
+ }
1658
+ interface SchemaDiffResult {
1659
+ current?: IntrospectResult;
1660
+ desired?: IntrospectResult;
1661
+ diff: DiffResult | string;
1662
+ plan: PlanResult;
1663
+ }
1664
+ /**
1665
+ * Restricts a diff/migrate to a set of schemas (LITE-291). When set, both the
1666
+ * current and desired catalogs are filtered to these schemas, so out-of-scope
1667
+ * (e.g. user-land `public`) objects are invisible to the diff and are never
1668
+ * dropped. Used by `App.ensureSystemSchema()` to reconcile only system schemas.
1669
+ */
1670
+ interface MigrateScope {
1671
+ schemas?: string[];
1672
+ }
1673
+ interface ConnectionMigrator {
1674
+ diff(scope?: MigrateScope): Promise<SchemaDiffResult>;
1675
+ migrate(opts?: {
1676
+ force?: boolean;
1677
+ } & MigrateScope): Promise<SchemaDiffResult>;
1678
+ migratePlan(planResult: PlanResult, opts?: {
1679
+ force?: boolean;
1680
+ }): Promise<void>;
1681
+ safeSortPlanSteps(steps: PlanStep[]): PlanStep[];
1682
+ }
1683
+
1684
+ /**
1685
+ * Nested object for runtime variable substitution.
1686
+ * Paths are resolved via lodash-style dot-path access (e.g. "auth.jwt.role" → vars.auth.jwt.role).
1687
+ * e.g. { auth: { uid: "uuid-here", role: "authenticated", jwt: { role: "admin" } } }
1688
+ */
1689
+ type VarsContext = Record<string, unknown>;
1690
+
1691
+ type ColumnDef = {
1692
+ column?: string;
1693
+ cast?: string;
1694
+ preCast?: string;
1695
+ aggregate?: AggregateFunction;
1696
+ bareCount?: boolean;
1697
+ path?: string;
1698
+ /** True when the trailing JSON-path operator was `->>` (text extract). */
1699
+ pathText?: boolean;
1700
+ /** First key reached after an earlier `->>` text extraction. */
1701
+ invalidJsonTextTraversalKey?: string;
1702
+ };
1703
+ type EmbedDef = {
1704
+ select?: SelectEntry[];
1705
+ where?: Where;
1706
+ order?: OrderEntry[];
1707
+ limit?: number;
1708
+ offset?: number;
1709
+ spread?: boolean;
1710
+ join?: JoinMap;
1711
+ };
1712
+ type SelectEntry = string | Record<string, ColumnDef | EmbedDef>;
1713
+ type JoinDef = {
1714
+ from?: string;
1715
+ type?: "inner" | "left";
1716
+ hint?: string;
1717
+ on?: Where;
1718
+ };
1719
+ type JoinMap = Record<string, JoinDef>;
1720
+ type Where = Record<string, unknown>;
1721
+ type OrderEntry = {
1722
+ column: string;
1723
+ direction?: "asc" | "desc";
1724
+ nullsFirst?: boolean;
1725
+ /** For ordering by embedded resource column: embed alias */
1726
+ embed?: string;
1727
+ };
1728
+ type ExplainOptions = {
1729
+ analyze?: boolean;
1730
+ verbose?: boolean;
1731
+ settings?: boolean;
1732
+ buffers?: boolean;
1733
+ wal?: boolean;
1734
+ };
1735
+ type Meta = {
1736
+ cardinality?: "one" | "maybe" | "many";
1737
+ count?: "exact" | "planned" | "estimated";
1738
+ head?: boolean;
1739
+ maxAffected?: number;
1740
+ rollback?: boolean;
1741
+ missing?: "null" | "default";
1742
+ handling?: "strict" | "lenient";
1743
+ timezone?: string;
1744
+ columns?: string[];
1745
+ stripNulls?: boolean;
1746
+ explain?: ExplainOptions;
1747
+ headers?: Record<string, string>;
1748
+ return?: "minimal" | "headers-only" | "representation";
1749
+ tx?: "commit" | "rollback";
1750
+ };
1751
+ type AnyAST = {
1752
+ type?: string;
1753
+ from?: string;
1754
+ function?: string;
1755
+ schema?: string;
1756
+ join?: JoinMap;
1757
+ select?: SelectEntry[];
1758
+ where?: Where;
1759
+ values?: object | object[];
1760
+ args?: object | unknown[];
1761
+ order?: OrderEntry[];
1762
+ limit?: number;
1763
+ offset?: number;
1764
+ group?: string[];
1765
+ onConflict?: string[];
1766
+ ignoreDuplicates?: boolean;
1767
+ httpMethod?: "GET" | "POST";
1768
+ paramsType?: "named" | "positional";
1769
+ inputType?: "json" | "text" | "binary" | "xml";
1770
+ $meta?: Meta;
1771
+ };
1772
+ type AggregateFunction = "count" | "sum" | "avg" | "min" | "max";
1773
+
1774
+ interface IConnectionConfig extends Partial<KyselyConfig> {
1775
+ url?: string;
1776
+ introspection?: IntrospectOptions;
1777
+ schemaCache?: CacheDriver;
1778
+ /**
1779
+ * Base schema of the connection that is always prepended to any schema operations.
1780
+ * E.g. when migrating to a desired schema, `baseSchema` is always prepended.
1781
+ * This is useful for when auth is enabled, and auth schema must be present.
1782
+ */
1783
+ baseSchema?: string;
1784
+ /** System-owned tables whose own schema enables RLS. */
1785
+ systemRls?: Array<{
1786
+ schema: string;
1787
+ tables: string[];
1788
+ }>;
1789
+ }
1790
+ type Dialect = "sqlite" | "postgres";
1791
+ type TransactionOptions = {
1792
+ intent?: "migration";
1793
+ };
1794
+ type ConnectionContextOptions = {
1795
+ forceRollback?: boolean;
1796
+ /** Reuse an existing transaction so trusted preflights and scoped writes stay atomic. */
1797
+ transaction?: Kysely<any>;
1798
+ /**
1799
+ * Present for RPC (`/rpc/*`) requests on the postgres backend only. Forces the
1800
+ * call into one explicit transaction so request.* GUC injection, GET read-only
1801
+ * mode, and the function's transaction-local response.* GUCs (read back by the
1802
+ * handler) are atomic. Without it, the common anon path runs with no
1803
+ * transaction and `set_config(...,true)` would be lost before the read-back.
1804
+ * Ignored by the base/sqlite pass-through `withContext` (RPC is rejected on
1805
+ * sqlite at server/data.ts, so sqlite never constructs this).
1806
+ */
1807
+ rpc?: {
1808
+ method: string;
1809
+ path: string;
1810
+ readOnly: boolean;
1811
+ requestHeaders?: Record<string, string>;
1812
+ };
1813
+ };
1814
+ declare abstract class Connection<Driver = unknown, DB = any, Config extends IConnectionConfig = IConnectionConfig> {
1815
+ config: Config;
1816
+ kysely: Kysely<DB>;
1817
+ abstract driver: Driver;
1818
+ abstract dialect: Dialect;
1819
+ protected introspection: IntrospectResult | undefined;
1820
+ protected constructor(config: Config);
1821
+ /**
1822
+ * Connection-level DDL translation, mainly for SQLite connections to override.
1823
+ */
1824
+ translateDdl(ddl: string): Promise<unknown>;
1825
+ clearSchemaCache(): Promise<void>;
1826
+ protected readCachedIntrospection(options?: {
1827
+ useCache?: boolean;
1828
+ }): Promise<IntrospectResult | undefined>;
1829
+ protected writeCachedIntrospection(result: IntrospectResult, options?: {
1830
+ useDriver?: boolean;
1831
+ }): Promise<void>;
1832
+ protected deleteCachedIntrospection(): Promise<void>;
1833
+ protected schemaCacheKey(): string;
1834
+ exec<T = {
1835
+ rows: unknown[];
1836
+ } | void>(query: string, ...parameters: readonly unknown[]): Promise<T>;
1837
+ ping(): Promise<boolean | void>;
1838
+ abstract introspect(options?: {
1839
+ useCache?: boolean;
1840
+ }): Promise<IntrospectResult>;
1841
+ transaction(_statements: string[], _opts?: TransactionOptions): Promise<void>;
1842
+ /**
1843
+ * Callback-based transaction API for application code (e.g. AuthRepository)
1844
+ * that needs atomicity across several kysely operations without hand-rolling
1845
+ * BEGIN/COMMIT/ROLLBACK. `fn` is handed a kysely instance bound to the
1846
+ * transaction — use it (not `this.kysely`) for every operation that must
1847
+ * participate.
1848
+ *
1849
+ * Default implementation issues a real BEGIN/COMMIT/ROLLBACK via kysely's
1850
+ * `transaction().execute()`, appropriate for backends where `sql\`BEGIN\``
1851
+ * is meaningful (base sqlite drivers, Postgres). Durable Objects storage
1852
+ * has no such thing — `DoSqliteConnection` overrides this to use
1853
+ * `storage.transaction()` instead, running `fn` against the *same* kysely
1854
+ * instance (see that class for why).
1855
+ */
1856
+ runInTransaction<T>(fn: (trx: Kysely<DB>) => Promise<T>): Promise<T>;
1857
+ abstract close(): Promise<void>;
1858
+ createMigrator(_desiredSchema: string): ConnectionMigrator;
1859
+ onPostgrestAST(ast: AnyAST, _vars?: VarsContext): Promise<AnyAST>;
1860
+ /**
1861
+ * Per-row response coercion run after schema-typed deserialization.
1862
+ * Subclasses fix wire-protocol-shape quirks (e.g. JSON-as-text on
1863
+ * Postgres `json_agg`, numeric-as-string from postgres.js). Default = no-op.
1864
+ */
1865
+ deserializeRow(row: Record<string, unknown>): Record<string, unknown>;
1866
+ /**
1867
+ * Normalize a database error into a PG-style error object.
1868
+ * Override in subclasses to map dialect-specific error codes.
1869
+ */
1870
+ normalizeDbError(e: unknown): unknown;
1871
+ /**
1872
+ * Wrap PostgREST query execution with connection-specific context.
1873
+ * For Postgres: wraps in a transaction with SET LOCAL role/claims.
1874
+ * Default: pass-through.
1875
+ */
1876
+ withContext<T>(_vars: VarsContext | undefined, fn: (db: Kysely<any>) => Promise<T>, opts?: ConnectionContextOptions): Promise<T>;
1877
+ /**
1878
+ * Whether this connection serves RPC (stored functions). SQLite-backed
1879
+ * connections have none; the data route uses this to gate `/rpc/*`.
1880
+ */
1881
+ get supportsRpc(): boolean;
1882
+ /**
1883
+ * OPTIONS write-capability for a view, resolved from the catalog. Returns
1884
+ * `null` when the dialect cannot introspect view updatability via SQL (e.g.
1885
+ * SQLite, where the caller derives it from `INSTEAD OF` triggers instead).
1886
+ * Overridden on the Postgres path.
1887
+ */
1888
+ viewOptionsMetadata(_viewName: string, _viewSchema: string): Promise<ViewOptionsMetadata | null>;
1889
+ }
1890
+ /** Catalog metadata for a view used to build an OPTIONS `Allow` header. */
1891
+ interface ViewOptionsMetadata {
1892
+ canInsert: boolean;
1893
+ canUpdate: boolean;
1894
+ canDelete: boolean;
1895
+ /** Base relations the view reads from, for scoping the PK check. */
1896
+ baseTables: Array<{
1897
+ schema: string;
1898
+ name: string;
1899
+ }>;
1900
+ }
1901
+
1375
1902
  interface Bucket {
1376
1903
  id: string;
1377
1904
  name: string;
@@ -1407,10 +1934,10 @@ interface ListObjectsOptions {
1407
1934
  search?: string;
1408
1935
  }
1409
1936
  declare class StorageRepository {
1937
+ private schema;
1410
1938
  private db;
1411
1939
  private dialect;
1412
- private schema;
1413
- constructor(db: Kysely<any>, dialect: Dialect);
1940
+ constructor(connection: Connection);
1414
1941
  private table;
1415
1942
  private insertInto;
1416
1943
  private update;
@@ -1440,20 +1967,22 @@ declare class StorageRepository {
1440
1967
  name: string;
1441
1968
  owner?: string | null;
1442
1969
  owner_id?: string | null;
1443
- metadata?: Record<string, unknown>;
1444
- user_metadata?: Record<string, unknown>;
1970
+ metadata?: Record<string, unknown> | null;
1971
+ user_metadata?: Record<string, unknown> | null;
1445
1972
  version?: string | null;
1446
1973
  }): Promise<StorageObject>;
1447
1974
  findObjectById(id: string): Promise<StorageObject | null>;
1448
1975
  findObjectByPath(bucketId: string, name: string): Promise<StorageObject | null>;
1449
1976
  listObjects(bucketId: string, prefix?: string, options?: ListObjectsOptions): Promise<StorageObject[]>;
1450
1977
  updateObject(id: string, updates: Partial<{
1978
+ bucket_id: string;
1451
1979
  name: string;
1452
- metadata: Record<string, unknown>;
1453
- user_metadata: Record<string, unknown>;
1980
+ metadata: Record<string, unknown> | null;
1981
+ user_metadata: Record<string, unknown> | null;
1454
1982
  version: string | null;
1455
1983
  owner: string | null;
1456
1984
  owner_id: string | null;
1985
+ updated_at: string;
1457
1986
  }>): Promise<StorageObject | null>;
1458
1987
  deleteObject(id: string): Promise<void>;
1459
1988
  deleteObjectsByBucket(bucketId: string): Promise<string[]>;
@@ -1463,6 +1992,13 @@ declare class StorageRepository {
1463
1992
  private parseObjectRow;
1464
1993
  }
1465
1994
 
1995
+ type StorageRole = string;
1996
+ interface StorageRequestAuth {
1997
+ role: StorageRole;
1998
+ sub: string | null;
1999
+ jwt: Record<string, unknown> | null;
2000
+ }
2001
+
1466
2002
  interface StorageServiceConfig {
1467
2003
  jwtSecret: string;
1468
2004
  fileSizeLimit?: number;
@@ -1481,8 +2017,12 @@ declare class StorageService {
1481
2017
  private config;
1482
2018
  private options;
1483
2019
  private transformationAdapter?;
2020
+ private connection?;
1484
2021
  private initialized;
1485
- constructor(repo: StorageRepository, adapter: StorageAdapter, config: StorageServiceConfig, options?: StorageServiceOptions, transformationAdapter?: TransformationAdapter | undefined);
2022
+ private access;
2023
+ constructor(repo: StorageRepository, adapter: StorageAdapter, config: StorageServiceConfig, options?: StorageServiceOptions, transformationAdapter?: TransformationAdapter | undefined, connection?: Connection | undefined);
2024
+ setRequestAuth(auth: StorageRequestAuth, operation?: string): void;
2025
+ get requestAuth(): StorageRequestAuth;
1486
2026
  init(): Promise<void>;
1487
2027
  createBucket(params: {
1488
2028
  id: string;
@@ -1493,6 +2033,7 @@ declare class StorageService {
1493
2033
  owner?: string | null;
1494
2034
  }): Promise<Bucket>;
1495
2035
  getBucket(id: string): Promise<Bucket>;
2036
+ getBucketBypass(id: string): Promise<Bucket>;
1496
2037
  listBuckets(): Promise<Bucket[]>;
1497
2038
  updateBucket(id: string, updates: {
1498
2039
  public?: boolean;
@@ -1507,32 +2048,34 @@ declare class StorageService {
1507
2048
  contentLength?: number;
1508
2049
  upsert?: boolean;
1509
2050
  metadata?: Record<string, unknown>;
1510
- owner?: string | null;
1511
2051
  }): Promise<StorageObject>;
2052
+ private uploadInternal;
1512
2053
  download(bucketId: string, path: string, options?: {
1513
2054
  transform?: TransformOptions;
1514
2055
  }): Promise<{
1515
2056
  body: CrossReadableStream | Blob | Buffer | Uint8Array;
1516
2057
  metadata: ObjectMetadata;
1517
2058
  }>;
2059
+ private downloadBypass;
2060
+ private downloadObject;
1518
2061
  update(bucketId: string, path: string, body: ReadableStream | Buffer | Uint8Array, options?: {
1519
2062
  contentType?: string;
1520
2063
  cacheControl?: string;
1521
2064
  contentLength?: number;
1522
2065
  metadata?: Record<string, unknown>;
1523
2066
  upsert?: boolean;
1524
- owner?: string | null;
1525
2067
  }): Promise<StorageObject>;
1526
2068
  remove(bucketId: string, paths: string[]): Promise<StorageObject[]>;
1527
2069
  list(bucketId: string, prefix?: string, options?: ListObjectsOptions): Promise<StorageObject[]>;
1528
- move(bucketId: string, fromPath: string, toPath: string): Promise<void>;
1529
- copy(bucketId: string, fromPath: string, toPath: string): Promise<{
2070
+ move(bucketId: string, fromPath: string, toPath: string, destinationBucketId?: string): Promise<void>;
2071
+ copy(bucketId: string, fromPath: string, toPath: string, destinationBucketId?: string, upsert?: boolean): Promise<{
1530
2072
  key: string;
1531
2073
  }>;
1532
2074
  info(bucketId: string, path: string): Promise<StorageObject & {
1533
2075
  httpMetadata: ObjectMetadata;
1534
2076
  }>;
1535
2077
  exists(bucketId: string, path: string): Promise<boolean>;
2078
+ private assertBucketRetrievable;
1536
2079
  createSignedUrl(bucketId: string, path: string, expiresIn: number): Promise<{
1537
2080
  signedUrl: string;
1538
2081
  }>;
@@ -1541,7 +2084,10 @@ declare class StorageService {
1541
2084
  signedUrl: string;
1542
2085
  error: string | null;
1543
2086
  }[]>;
1544
- createSignedUploadUrl(bucketId: string, path: string): Promise<{
2087
+ createSignedUploadUrl(bucketId: string, path: string, upsert?: boolean, options?: {
2088
+ metadata?: Record<string, unknown>;
2089
+ userMetadata?: Record<string, unknown>;
2090
+ }): Promise<{
1545
2091
  signedUrl: string;
1546
2092
  token: string;
1547
2093
  path: string;
@@ -1550,11 +2096,34 @@ declare class StorageService {
1550
2096
  bucket: string;
1551
2097
  path: string;
1552
2098
  intent: "download" | "upload";
2099
+ owner: string | null;
2100
+ upsert: boolean;
1553
2101
  }>;
2102
+ downloadSigned(bucketId: string, path: string, options?: {
2103
+ transform?: TransformOptions;
2104
+ }): Promise<{
2105
+ body: CrossReadableStream | Blob | Buffer | Uint8Array;
2106
+ metadata: ObjectMetadata;
2107
+ }>;
2108
+ uploadSigned(bucketId: string, path: string, body: ReadableStream | Buffer | Uint8Array, options: {
2109
+ contentType?: string;
2110
+ cacheControl?: string;
2111
+ contentLength?: number;
2112
+ upsert?: boolean;
2113
+ metadata?: Record<string, unknown>;
2114
+ owner: string | null;
2115
+ }): Promise<StorageObject>;
1554
2116
  private signStorageToken;
2117
+ private uploadPermissionValues;
2118
+ private databaseErrorCode;
1555
2119
  }
1556
2120
 
2121
+ /** Trusted socket metadata supplied by an adapter that owns the listener. */
2122
+ type AppRequestContext = {
2123
+ peerAddress: string | null;
2124
+ };
1557
2125
  type HonoContext = {
2126
+ Bindings: AppRequestContext;
1558
2127
  Variables: {
1559
2128
  app: App;
1560
2129
  authService: AuthService;
@@ -2405,6 +2974,7 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2405
2974
  input: {
2406
2975
  json: {
2407
2976
  [x: string]: unknown;
2977
+ destinationBucket?: string | undefined;
2408
2978
  bucketId: string;
2409
2979
  sourceKey: string;
2410
2980
  destinationKey: string;
@@ -2423,6 +2993,7 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2423
2993
  input: {
2424
2994
  json: {
2425
2995
  [x: string]: unknown;
2996
+ destinationBucket?: string | undefined;
2426
2997
  bucketId: string;
2427
2998
  sourceKey: string;
2428
2999
  destinationKey: string;
@@ -2723,6 +3294,7 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2723
3294
  unique: boolean;
2724
3295
  columns: string[];
2725
3296
  schema: string;
3297
+ sql?: string | undefined;
2726
3298
  }[];
2727
3299
  foreign_keys: {
2728
3300
  table: string;
@@ -2817,8 +3389,6 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2817
3389
  };
2818
3390
  }, "/_system">, "/", "*">;
2819
3391
 
2820
- type Where = Record<string, unknown>;
2821
-
2822
3392
  type PolicyCommand = "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "ALL";
2823
3393
  type PolicyRole = "anon" | "authenticated" | string;
2824
3394
  interface PolicyData {
@@ -2841,7 +3411,7 @@ declare class Policy {
2841
3411
  }
2842
3412
 
2843
3413
  interface IAppConfig extends DefaultSchema {
2844
- connection: Connection | Promise<Connection>;
3414
+ connection: Connection$1 | Promise<Connection$1>;
2845
3415
  rls?: {
2846
3416
  tables: string[];
2847
3417
  policies: Policy[];
@@ -2866,7 +3436,7 @@ interface SystemOptions {
2866
3436
  schemaReconciliation?: "additive" | "full";
2867
3437
  }
2868
3438
  interface DefaultAppConfig extends IAppConfig {
2869
- connection: Connection;
3439
+ connection: Connection$1;
2870
3440
  options?: {
2871
3441
  defaults?: true;
2872
3442
  server?: ServerOptions;
@@ -2874,7 +3444,7 @@ interface DefaultAppConfig extends IAppConfig {
2874
3444
  system?: SystemOptions;
2875
3445
  };
2876
3446
  }
2877
- declare class App<Config extends IAppConfig = DefaultAppConfig, Conn = Config extends IAppConfig ? Config["connection"] extends Connection ? Config["connection"] : Config["connection"] extends Promise<Connection> ? Awaited<Config["connection"]> : Connection : never> {
3447
+ declare class App<Config extends IAppConfig = DefaultAppConfig, Conn = Config extends IAppConfig ? Config["connection"] extends Connection$1 ? Config["connection"] : Config["connection"] extends Promise<Connection$1> ? Awaited<Config["connection"]> : Connection$1 : never> {
2878
3448
  #private;
2879
3449
  private readonly _connection;
2880
3450
  private readonly _rls;
@@ -2909,6 +3479,7 @@ declare class App<Config extends IAppConfig = DefaultAppConfig, Conn = Config ex
2909
3479
  ensureSystemSchema(opts?: {
2910
3480
  force?: boolean;
2911
3481
  }): Promise<void>;
3482
+ hasEnabledSystemBaseSchema(): boolean;
2912
3483
  isValidConfig(config: Schema | DefaultSchema | IAppConfig): boolean;
2913
3484
  getClient<SchemaName extends string = "public">(options?: SupabaseClientOptions<SchemaName> & {
2914
3485
  apikey?: string;
@@ -2959,7 +3530,7 @@ declare class App<Config extends IAppConfig = DefaultAppConfig, Conn = Config ex
2959
3530
  }>;
2960
3531
  } ? Omit<any, "__InternalSupabase">[SchemaName] : never, any>;
2961
3532
  isLocalRequest(request: Request): boolean;
2962
- fetch: (request: Request) => Promise<Response>;
3533
+ fetch: (request: Request, context?: AppRequestContext) => Promise<Response>;
2963
3534
  getInfoJson(): {
2964
3535
  connection: object;
2965
3536
  config: Config;
@@ -2977,14 +3548,15 @@ type SupaliteOptions = {
2977
3548
  initOnBoot?: boolean;
2978
3549
  prefixes?: string[];
2979
3550
  /**
2980
- * Local admin mode (default `true`): keyless, same-origin, loopback
2981
- * requests from the dev server run as `service_role`. In practice that
2982
- * means `/rest/v1` here — admin mode also covers `/storage/v1`, but this
2983
- * plugin does not mount that prefix unless you add it to `prefixes`.
3551
+ * Local admin mode: defaults on for loopback Vite dev hosts and off for
3552
+ * exposed hosts. Keyless, same-origin, loopback requests run as
3553
+ * `service_role`. In practice that means `/rest/v1` here — admin mode also
3554
+ * covers `/storage/v1`, but this plugin does not mount that prefix unless
3555
+ * you add it to `prefixes`.
2984
3556
  *
2985
- * See `ServerOptions.admin` for the caveats. Never applied in
2986
- * `vite preview`, which serves a production build; an explicit value here
2987
- * also outranks `options.server.admin` in `config.toml`.
3557
+ * See `ServerOptions.admin` for the caveats. An explicit value here
3558
+ * outranks `options.server.admin`; explicit `true` is required to enable
3559
+ * admin on an exposed host. Never applied in `vite preview`.
2988
3560
  */
2989
3561
  admin?: boolean;
2990
3562
  };