@supabase/lite 0.2.1-next.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/STATUS.md +7 -6
- package/dist/{Connection-rAPmec1m.d.ts → Connection-CSVCuMv-.d.ts} +1 -152
- package/dist/cli/index.js +152 -128
- package/dist/cli/lib.js +39 -36
- package/dist/db/browser/index.d.ts +3 -532
- package/dist/db/browser/index.js +3 -207
- package/dist/db/bun/index.d.ts +3 -532
- package/dist/db/bun/index.js +3 -207
- package/dist/db/fallback.d.ts +4 -180
- package/dist/db/fallback.js +2 -205
- package/dist/db/node/index.d.ts +3 -532
- package/dist/db/node/index.js +3 -207
- package/dist/db/postgres/{BasePostgresConnection-B7zHDAib.d.ts → BasePostgresConnection-Clykq58D.d.ts} +1 -1
- package/dist/db/postgres/PostgresConnection.d.ts +1 -1
- package/dist/db/postgres/PostgresConnection.js +21 -25
- package/dist/db/postgres/pglite/PgliteConnection.d.ts +1 -1
- package/dist/db/postgres/pglite/PgliteConnection.js +25 -27
- package/dist/db/workerd/index.d.ts +6 -535
- package/dist/db/workerd/index.js +2 -206
- package/dist/index.d.ts +329 -7
- package/dist/index.js +252 -54
- package/dist/vite/index.js +2 -6
- package/package.json +4 -8
package/README.md
CHANGED
|
@@ -174,7 +174,6 @@ supabase/
|
|
|
174
174
|
```toml
|
|
175
175
|
[api]
|
|
176
176
|
port = 54321
|
|
177
|
-
max_rows = 1000
|
|
178
177
|
|
|
179
178
|
[db]
|
|
180
179
|
driver = "sqlite-postgres" # or "sqlite" | "pglite" | "postgres"
|
|
@@ -204,7 +203,7 @@ enable_confirmations = false
|
|
|
204
203
|
|
|
205
204
|
Write **Postgres DDL** in `supabase/schemas/*.sql`. When the DB driver is SQLite, DDL is translated on the fly (`SERIAL` → `INTEGER PRIMARY KEY AUTOINCREMENT`, `NOW()` → `datetime('now')`, `JSONB` → `TEXT` with a `json_valid()` check, and so on). Postgres-only features that don't translate (ranges, `LATERAL`, table inheritance) throw a descriptive error.
|
|
206
205
|
|
|
207
|
-
RLS works across all backends: on SQLite, policies are extracted from DDL and enforced at the application layer by rewriting the query AST; on PGlite/Postgres, native RLS is used. `auth.uid()`, `auth.jwt()`, and roles (`anon`, `authenticated`) resolve from the JWT.
|
|
206
|
+
RLS works across all backends: on SQLite, policies are extracted from DDL and enforced at the application layer by rewriting the query AST; on PGlite/Postgres, native RLS is used. `auth.uid()`, `auth.jwt()`, and roles (`anon`, `authenticated`, `service_role`) resolve from the JWT.
|
|
208
207
|
|
|
209
208
|
Full translation reference: [STATUS.md#postgres-to-sqlite-translation](https://github.com/supabase-community/lite/blob/HEAD/STATUS.md#postgres-to-sqlite-translation) and [`app/POSTGRES-SQLITE-COMPAT.md`](https://github.com/supabase-community/lite/blob/HEAD/app/POSTGRES-SQLITE-COMPAT.md).
|
|
210
209
|
|
package/STATUS.md
CHANGED
|
@@ -34,9 +34,9 @@ Feature and API compatibility tracking for @supabase/lite. For usage docs, see [
|
|
|
34
34
|
|
|
35
35
|
## Postgres-to-SQLite Translation
|
|
36
36
|
|
|
37
|
-
When using SQLite databases, SQL schemas written in Postgres dialect are translated on the fly. The translator extends the Postgres deparser. It passes through 1:1 compatible syntax unchanged, rewrites constructs that have SQLite equivalents (for example `SERIAL` → `INTEGER PRIMARY KEY AUTOINCREMENT`, `NOW()` → `datetime('now')`), silently drops Postgres-only decorators (storage parameters, locking clauses), and errors on features that have no SQLite counterpart (`LATERAL` joins, table inheritance).
|
|
37
|
+
When using SQLite databases, SQL schemas written in Postgres dialect are translated on the fly. The translator extends the Postgres deparser. It passes through 1:1 compatible syntax unchanged, rewrites constructs that have SQLite equivalents (for example `SERIAL` → `INTEGER PRIMARY KEY AUTOINCREMENT`, `NOW()` → `datetime('now')`), silently drops Postgres-only decorators and relation/schema privilege metadata (storage parameters, locking clauses, table/schema/sequence grants), and errors on features that have no SQLite counterpart (`LATERAL` joins, table inheritance, function grants).
|
|
38
38
|
|
|
39
|
-
📋 See [`app/POSTGRES-SQLITE-COMPAT.md`](https://github.com/supabase-community/lite/blob/HEAD/app/POSTGRES-SQLITE-COMPAT.md) for the full auto-generated compatibility reference (
|
|
39
|
+
📋 See [`app/POSTGRES-SQLITE-COMPAT.md`](https://github.com/supabase-community/lite/blob/HEAD/app/POSTGRES-SQLITE-COMPAT.md) for the full auto-generated compatibility reference (71 entries).
|
|
40
40
|
|
|
41
41
|
Here is an example of a Postgres schema that is translated to SQLite:
|
|
42
42
|
|
|
@@ -190,7 +190,7 @@ RLS is supported on all database backends. The enforcement strategy differs by d
|
|
|
190
190
|
|
|
191
191
|
📖 See [`internal/docs/postgres/rls.md`](https://github.com/supabase-community/lite/blob/HEAD/internal/docs/postgres/rls.md) for the full RLS reference and behavior matrix.
|
|
192
192
|
|
|
193
|
-
**PGlite / PostgreSQL auto-setup:** When any table has `ENABLE ROW LEVEL SECURITY`, supalite creates `anon` and `
|
|
193
|
+
**PGlite / PostgreSQL auto-setup:** When any table has `ENABLE ROW LEVEL SECURITY`, supalite creates `anon`, `authenticated`, and `service_role` roles (if missing; `service_role` uses `BYPASSRLS`) and grants default privileges on all tables and sequences in the relevant schemas. No manual `CREATE ROLE` or `GRANT` statements needed for these built-in roles.
|
|
194
194
|
|
|
195
195
|
### PL/pgSQL Trigger Functions
|
|
196
196
|
|
|
@@ -644,7 +644,7 @@ Help groups match upstream: **Local Development** (commands you run from a proje
|
|
|
644
644
|
|
|
645
645
|
| Command | Status | Notes |
|
|
646
646
|
|-----------|--------|--------------------------------------------------------------------|
|
|
647
|
-
| `init` | ✅ |
|
|
647
|
+
| `init` | ✅ | Scaffolds API, migration/seed paths, and auth defaults; flags differ upstream |
|
|
648
648
|
| `start` | ✅ | In-process; no Docker stack flags (`-x`, `--ignore-health-check`) |
|
|
649
649
|
| `status` | 🧪 | `[experimental]` `[lite]`: shows linked project metadata |
|
|
650
650
|
| `login` | 🧪 | `[experimental]` Email/password against supalite cloud |
|
|
@@ -667,11 +667,12 @@ Help groups match upstream: **Local Development** (commands you run from a proje
|
|
|
667
667
|
|
|
668
668
|
| Command | Status | Notes |
|
|
669
669
|
|---------------|--------|----------------------------------------------------------------------|
|
|
670
|
-
| `db diff` | ✅ |
|
|
670
|
+
| `db diff` | ✅ | `--local` semantics; `-f` emits pg-DDL migrations from declarative schemas |
|
|
671
671
|
| `db query` | ✅ | Renamed from top-level `exec`; supports `--remote` and `--config` |
|
|
672
672
|
| `db schema` | ✅ | `[lite]`: moved from top-level; `--diff` and `--sql` modes |
|
|
673
673
|
| `db push` | 🔄 | Not registered; use `lite cloud deploy` |
|
|
674
|
-
| `db
|
|
674
|
+
| `db reset` | ✅ | Replays migrations + seed; does not apply declarative schema_paths |
|
|
675
|
+
| `db pull`, `db dump`, `db lint`, `db advisors` | 🔄 | Not registered |
|
|
675
676
|
| `db start` | 🚫 | Not applicable; in-process, no separate DB start |
|
|
676
677
|
|
|
677
678
|
### `migration` group
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ParseResult } from 'libpg-query';
|
|
2
|
-
import { DeparserOptions } from 'pgsql-deparser';
|
|
3
1
|
import { SelectQueryBuilder, InsertQueryBuilder, UpdateQueryBuilder, DeleteQueryBuilder, KyselyConfig, Kysely } from 'kysely';
|
|
4
2
|
|
|
5
3
|
/**
|
|
@@ -256,128 +254,6 @@ type TranslatorConfig = {
|
|
|
256
254
|
basePath?: string;
|
|
257
255
|
};
|
|
258
256
|
|
|
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
257
|
interface TableInfo {
|
|
382
258
|
name: string;
|
|
383
259
|
sql: string;
|
|
@@ -598,33 +474,6 @@ interface ConnectionMigrator {
|
|
|
598
474
|
safeSortPlanSteps(steps: PlanStep[]): PlanStep[];
|
|
599
475
|
}
|
|
600
476
|
|
|
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
477
|
interface CacheSetOptions {
|
|
629
478
|
ttl?: number;
|
|
630
479
|
}
|
|
@@ -707,4 +556,4 @@ declare abstract class Connection<Driver = unknown, DB = any, Config extends ICo
|
|
|
707
556
|
withContext<T>(_vars: VarsContext | undefined, fn: (db: Kysely<any>) => Promise<T>, _opts?: ConnectionContextOptions): Promise<T>;
|
|
708
557
|
}
|
|
709
558
|
|
|
710
|
-
export { type
|
|
559
|
+
export { type QbUpdate as $, type AnyAST as A, type BaseAST as B, Connection as C, DataLossError as D, type EmbedDef as E, type FiltersResult as F, type InsertAST as G, type HeadersResult as H, type IConnectionConfig as I, type IntrospectOptions as J, type JoinDef as K, type JoinMap as L, type Meta as M, MigrationError as N, type OrderEntry as O, type PlanResult as P, type PlanStep as Q, PlanStepType as R, type PreferToken as S, type TransactionOptions as T, type PrimaryKeyInfo as U, type VarsContext as V, type Where as W, type Qb as X, type QbDelete as Y, type QbInsert as Z, type QbSelect as _, type IntrospectResult as a, type QueryAST as a0, type QueryParamsResult as a1, RelationNotFoundError as a2, type RouteResult as a3, type RpcAST as a4, type RpcResult as a5, type SchemaDiffResult as a6, type SelectEntry as a7, type SelectResult as a8, type TableDiff as a9, type TableInfo as aa, type TextSearchValue as ab, type TransformsResult as ac, type TranslatorConfig as ad, type TriggerInfo as ae, type UniqueConstraintInfo as af, type UpdateAST as ag, type UpsertAST as ah, type UpsertResult as ai, type ViewInfo as aj, type WhereValue as ak, isRef as al, type CacheDriver as b, type CacheSetOptions as c, type AST as d, type ASTType as e, type AggregateFunction as f, type BodyResult as g, type CheckConstraintInfo as h, type ColumnDef as i, type ColumnDiff as j, type ColumnInfo as k, type ColumnRef as l, type CommentInfo as m, type ConnectionContextOptions as n, type ConnectionMigrator as o, type CustomTypesInfo as p, type DataLossWarning as q, type DeleteAST as r, type Dialect as s, type DiffResult as t, type EmbedTransform as u, type ExplainOptions as v, type ForeignKeyDiff as w, type ForeignKeyInfo as x, type IndexDiff as y, type IndexInfo as z };
|