@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
@@ -0,0 +1,88 @@
1
+ ---
2
+ title: "Storage overview"
3
+ description: "Storage API for @supabase/lite: experimental flag, endpoint coverage, and supabase-js parity."
4
+ ---
5
+
6
+ import { Aside, Card, CardGrid, Steps } from '@astrojs/starlight/components';
7
+
8
+ Supabase Lite ships a Storage API at `/storage/v1/*` covering all 20 endpoints upstream Supabase Storage exposes to `supabase-js`: bucket CRUD, object upload/download/list/remove/move/copy, signed URLs, and image transformations. The same policies on `storage.buckets` and `storage.objects` work on SQLite, PGlite, and PostgreSQL. For the shipped surface, `@supabase/supabase-js`'s `storage` client works unchanged.
9
+
10
+ <Aside type="caution">
11
+ Storage is **experimental** and disabled by default. It is gated behind the `EXPERIMENTAL_STORAGE` environment variable and requires you to wire a storage adapter explicitly. Don't rely on it in production.
12
+ </Aside>
13
+
14
+ ## Enabling it
15
+
16
+ Storage requires three things to be true at once:
17
+
18
+ <Steps>
19
+
20
+ 1. **Set the experimental flag**
21
+
22
+ ```bash
23
+ EXPERIMENTAL_STORAGE=1 lite dev
24
+ ```
25
+
26
+ Without this, `/storage/v1/*` returns 404 and no storage schema is applied, even if `storage.enabled` is set.
27
+
28
+ 1. **Enable storage in config**
29
+
30
+ ```toml
31
+ [storage]
32
+ enabled = true
33
+ file_size_limit = "50MiB"
34
+ ```
35
+
36
+ 1. **Attach a storage adapter**
37
+
38
+ If you construct the `App` programmatically, set an adapter before calling `init()`:
39
+
40
+ ```ts
41
+ import { App } from "@supabase/lite";
42
+ import { FilesystemStorageAdapter } from "@supabase/lite/storage/adapters/FilesystemStorageAdapter";
43
+
44
+ const app = new App({ connection, storage: { enabled: true } });
45
+ app._storageAdapter = new FilesystemStorageAdapter({ basePath: "./supabase/.temp/storage" });
46
+ await app.init();
47
+ ```
48
+
49
+ The `lite` CLI (`lite dev` / `lite start`) auto-wires a `FilesystemStorageAdapter` under `.temp/storage` for you when `EXPERIMENTAL_STORAGE=1` and `storage.enabled` are both set, so CLI users only need steps 1 and 2.
50
+
51
+ </Steps>
52
+
53
+ <Aside type="note">
54
+ The explicit-adapter requirement is a stopgap while storage is experimental. Once stable, an adapter will be required outright (error instead of silent no-op) rather than auto-wired by the CLI. Confirm current behavior against the `EXPERIMENTAL_STORAGE` handling in your installed version if you're embedding the `App` class directly.
55
+ </Aside>
56
+
57
+ ## What's implemented
58
+
59
+ All 20 supabase-js storage methods map to real endpoints: `upload`, `download`, `list`, `remove`, `move`, `copy`, `info`, `exists`, `update`, `getPublicUrl`, `createSignedUrl`, `createSignedUrls`, `createSignedUploadUrl`, `uploadToSignedUrl`, `listBuckets`, `getBucket`, `createBucket`, `updateBucket`, `deleteBucket`, `emptyBucket`.
60
+
61
+ `/storage/v1` is transform-only for API keys, like upstream self-hosted Kong: a missing or invalid `apikey` never 401s at the gateway, so public objects, signed URLs, and S3 presigned flows stay keyless. When a key is present, it resolves to a role — a secret key satisfies storage's own authed routes as `service_role`. See [API keys](/auth/overview#api-keys).
62
+
63
+ Storage verifies bearer JWTs with the Data API verifier. Missing credentials become `anon`; protected operations return a Storage-shaped 401 for a malformed, invalid, or expired bearer JWT. Object `GET`, `HEAD`, and info routes tolerate an invalid JWT so stale sessions do not block public objects. As upstream does, an unauthenticated request to those routes receives `NoSuchBucket` for a private bucket; a verified `anon` JWT can still use an `anon` `SELECT` policy. `service_role` bypasses Storage RLS, while custom string roles remain available to `TO role` policies. Uploads made with a verified JWT carrying a `sub` claim populate `owner_id` and `owner` from that claim; `service_role` uploads remain ownerless. Public buckets bypass object `SELECT` for `GET`, `HEAD`, and info; listing, signing, copy, and move remain caller-scoped. Signed URL redemption uses the authorization decision made when the URL was created. These behaviors match [Supabase Storage access control](https://supabase.com/docs/guides/storage/security/access-control).
64
+
65
+ The protected `storage` schema is not exposed through `/rest/v1` by default; use `supabase.storage` and `/storage/v1` for normal operations. You may explicitly add `storage` to `api.schemas` for direct metadata reads. Treat those endpoints as read-only: PostgREST writes may succeed when policies permit, but they are unsupported because they do not update the backing filesystem or object store. On SQLite, Storage's system declaration keeps `storage.buckets` and `storage.objects` fail-closed even if external runtime metadata omits their RLS entries: no policies means no caller access, while `service_role` keeps its upstream bypass.
66
+
67
+ The upstream policy helpers `storage.foldername()`, `storage.filename()`, `storage.extension()`, `storage.operation()`, `storage.allow_only_operation()`, and `storage.allow_any_operation()` work on SQLite, PGlite, and PostgreSQL. `storage.operation()` returns the complete upstream route identifier, such as `storage.object.upload`, and can be used with comparison, `LIKE`/`ILIKE`, `IN`, and null predicates; the `allow_*` helpers accept identifiers with or without the `storage.` prefix. Policies can therefore distinguish actions such as object listing from authenticated download. See [Supabase Storage helper functions](https://supabase.com/docs/guides/storage/schema/helper-functions) for their canonical policy forms.
68
+
69
+ ```ts
70
+ const { data, error } = await supabase.storage
71
+ .from("avatars")
72
+ .upload("public/avatar1.png", file);
73
+
74
+ const { data: url } = supabase.storage
75
+ .from("avatars")
76
+ .getPublicUrl("public/avatar1.png");
77
+ ```
78
+
79
+ <CardGrid>
80
+ <Card title="Storage adapters">
81
+ Filesystem, S3-compatible, and image transformation backends, and how to configure each. [Read more →](/storage/adapters/)
82
+ </Card>
83
+ <Card title="Storage limitations">
84
+ What's not implemented yet: TUS uploads, webhooks, and the server-side S3 protocol. [Read more →](/storage/limitations/)
85
+ </Card>
86
+ </CardGrid>
87
+
88
+ For the Storage concepts that behave the same as upstream (bucket/object model, public vs. private buckets, MIME allow-lists), see the [Supabase Storage docs](https://supabase.com/docs/guides/storage).
@@ -0,0 +1,108 @@
1
+ ---
2
+ title: "Upgrading to Supabase"
3
+ description: "Migrate a Supabase Lite project to hosted or local Supabase with lite upgrade."
4
+ ---
5
+
6
+ import { Aside, Tabs, TabItem } from '@astrojs/starlight/components';
7
+
8
+ Supabase Lite is a starting point, not an end state. `lite upgrade` migrates a local Supabase Lite project (schema, `auth.users`/`auth.identities`, application table data, optionally sessions) to a hosted or local Supabase project.
9
+
10
+ <Aside type="caution">
11
+ Storage and Realtime migration are not implemented yet. If either is enabled, the command warns and continues with schema/auth/data migration only.
12
+ </Aside>
13
+
14
+ ## Quick start
15
+
16
+ Hosted Supabase is the default target:
17
+
18
+ ```bash
19
+ lite upgrade
20
+ lite upgrade --target hosted
21
+ ```
22
+
23
+ Rehearse first, with no changes to any target:
24
+
25
+ ```bash
26
+ lite upgrade --dry-run
27
+ ```
28
+
29
+ ```bash
30
+ lite upgrade --dry-run --json # machine-readable output
31
+ ```
32
+
33
+ Skip the interactive confirmation:
34
+
35
+ ```bash
36
+ lite upgrade --force
37
+ ```
38
+
39
+ ## Targets
40
+
41
+ <Tabs>
42
+ <TabItem label="Hosted (default)">
43
+ `--target hosted` creates a new hosted Supabase project through the Supabase Management API, waits for it to become healthy, applies schema/auth/data, fetches API keys, and prints the new project details.
44
+
45
+ ```bash
46
+ lite upgrade \
47
+ --target hosted \
48
+ --org-id <organization-id-or-slug> \
49
+ --region <region-key> \
50
+ --project-name <name> \
51
+ --supabase-token <personal-access-token>
52
+ ```
53
+
54
+ If `--supabase-token` is omitted, `SUPABASE_ACCESS_TOKEN` is used. Missing required values are prompted for interactively. Only `--mode user` is currently supported; `--mode platform` is reserved for future work.
55
+ </TabItem>
56
+ <TabItem label="Local">
57
+ `--target local` upgrades into a local [Supabase CLI](https://supabase.com/docs/guides/local-development) workdir. By default that's the current directory, so the command rewrites `./supabase/config.toml` in place, stripping the Supabase Lite-only `[db].driver`/`[db].url` keys and repointing at the Supabase CLI stack. **This breaks the Supabase Lite dev server until the config is restored.**
58
+
59
+ The original config is backed up first to `./supabase/config.toml.bak`:
60
+
61
+ ```bash
62
+ cp supabase/config.toml.bak supabase/config.toml # or: git checkout supabase/config.toml
63
+ ```
64
+
65
+ Use `--local-dir` to target a separate directory instead and leave the project's own `config.toml` untouched:
66
+
67
+ ```bash
68
+ lite upgrade --target local --local-dir ../my-local-supabase --force --no-migrate-sessions
69
+ ```
70
+
71
+ The local target drives the Supabase CLI via `bunx supabase@2.98.1` (override with `LITE_SUPABASE_CLI`), pins `db.major_version = 15`, enables Studio, and disables services not needed for verification (mailpit, realtime, storage, imgproxy, edge runtime, analytics, supavisor). It leaves the local stack running after a successful upgrade; stop it with `bunx supabase@2.98.1 stop --workdir <dir> --no-backup`.
72
+ </TabItem>
73
+ </Tabs>
74
+
75
+ ## The SQLite-shim audit
76
+
77
+ Every non-dry-run upgrade first runs readiness checks and an in-memory PGlite rehearsal of the generated schema/auth/data SQL, and only proceeds to the real target if that rehearsal succeeds.
78
+
79
+ `--dry-run` runs that readiness/rehearsal phase and stops there: no target is created or changed. Part of readiness is a scan of **SQLite-shim-backed fields**: columns whose SQLite representation depends on an application-layer shim (UUID validation, JSON-domain casts, boolean-as-integer, enum `CHECK` constraints, and similar) rather than a native Postgres type. The audit reports affected column counts, sample raw values, and sample row IDs so you can review anything that needs attention before it's translated into real Postgres data.
80
+
81
+ ```bash
82
+ lite upgrade --dry-run # readiness + rehearsal + shim audit, human-readable
83
+ lite upgrade --dry-run --json # same, as structured JSON
84
+ ```
85
+
86
+ See [Postgres/SQLite translation](/database/postgres-sqlite-translation) for what each shim represents and why it exists.
87
+
88
+ ## What doesn't carry over cleanly
89
+
90
+ - **Storage and Realtime**: not migrated. The command warns and continues.
91
+ - **SQLite-only RLS behavior**: SQLite enforces RLS by rewriting the PostgREST query AST at the application layer (see [RLS](/database/rls)); Postgres uses native RLS. Policies that only work because of the SQLite rewrite (or that hit a [known SQLite RLS limitation](/database/rls)) need re-checking against native Postgres semantics after upgrade.
92
+ - **Unsupported SQLite-side features**: range types, quantified comparisons (`eq(any)`, etc.), `rpc()`, multi-schema access, and full regex all behave differently or not at all on SQLite (see [Compatibility](/compatibility)). Code written around those gaps may now have real Postgres equivalents available and worth adopting.
93
+ - **Sessions**: preserved on hosted targets only, via `--migrate-sessions`, by importing `auth.jwt_secret` as a Supabase HS256 signing key. The local target does not support this yet; users re-authenticate after a local upgrade.
94
+ - **Weak JWT secrets**: session migration is blocked non-interactively unless you pass `--allow-weak-jwt-secret`.
95
+
96
+ ## Session migration
97
+
98
+ ```bash
99
+ lite upgrade --migrate-sessions
100
+ ```
101
+
102
+ If `auth.jwt_secret` is missing, hosted session migration fails and the CLI asks you to rerun with `--no-migrate-sessions`. Without session migration, existing tokens become invalid and users must sign in again.
103
+
104
+ ## Related
105
+
106
+ - [Postgres/SQLite translation](/database/postgres-sqlite-translation): what the shim audit is checking for.
107
+ - [Database backends](/database/backends): running against PGlite/Postgres directly instead of upgrading.
108
+ - Upstream: [Supabase local development](https://supabase.com/docs/guides/local-development) and [Database migrations](https://supabase.com/docs/guides/deployment/database-migrations).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/lite",
3
- "version": "0.9.0",
3
+ "version": "0.9.1-next.2",
4
4
  "description": "Lightweight TypeScript-native Supabase implementation on SQLite (alpha). PostgREST + GoTrue compatible — use @supabase/supabase-js as-is.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -74,7 +74,9 @@
74
74
  "UPGRADE.md",
75
75
  "LIMITATIONS.md",
76
76
  "PATTERNS.md",
77
+ "FEATURES.md",
77
78
  "skills",
79
+ "docs",
78
80
  "!dist/*.tsbuildinfo",
79
81
  "!dist/*.map",
80
82
  "!dist/**/*.map",
@@ -119,12 +121,14 @@
119
121
  "build": "bun run build.ts",
120
122
  "build:all": "bun run build:static && bun run build.ts --types --minify",
121
123
  "build:static": "vite build",
124
+ "check:bundle": "bun run internal/bundle-budget.ts",
122
125
  "watch:static": "vite build --watch",
123
126
  "dev:bun": "bun run --hot dev/bun/bun.dev.ts",
124
127
  "debug:bun": "bun run --hot dev/debug.ts",
125
128
  "debug:node": "tsx --watch dev/debug.ts",
126
129
  "cli": "LOCAL=1 bun src/cli/index.ts",
127
130
  "docs:generate": "bun run internal/extract.ts",
131
+ "docs:index": "bun run internal/package-docs.ts",
128
132
  "smoke:pack": "bun run internal/smoke-pack.ts",
129
133
  "prepack": "bun run internal/package-readme.ts prepare",
130
134
  "postpack": "bun run internal/package-readme.ts cleanup",
@@ -7,7 +7,7 @@ description: Use when building or debugging an app that uses `@supabase/lite` (a
7
7
 
8
8
  `@supabase/lite` (a.k.a. supalite) is a lightweight TypeScript implementation of the Supabase REST + Auth APIs over SQLite (with PGlite / Postgres as alternative drivers). `@supabase/supabase-js` works against it unchanged.
9
9
 
10
- The package is pre-1.0 and changes fast. **Do not rely on this skill's specifics — fetch the installed package's docs first.** Authoritative content (limitations, anti-patterns, patterns, full status) ships inside the package and updates with every `npm install`.
10
+ The package is pre-1.0 and changes fast. **Do not rely on this skill's specifics — fetch the installed package's docs first.** Authoritative content (limitations, anti-patterns, patterns, full status) ships inside the package and updates with every `npm install`. The full product documentation ships too, at `node_modules/@supabase/lite/docs/` (MDX, matching the installed version), and is published at https://docs.lite.dev.
11
11
 
12
12
  ## Cold start (do this before writing code)
13
13
 
@@ -15,8 +15,9 @@ The package is pre-1.0 and changes fast. **Do not rely on this skill's specifics
15
15
  2. `cat node_modules/@supabase/lite/LIMITATIONS.md` — agent-facing cheat sheet of what's not supported and what to avoid (anti-patterns). One-line bullets, links into STATUS.md for detail. Read this **first**.
16
16
  3. `cat node_modules/@supabase/lite/PATTERNS.md` — canonical recipes (per-user RLS, embedded filters, custom server logic, Vite cold start, triggers).
17
17
  4. `cat node_modules/@supabase/lite/README.md` — install, quick start, CLI, Vite plugin, project layout.
18
- 5. `cat node_modules/@supabase/lite/STATUS.md` only when you need detail behind a LIMITATIONS bullet, or when planning a feature that touches RLS / embedding / auth.
19
- 6. Pick the right runtime path (see decision rule below) before writing the dev server / client.
18
+ 5. `cat node_modules/@supabase/lite/docs/llms.txt` index of the full product docs (database, auth, storage, integrations, CLI). Read the page for the area you're touching, e.g. `docs/database/rls.mdx`, `docs/integrations/vite.mdx`.
19
+ 6. `cat node_modules/@supabase/lite/STATUS.md` only when you need detail behind a LIMITATIONS bullet, or when planning a feature that touches RLS / embedding / auth.
20
+ 7. Pick the right runtime path (see decision rule below) before writing the dev server / client.
20
21
 
21
22
  ## Decision rule
22
23
 
@@ -26,7 +27,7 @@ The package is pre-1.0 and changes fast. **Do not rely on this skill's specifics
26
27
  | Non-Vite app, want auto schema-reload | `lite dev` (separate process) | Watches `schemas/*.sql`. |
27
28
  | Non-Vite app, manual control / CI / prod-like | `lite start` (separate process) | No watch, no auto-migrate. |
28
29
 
29
- **Never** run `lite dev` or `lite start` alongside the Vite plugin port collision.
30
+ **Never** run more than one backend for a project: do not combine `lite dev`, `lite start`, or the Vite plugin against the same SQLite file.
30
31
 
31
32
  ## Patterns, limitations, anti-patterns
32
33
 
@@ -34,5 +35,6 @@ The skill deliberately does not duplicate these. They live in the installed pack
34
35
 
35
36
  - **What's limited / what to avoid** → `node_modules/@supabase/lite/LIMITATIONS.md`
36
37
  - **How to do common things** → `node_modules/@supabase/lite/PATTERNS.md`
38
+ - **Per-area product docs** → `node_modules/@supabase/lite/docs/` (index: `llms.txt`), or https://docs.lite.dev
37
39
 
38
40
  Re-read both when starting work on a supalite project, or when the user reports an unexpected behavior — they may already be documented.