@supacloud/lite 0.8.5 → 0.9.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.0](https://github.com/vibeunion/supacloud/compare/supacloud-lite-v0.8.5...supacloud-lite-v0.9.0) (2026-08-20)
4
+
5
+
6
+ ### Features
7
+
8
+ * complete Lite application primitives and PowerSync profile ([#1017](https://github.com/vibeunion/supacloud/issues/1017)) ([134444f](https://github.com/vibeunion/supacloud/commit/134444f98d310f65bf376be1ef7bb92445701b6b))
9
+
3
10
  ## [0.8.5](https://github.com/vibeunion/supacloud/compare/supacloud-lite-v0.8.4...supacloud-lite-v0.8.5) (2026-08-18)
4
11
 
5
12
 
package/README.md CHANGED
@@ -106,6 +106,7 @@ supacloud-lite snapshot create [-o backup.tar.gz]
106
106
  supacloud-lite snapshot restore <backup.tar.gz> [--force]
107
107
  supacloud-lite upgrade [-o pre-upgrade.tar.gz]
108
108
  supacloud-lite inspect
109
+ supacloud-lite doctor [--json]
109
110
  supacloud-lite version
110
111
  ```
111
112
 
@@ -136,6 +137,13 @@ supacloud-lite version
136
137
  - `SUPACLOUD_LITE_STORAGE_BACKEND`:`fs`(默认)、`memory` 或 `s3`
137
138
  - `SUPACLOUD_LITE_S3_PREFIX`:S3 对象 key 前缀,可被 `--s3-prefix` 覆盖
138
139
  - `SUPACLOUD_LITE_POSTGRES_MIRROR`:native 引擎下载 PostgreSQL 发布包时使用的 HTTPS 镜像前缀,例如 `https://ghproxy.net/`
140
+ - `SUPACLOUD_LITE_ENGINE`:`pglite`(默认)或 `native`
141
+ - `SUPACLOUD_LITE_REPLICATION_PROFILE`:仅支持显式值 `powersync`,且仅用于 native 引擎
142
+ - `SUPACLOUD_LITE_REPLICATION_HOST` / `SUPACLOUD_LITE_REPLICATION_PORT`:PowerSync 数据库监听地址和端口,默认 `127.0.0.1:54322`
143
+ - `SUPACLOUD_LITE_REPLICATION_ALLOW_CIDRS`:逗号分隔的 PowerSync 客户端 CIDR allowlist
144
+ - `SUPACLOUD_LITE_POWERSYNC_TABLES`:逗号分隔、带 schema 的 publication 表 allowlist
145
+ - `SUPACLOUD_LITE_POWERSYNC_PASSWORD`:独立 replication role 密码,至少 32 字符;不支持 CLI 密码参数
146
+ - `SUPACLOUD_LITE_REPLICATION_TLS_CERT_FILE` / `SUPACLOUD_LITE_REPLICATION_TLS_KEY_FILE`:非 loopback 监听必需
139
147
  - `SUPACLOUD_LITE_JWT_SECRET`
140
148
  - `SUPACLOUD_LITE_VAULT_KEY`
141
149
 
@@ -254,6 +262,9 @@ S3 模式的快照只包含数据库中的 Storage 元数据和密钥,不复
254
262
  | Edge Functions `SupaCloud.pgredis` | 已验证核心 | 提供单项目持久 KV、TTL、原子 `getset`/`getdel`;绑定只在当前函数请求内可用 |
255
263
  | Supabase migrations | 支持 | 按文件名排序,记录到 `supabase_migrations` |
256
264
  | PostgreSQL RLS | 支持 | 使用 `anon`、`authenticated`、`service_role` 数据库角色执行 |
265
+ | Maker-Checker SQL | 支持 | 参考 migration 在 PGlite/native 自动测试中覆盖角色分离、行版本、幂等、非法跃迁和只增审计 |
266
+ | Commands / Artifacts | 支持 | 与完整 SupaCloud 使用相同 SQL contract;PGlite/native 均通过 `@supacloud/js` 端到端测试 |
267
+ | Logical Replication / PowerSync source | 有条件支持 | PGlite 不支持;native 仅在显式 `powersync` profile 下支持,默认关闭 |
257
268
  | PostgREST 完整线协议 | 部分支持 | 目标是常用 `supabase-js` 行为,不承诺所有 PostgREST 边角行为 |
258
269
  | PostgreSQL 扩展 | 部分支持 | 仅支持 PGlite 内置或 Lite 模拟的扩展能力 |
259
270
  | Supabase Studio | 不支持 | V1 不提供管理 UI |
@@ -261,6 +272,50 @@ S3 模式的快照只包含数据库中的 Storage 元数据和密钥,不复
261
272
 
262
273
  RLS 表的 Realtime DELETE 无法在行删除后安全重放 SELECT policy,因此 V1 只向 `service_role` 订阅者发送这类 DELETE 事件。普通用户仍可收到通过逐行 RLS 校验的 INSERT/UPDATE 事件。
263
274
 
275
+ ### Capability doctor 与 PowerSync profile
276
+
277
+ `doctor` 输出 Lite 自己的稳定能力契约,不复制完整 Management API:
278
+
279
+ ```bash
280
+ supacloud-lite doctor --json
281
+ ```
282
+
283
+ 默认 PGlite 输出会明确包含:
284
+
285
+ ```json
286
+ {
287
+ "engine": "pglite",
288
+ "state_machine_sql": "supported",
289
+ "durable_workflows": "supported",
290
+ "commands": "supported",
291
+ "artifacts": "supported",
292
+ "postgrest_schema_config": "static",
293
+ "logical_replication": "unsupported",
294
+ "powersync_source": "unsupported"
295
+ }
296
+ ```
297
+
298
+ PGlite 永远不伪造 WAL、publication 或 replication slot。单机现场 ELN 可以直接把 Lite 当作本地服务器;多设备离线同步应使用中央 SupaCloud + PowerSync,或由应用 outbox 把本地 Lite 数据推送到中央 SupaCloud。PowerSync 客户端本地数据库是 SQLite,与 Lite/PGlite 不是同一层能力。
299
+
300
+ Native Lite 默认仍使用 `wal_level=minimal`、关闭 WAL sender 并且不监听数据库 TCP。只有显式启用 profile 才配置有界 Logical Replication:
301
+
302
+ ```bash
303
+ export SUPACLOUD_LITE_POWERSYNC_PASSWORD='<secret-store-value-at-least-32-characters>'
304
+ supacloud-lite migrate \
305
+ --engine native \
306
+ --replication-profile powersync \
307
+ --powersync-tables public.eln_entries,public.eln_observations
308
+
309
+ supacloud-lite doctor --json \
310
+ --engine native \
311
+ --replication-profile powersync \
312
+ --powersync-tables public.eln_entries,public.eln_observations
313
+ ```
314
+
315
+ 该 profile 使用独立 `supacloud_powersync` 登录角色、显式 `powersync` publication、`wal_level=logical`、4 个 sender、4 个 slot 和 `max_slot_wal_keep_size=1024MB`。默认只允许 loopback 上的 SCRAM 连接;非 loopback 监听必须同时提供 TLS 证书、权限受限的私钥和显式 CIDR allowlist。POSIX 平台要求私钥 mode 不向 group/other 开放;Windows 部署应通过文件 ACL 达到同等限制。
316
+
317
+ Lite 会创建或更新 replication role 与 publication allowlist,但**不会创建、删除或猜测 replication slot**。slot 由固定版本的 PowerSync 服务和运维流程持有。`doctor` 只读检查 WAL、sender/slot 容量、角色、publication、replica identity 和现有 slot 的滞留/失效状态。
318
+
264
319
  ### 从 Supabase 迁移
265
320
 
266
321
  应用代码、SQL migrations、RLS policy、Storage 调用和 Realtime 订阅可以保持原来的 Supabase 形状。迁移时仍需验证以下边界:
@@ -448,6 +503,7 @@ supacloud-lite snapshot create [-o backup.tar.gz]
448
503
  supacloud-lite snapshot restore <backup.tar.gz> [--force]
449
504
  supacloud-lite upgrade [-o pre-upgrade.tar.gz]
450
505
  supacloud-lite inspect
506
+ supacloud-lite doctor [--json]
451
507
  supacloud-lite version
452
508
  ```
453
509
 
@@ -478,6 +534,13 @@ Environment variables:
478
534
  - `SUPACLOUD_LITE_STORAGE_BACKEND`: `fs` (default), `memory`, or `s3`
479
535
  - `SUPACLOUD_LITE_S3_PREFIX`: S3 object key prefix, can be overridden by `--s3-prefix`
480
536
  - `SUPACLOUD_LITE_POSTGRES_MIRROR`: HTTPS prefix used to proxy native-engine PostgreSQL release downloads, for example `https://ghproxy.net/`
537
+ - `SUPACLOUD_LITE_ENGINE`: `pglite` (default) or `native`
538
+ - `SUPACLOUD_LITE_REPLICATION_PROFILE`: explicit `powersync` opt-in for the native engine only
539
+ - `SUPACLOUD_LITE_REPLICATION_HOST` / `SUPACLOUD_LITE_REPLICATION_PORT`: PowerSync database listener, default `127.0.0.1:54322`
540
+ - `SUPACLOUD_LITE_REPLICATION_ALLOW_CIDRS`: comma-separated PowerSync client CIDR allowlist
541
+ - `SUPACLOUD_LITE_POWERSYNC_TABLES`: comma-separated schema-qualified publication table allowlist
542
+ - `SUPACLOUD_LITE_POWERSYNC_PASSWORD`: dedicated replication-role password of at least 32 characters; no CLI password flag is provided
543
+ - `SUPACLOUD_LITE_REPLICATION_TLS_CERT_FILE` / `SUPACLOUD_LITE_REPLICATION_TLS_KEY_FILE`: required for non-loopback listeners
481
544
  - `SUPACLOUD_LITE_JWT_SECRET`
482
545
  - `SUPACLOUD_LITE_VAULT_KEY`
483
546
 
@@ -596,6 +659,9 @@ In-memory databases have no persistable data, so `snapshot` and `upgrade` reject
596
659
  | Edge Functions `SupaCloud.pgredis` | Verified core | Provides single-project persistent KV, TTL, and atomic `getset`/`getdel`; the binding is only available within the current function request |
597
660
  | Supabase migrations | Supported | Sorted by filename, recorded in `supabase_migrations` |
598
661
  | PostgreSQL RLS | Supported | Executed using the `anon`, `authenticated`, and `service_role` database roles |
662
+ | Maker-Checker SQL | Supported | The reference migration is tested on PGlite/native for role separation, row versions, idempotency, illegal transitions, and append-only audit |
663
+ | Commands / Artifacts | Supported | Uses the same SQL contract as full SupaCloud; PGlite/native are both exercised end-to-end through `@supacloud/js` |
664
+ | Logical Replication / PowerSync source | Conditional | PGlite is unsupported; native requires the explicit `powersync` profile and remains disabled by default |
599
665
  | Full PostgREST wire protocol | Partial | Targets common `supabase-js` behavior; does not promise all PostgREST edge-case behavior |
600
666
  | PostgreSQL extensions | Partial | Only supports extensions built into PGlite or emulated by Lite |
601
667
  | Supabase Studio | Not supported | V1 does not provide an admin UI |
@@ -603,6 +669,22 @@ In-memory databases have no persistable data, so `snapshot` and `upgrade` reject
603
669
 
604
670
  Realtime DELETE on RLS tables cannot safely replay SELECT policies after a row is deleted, so V1 only sends such DELETE events to `service_role` subscribers. Regular users can still receive INSERT/UPDATE events that pass row-by-row RLS validation.
605
671
 
672
+ ### Capability doctor and PowerSync profile
673
+
674
+ `supacloud-lite doctor --json` reports a stable Lite capability contract without copying the full Management API. PGlite explicitly reports Logical Replication and PowerSync source support as `unsupported`; it never emulates WAL, publications, or slots. Multi-device offline deployments should use central SupaCloud + PowerSync, while a single field workstation can use Lite as a local project server or upload through an application-owned outbox.
675
+
676
+ Native Lite keeps `wal_level=minimal`, WAL senders, and database TCP disabled by default. The explicit profile enables bounded Logical Replication:
677
+
678
+ ```bash
679
+ export SUPACLOUD_LITE_POWERSYNC_PASSWORD='<secret-store-value-at-least-32-characters>'
680
+ supacloud-lite migrate --engine native --replication-profile powersync \
681
+ --powersync-tables public.eln_entries,public.eln_observations
682
+ supacloud-lite doctor --json --engine native --replication-profile powersync \
683
+ --powersync-tables public.eln_entries,public.eln_observations
684
+ ```
685
+
686
+ The profile manages the dedicated `supacloud_powersync` login role and explicit `powersync` publication, with four WAL senders, four slots, and `max_slot_wal_keep_size=1024MB`. It uses loopback SCRAM by default; non-loopback listeners require TLS files and explicit CIDRs. POSIX systems reject group/other-readable private keys; Windows deployments must enforce the equivalent file ACL. Lite never creates or deletes a replication slot. PowerSync and the operator remain responsible for the exact slot lifecycle.
687
+
606
688
  ### Migrating from Supabase
607
689
 
608
690
  Application code, SQL migrations, RLS policies, Storage calls, and Realtime subscriptions can keep their original Supabase shape. When migrating, you still need to validate the following boundaries: