@supacloud/lite 0.5.5 → 0.5.7

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 (155) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +333 -15
  3. package/THIRD_PARTY_NOTICES.md +3 -4
  4. package/dist/cli.js +159 -66
  5. package/dist/index.d.ts +10 -10
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +157 -64
  8. package/dist/project-runtime.d.ts +6 -6
  9. package/dist/project-runtime.d.ts.map +1 -1
  10. package/dist/runtime/auth/handler.d.ts.map +1 -0
  11. package/dist/{vendor/tinbase → runtime}/auth/inbox.d.ts +1 -1
  12. package/dist/runtime/auth/inbox.d.ts.map +1 -0
  13. package/dist/runtime/auth/oauth.d.ts.map +1 -0
  14. package/dist/runtime/auth/password.d.ts.map +1 -0
  15. package/dist/runtime/auth/qr.d.ts.map +1 -0
  16. package/dist/{vendor/tinbase → runtime}/auth/rate-limit.d.ts +1 -1
  17. package/dist/runtime/auth/rate-limit.d.ts.map +1 -0
  18. package/dist/runtime/auth/redirect.d.ts.map +1 -0
  19. package/dist/runtime/auth/settings.d.ts.map +1 -0
  20. package/dist/runtime/auth/totp.d.ts.map +1 -0
  21. package/dist/runtime/cron/service.d.ts.map +1 -0
  22. package/dist/{vendor/tinbase → runtime}/db/bootstrap.d.ts +1 -1
  23. package/dist/runtime/db/bootstrap.d.ts.map +1 -0
  24. package/dist/runtime/db/data-dir-lock.d.ts.map +1 -0
  25. package/dist/{vendor/tinbase → runtime}/db/database.d.ts +1 -1
  26. package/dist/runtime/db/database.d.ts.map +1 -0
  27. package/dist/runtime/db/emulated.d.ts.map +1 -0
  28. package/dist/{vendor/tinbase → runtime}/db/engine.d.ts +2 -2
  29. package/dist/runtime/db/engine.d.ts.map +1 -0
  30. package/dist/{vendor/tinbase → runtime}/db/inspect.d.ts +1 -1
  31. package/dist/runtime/db/inspect.d.ts.map +1 -0
  32. package/dist/runtime/db/pglite-engine.d.ts.map +1 -0
  33. package/dist/runtime/db/schema-diff.d.ts.map +1 -0
  34. package/dist/{vendor/tinbase → runtime}/db/sql-compat.d.ts +2 -2
  35. package/dist/runtime/db/sql-compat.d.ts.map +1 -0
  36. package/dist/runtime/functions/deno-shim.d.ts.map +1 -0
  37. package/dist/runtime/functions/handler.d.ts.map +1 -0
  38. package/dist/runtime/functions/pgredis.d.ts.map +1 -0
  39. package/dist/runtime/gen-types.d.ts.map +1 -0
  40. package/dist/{vendor/tinbase → runtime}/index.d.ts +6 -6
  41. package/dist/runtime/index.d.ts.map +1 -0
  42. package/dist/runtime/jwt.d.ts.map +1 -0
  43. package/dist/runtime/log-buffer.d.ts.map +1 -0
  44. package/dist/runtime/net/service.d.ts.map +1 -0
  45. package/dist/runtime/node/bun-server.d.ts.map +1 -0
  46. package/dist/runtime/node/bundle-function.d.ts.map +1 -0
  47. package/dist/runtime/node/config-toml.d.ts.map +1 -0
  48. package/dist/runtime/node/fs-driver.d.ts.map +1 -0
  49. package/dist/{vendor/tinbase → runtime}/node/load-config.d.ts +4 -4
  50. package/dist/runtime/node/load-config.d.ts.map +1 -0
  51. package/dist/runtime/node/load-functions.d.ts.map +1 -0
  52. package/dist/runtime/node/project.d.ts.map +1 -0
  53. package/dist/runtime/node/server-shared.d.ts.map +1 -0
  54. package/dist/runtime/realtime/engine.d.ts.map +1 -0
  55. package/dist/runtime/rest/build.d.ts.map +1 -0
  56. package/dist/runtime/rest/errors.d.ts.map +1 -0
  57. package/dist/runtime/rest/handler.d.ts.map +1 -0
  58. package/dist/runtime/rest/parse.d.ts.map +1 -0
  59. package/dist/runtime/retention/service.d.ts.map +1 -0
  60. package/dist/runtime/security.d.ts.map +1 -0
  61. package/dist/runtime/storage/driver.d.ts.map +1 -0
  62. package/dist/runtime/storage/handler.d.ts.map +1 -0
  63. package/dist/runtime/storage/image-transform.d.ts.map +1 -0
  64. package/dist/runtime/storage/s3-driver.d.ts.map +1 -0
  65. package/dist/{vendor/tinbase → runtime}/types.d.ts +2 -2
  66. package/dist/runtime/types.d.ts.map +1 -0
  67. package/dist/{vendor/tinbase → runtime}/webhooks/service.d.ts +1 -1
  68. package/dist/runtime/webhooks/service.d.ts.map +1 -0
  69. package/package.json +3 -2
  70. package/dist/vendor/tinbase/auth/handler.d.ts.map +0 -1
  71. package/dist/vendor/tinbase/auth/inbox.d.ts.map +0 -1
  72. package/dist/vendor/tinbase/auth/oauth.d.ts.map +0 -1
  73. package/dist/vendor/tinbase/auth/password.d.ts.map +0 -1
  74. package/dist/vendor/tinbase/auth/qr.d.ts.map +0 -1
  75. package/dist/vendor/tinbase/auth/rate-limit.d.ts.map +0 -1
  76. package/dist/vendor/tinbase/auth/redirect.d.ts.map +0 -1
  77. package/dist/vendor/tinbase/auth/settings.d.ts.map +0 -1
  78. package/dist/vendor/tinbase/auth/totp.d.ts.map +0 -1
  79. package/dist/vendor/tinbase/cron/service.d.ts.map +0 -1
  80. package/dist/vendor/tinbase/db/bootstrap.d.ts.map +0 -1
  81. package/dist/vendor/tinbase/db/data-dir-lock.d.ts.map +0 -1
  82. package/dist/vendor/tinbase/db/database.d.ts.map +0 -1
  83. package/dist/vendor/tinbase/db/emulated.d.ts.map +0 -1
  84. package/dist/vendor/tinbase/db/engine.d.ts.map +0 -1
  85. package/dist/vendor/tinbase/db/inspect.d.ts.map +0 -1
  86. package/dist/vendor/tinbase/db/pglite-engine.d.ts.map +0 -1
  87. package/dist/vendor/tinbase/db/schema-diff.d.ts.map +0 -1
  88. package/dist/vendor/tinbase/db/sql-compat.d.ts.map +0 -1
  89. package/dist/vendor/tinbase/functions/deno-shim.d.ts.map +0 -1
  90. package/dist/vendor/tinbase/functions/handler.d.ts.map +0 -1
  91. package/dist/vendor/tinbase/functions/pgredis.d.ts.map +0 -1
  92. package/dist/vendor/tinbase/gen-types.d.ts.map +0 -1
  93. package/dist/vendor/tinbase/index.d.ts.map +0 -1
  94. package/dist/vendor/tinbase/jwt.d.ts.map +0 -1
  95. package/dist/vendor/tinbase/log-buffer.d.ts.map +0 -1
  96. package/dist/vendor/tinbase/net/service.d.ts.map +0 -1
  97. package/dist/vendor/tinbase/node/bun-server.d.ts.map +0 -1
  98. package/dist/vendor/tinbase/node/bundle-function.d.ts.map +0 -1
  99. package/dist/vendor/tinbase/node/config-toml.d.ts.map +0 -1
  100. package/dist/vendor/tinbase/node/fs-driver.d.ts.map +0 -1
  101. package/dist/vendor/tinbase/node/load-config.d.ts.map +0 -1
  102. package/dist/vendor/tinbase/node/load-functions.d.ts.map +0 -1
  103. package/dist/vendor/tinbase/node/project.d.ts.map +0 -1
  104. package/dist/vendor/tinbase/node/server-shared.d.ts.map +0 -1
  105. package/dist/vendor/tinbase/realtime/engine.d.ts.map +0 -1
  106. package/dist/vendor/tinbase/rest/build.d.ts.map +0 -1
  107. package/dist/vendor/tinbase/rest/errors.d.ts.map +0 -1
  108. package/dist/vendor/tinbase/rest/handler.d.ts.map +0 -1
  109. package/dist/vendor/tinbase/rest/parse.d.ts.map +0 -1
  110. package/dist/vendor/tinbase/retention/service.d.ts.map +0 -1
  111. package/dist/vendor/tinbase/security.d.ts.map +0 -1
  112. package/dist/vendor/tinbase/storage/driver.d.ts.map +0 -1
  113. package/dist/vendor/tinbase/storage/handler.d.ts.map +0 -1
  114. package/dist/vendor/tinbase/storage/image-transform.d.ts.map +0 -1
  115. package/dist/vendor/tinbase/storage/s3-driver.d.ts.map +0 -1
  116. package/dist/vendor/tinbase/types.d.ts.map +0 -1
  117. package/dist/vendor/tinbase/webhooks/service.d.ts.map +0 -1
  118. /package/LICENSES/{TINBASE-MIT.txt → UPSTREAM-PROTOCOL-MIT.txt} +0 -0
  119. /package/dist/{vendor/tinbase → runtime}/auth/handler.d.ts +0 -0
  120. /package/dist/{vendor/tinbase → runtime}/auth/oauth.d.ts +0 -0
  121. /package/dist/{vendor/tinbase → runtime}/auth/password.d.ts +0 -0
  122. /package/dist/{vendor/tinbase → runtime}/auth/qr.d.ts +0 -0
  123. /package/dist/{vendor/tinbase → runtime}/auth/redirect.d.ts +0 -0
  124. /package/dist/{vendor/tinbase → runtime}/auth/settings.d.ts +0 -0
  125. /package/dist/{vendor/tinbase → runtime}/auth/totp.d.ts +0 -0
  126. /package/dist/{vendor/tinbase → runtime}/cron/service.d.ts +0 -0
  127. /package/dist/{vendor/tinbase → runtime}/db/data-dir-lock.d.ts +0 -0
  128. /package/dist/{vendor/tinbase → runtime}/db/emulated.d.ts +0 -0
  129. /package/dist/{vendor/tinbase → runtime}/db/pglite-engine.d.ts +0 -0
  130. /package/dist/{vendor/tinbase → runtime}/db/schema-diff.d.ts +0 -0
  131. /package/dist/{vendor/tinbase → runtime}/functions/deno-shim.d.ts +0 -0
  132. /package/dist/{vendor/tinbase → runtime}/functions/handler.d.ts +0 -0
  133. /package/dist/{vendor/tinbase → runtime}/functions/pgredis.d.ts +0 -0
  134. /package/dist/{vendor/tinbase → runtime}/gen-types.d.ts +0 -0
  135. /package/dist/{vendor/tinbase → runtime}/jwt.d.ts +0 -0
  136. /package/dist/{vendor/tinbase → runtime}/log-buffer.d.ts +0 -0
  137. /package/dist/{vendor/tinbase → runtime}/net/service.d.ts +0 -0
  138. /package/dist/{vendor/tinbase → runtime}/node/bun-server.d.ts +0 -0
  139. /package/dist/{vendor/tinbase → runtime}/node/bundle-function.d.ts +0 -0
  140. /package/dist/{vendor/tinbase → runtime}/node/config-toml.d.ts +0 -0
  141. /package/dist/{vendor/tinbase → runtime}/node/fs-driver.d.ts +0 -0
  142. /package/dist/{vendor/tinbase → runtime}/node/load-functions.d.ts +0 -0
  143. /package/dist/{vendor/tinbase → runtime}/node/project.d.ts +0 -0
  144. /package/dist/{vendor/tinbase → runtime}/node/server-shared.d.ts +0 -0
  145. /package/dist/{vendor/tinbase → runtime}/realtime/engine.d.ts +0 -0
  146. /package/dist/{vendor/tinbase → runtime}/rest/build.d.ts +0 -0
  147. /package/dist/{vendor/tinbase → runtime}/rest/errors.d.ts +0 -0
  148. /package/dist/{vendor/tinbase → runtime}/rest/handler.d.ts +0 -0
  149. /package/dist/{vendor/tinbase → runtime}/rest/parse.d.ts +0 -0
  150. /package/dist/{vendor/tinbase → runtime}/retention/service.d.ts +0 -0
  151. /package/dist/{vendor/tinbase → runtime}/security.d.ts +0 -0
  152. /package/dist/{vendor/tinbase → runtime}/storage/driver.d.ts +0 -0
  153. /package/dist/{vendor/tinbase → runtime}/storage/handler.d.ts +0 -0
  154. /package/dist/{vendor/tinbase → runtime}/storage/image-transform.d.ts +0 -0
  155. /package/dist/{vendor/tinbase → runtime}/storage/s3-driver.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.7](https://github.com/zuohuadong/supacloud/compare/supacloud-lite-v0.5.6...supacloud-lite-v0.5.7) (2026-08-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **lite:** rename internal runtime identities ([a8183d6](https://github.com/zuohuadong/supacloud/commit/a8183d6c9dd9a726e416698f5039be86ef6a3b0c))
9
+
10
+ ## [0.5.6](https://github.com/zuohuadong/supacloud/compare/supacloud-lite-v0.5.5...supacloud-lite-v0.5.6) (2026-08-04)
11
+
12
+
13
+ ### Documentation
14
+
15
+ * **lite:** add bilingual Chinese/English README ([2b31e87](https://github.com/zuohuadong/supacloud/commit/2b31e8778389200b1077d77e7b1e9999db57d848))
16
+
3
17
  ## [0.5.5](https://github.com/zuohuadong/supacloud/compare/supacloud-lite-v0.5.4...supacloud-lite-v0.5.5) (2026-08-03)
4
18
 
5
19
 
package/README.md CHANGED
@@ -1,10 +1,16 @@
1
1
  # SupaCloud Lite
2
2
 
3
+ [中文](#中文) | [English](#english)
4
+
5
+ ---
6
+
7
+ ## 中文
8
+
3
9
  SupaCloud Lite 是一个面向单项目部署的 Bun 原生 Supabase 兼容后端。它使用 PGlite 在进程内运行 PostgreSQL,并实现 Supabase 客户端依赖的 REST、Auth、Storage、Realtime 和 Edge Functions 协议。
4
10
 
5
11
  V1 的目标不是复刻完整 Supabase 平台控制面,而是让现有应用在尽量少改代码的前提下,使用官方 `@supabase/supabase-js` 连接一个轻量、本地、无 Docker 的后端。
6
12
 
7
- ## 状态
13
+ ### 状态
8
14
 
9
15
  - 运行时:npm 包需要 Bun 1.3+;单二进制发行版已内嵌 Bun 和 PGlite 资源
10
16
  - 数据库:PGlite 0.5.4
@@ -14,7 +20,7 @@ V1 的目标不是复刻完整 Supabase 平台控制面,而是让现有应用
14
20
  - 对象存储:默认使用 `.supacloud-lite/storage`,也可切换为内存或远端 S3
15
21
  - 密钥文件:`.supacloud-lite/secrets.json`,权限为 `0600`
16
22
 
17
- ## 快速开始
23
+ ### 快速开始
18
24
 
19
25
  ```bash
20
26
  bun add @supacloud/lite
@@ -52,7 +58,7 @@ const supabase = createClient('http://127.0.0.1:54321', process.env.SUPACLOUD_LI
52
58
  const { data, error } = await supabase.from('todos').select('*')
53
59
  ```
54
60
 
55
- ## 项目约定
61
+ ### 项目约定
56
62
 
57
63
  SupaCloud Lite 直接读取现有 Supabase CLI 目录:
58
64
 
@@ -68,7 +74,7 @@ supabase/
68
74
 
69
75
  `config.toml` 当前支持 Auth、API schema/max rows、Storage bucket/size limit、seed 和 function entrypoint 等常用配置。
70
76
 
71
- ### Auth 运行方式
77
+ #### Auth 运行方式
72
78
 
73
79
  Lite 不下载、安装或启动独立的 GoTrue 进程。`/auth/v1/*` 由同一个 Bun 进程中的内置 Auth 实现处理,并与该 Lite 项目的 PGlite `auth` schema 共享生命周期;这避免了 sidecar 的配置、端口和会话一致性负担。
74
80
 
@@ -81,7 +87,7 @@ enabled = false
81
87
 
82
88
  关闭后 `/auth/v1/*` 返回 `404`,但不会把 Lite 变成完整 GoTrue 运行时,也不会自动移除已有的 `auth` schema 或 API key。需要完整 GoTrue 行为、多项目鉴权或独立鉴权进程时,应使用完整 SupaCloud 平台。
83
89
 
84
- ## CLI
90
+ ### CLI
85
91
 
86
92
  ```text
87
93
  supacloud-lite start
@@ -132,7 +138,7 @@ S3 模式下 `db reset` 会被拒绝,因为 Lite 不能把数据库元数据
132
138
 
133
139
  网络暴露时必须提供足够强的 JWT secret 和独立 vault key。默认生成的密钥适合单机项目;不要把 `.supacloud-lite/secrets.json` 提交到版本库。
134
140
 
135
- ## Windows 内嵌终端排障
141
+ ### Windows 内嵌终端排障
136
142
 
137
143
  Lite 需要 Bun 读取已安装的 `dist/cli.js`、项目配置和 PGlite WASM 文件。若在 TRAE 等 IDE 内嵌 PowerShell 中出现 `EPERM reading`,先在同一终端运行最小文件读取测试:
138
144
 
@@ -145,7 +151,7 @@ bun .\bun-read-test.js
145
151
 
146
152
  若最小测试成功而 Lite 仍失败,请保留完整错误、`bun --version`、终端类型和项目路径,再提交 Lite 问题。不要为绕过 `EPERM` 放宽项目目录的全局 ACL。
147
153
 
148
- ## 升级、快照与恢复
154
+ ### 升级、快照与恢复
149
155
 
150
156
  生产或持久化环境升级时,必须先停止当前 Lite 进程。npm 安装先更新项目锁定的依赖,再运行受控升级命令:
151
157
 
@@ -206,7 +212,7 @@ S3 模式的快照只包含数据库中的 Storage 元数据和密钥,不复
206
212
 
207
213
  内存数据库没有可持久化的数据,因此 `snapshot` 和 `upgrade` 会拒绝 `--memory`。
208
214
 
209
- ## 兼容范围
215
+ ### 兼容范围
210
216
 
211
217
  | 能力 | V1 状态 | 说明 |
212
218
  | --- | --- | --- |
@@ -226,7 +232,7 @@ S3 模式的快照只包含数据库中的 Storage 元数据和密钥,不复
226
232
 
227
233
  RLS 表的 Realtime DELETE 无法在行删除后安全重放 SELECT policy,因此 V1 只向 `service_role` 订阅者发送这类 DELETE 事件。普通用户仍可收到通过逐行 RLS 校验的 INSERT/UPDATE 事件。
228
234
 
229
- ## 从 Supabase 迁移
235
+ ### 从 Supabase 迁移
230
236
 
231
237
  应用代码、SQL migrations、RLS policy、Storage 调用和 Realtime 订阅可以保持原来的 Supabase 形状。迁移时仍需验证以下边界:
232
238
 
@@ -237,7 +243,7 @@ RLS 表的 Realtime DELETE 无法在行删除后安全重放 SELECT policy,因
237
243
 
238
244
  Lite 使用 Bun 原生 bcrypt,并兼容验证常见 GoTrue bcrypt 密码散列,因此经过映射的 `auth.users` 用户可保留密码。Auth 表结构、identity、refresh token 和 provider metadata 仍需通过受控迁移脚本转换;不要直接覆盖整个 `auth` schema。迁移后必须抽样验证登录,并为无法识别的散列准备密码重置流程。
239
245
 
240
- ## 队列与 Edge 缓存
246
+ ### 队列与 Edge 缓存
241
247
 
242
248
  Lite 在同一个 PGlite 数据库中提供 Supabase Queues 的公开 RPC façade。应用可以直接使用官方客户端的
243
249
  `supabase.schema('pgmq_public').rpc(...)`,无需额外的队列进程:
@@ -275,17 +281,17 @@ const value = await cache.get<{ rendered: boolean }>('welcome:user:42')
275
281
  缓存实现使用项目自己的 PGlite 表,支持 `get`、`set`、`delete`、`ttl`、原子 `getset` 和原子 `getdel`。默认边界与标准版一致:key 最长 512 个字符、JSON 值最大 1,048,576 bytes、TTL 最大 31,536,000,000ms。有 TTL 的值在读取时会惰性清理,Lite 的 retention sweeper 还会周期性删除过期行;文件数据库会跨重启保留缓存,`--memory` 数据库则随进程退出丢失。绑定按函数请求和项目隔离,函数返回后启动的 detached Promise 不能继续访问它;Lite 不提供跨项目共享、Redis 协议、队列或限流能力。
276
282
  Lite 的缓存调用是进程内数据库操作,不具备标准版跨进程 HTTP binding 的超时和请求中止传播;不要在同一 JavaScript 进程中混合加载 Lite 与标准 Edge Runtime,两者都拥有全局 `SupaCloud` binding,Lite 检测到已有其他实现时会拒绝启动。
277
283
 
278
- ## 多项目
284
+ ### 多项目
279
285
 
280
286
  V1 不在一个进程内复用多个 PGlite 项目。需要多个项目时,为每个项目配置独立的工作目录、端口和 `.supacloud-lite` 状态目录,并用进程管理器分别启动。这样可保持数据库、JWT、Storage 和 Realtime 的故障域隔离。
281
287
 
282
- ## 资源边界
288
+ ### 资源边界
283
289
 
284
290
  PGlite 是 WebAssembly PostgreSQL,不是 SQLite。它换来了 PostgreSQL SQL、角色、RLS 和 Supabase 迁移兼容性,但内存占用通常高于 PocketBase/SQLite。生产部署前应按真实 schema、并发和 Realtime 负载做容量测试。
285
291
 
286
292
  npm 包继续通过依赖目录加载 PGlite。GitHub Release 的平台单二进制则内嵌 Bun、PGlite JS、核心 WASM/data 和 Lite 使用的 contrib 扩展;启动时会把扩展压缩包释放到受限的临时目录,PGlite 初始化完成后立即清理。项目配置、Functions、数据库、对象存储和密钥仍保持外置。
287
293
 
288
- ## API
294
+ ### API
289
295
 
290
296
  ```ts
291
297
  import { createProjectBackend, startProjectServer } from '@supacloud/lite'
@@ -304,6 +310,318 @@ await running.close()
304
310
 
305
311
  也可以使用 `createLiteBackend()` 直接创建内存或自定义目录的嵌入式后端,并把它的 `fetch` 传给自定义宿主。
306
312
 
307
- ## 来源与许可
313
+ ### 来源与许可
314
+
315
+ 协议实现派生并精简自一个采用 MIT 许可的上游协议实现;PGlite 使用 Apache-2.0。完整说明见 `THIRD_PARTY_NOTICES.md` 和 `LICENSES/`。
316
+
317
+ ---
318
+
319
+ ## English
320
+
321
+ SupaCloud Lite is a Bun-native, Supabase-compatible backend designed for single-project deployments. It runs PostgreSQL in-process using PGlite and implements the REST, Auth, Storage, Realtime, and Edge Functions protocols that the Supabase client relies on.
322
+
323
+ The goal of V1 is not to replicate the full Supabase platform control plane, but to let existing applications connect to a lightweight, local, Docker-free backend using the official `@supabase/supabase-js` with minimal code changes.
324
+
325
+ ### Status
326
+
327
+ - Runtime: the npm package requires Bun 1.3+; the single-binary release embeds Bun and PGlite assets
328
+ - Database: PGlite 0.5.4
329
+ - Project model: single process, single project, with an internal project ref fixed as `local`
330
+ - Client: uses the official `@supabase/supabase-js` directly
331
+ - Data directory: `.supacloud-lite/db`
332
+ - Object storage: defaults to `.supacloud-lite/storage`, can also be switched to memory or remote S3
333
+ - Secrets file: `.supacloud-lite/secrets.json`, with permissions `0600`
334
+
335
+ ### Quick Start
336
+
337
+ ```bash
338
+ bun add @supacloud/lite
339
+ bunx supacloud-lite start
340
+ ```
341
+
342
+ You can also download the `supacloud-lite-*` single binary for your current platform from the GitHub Release. This file does not require Bun, Node, npm, or Docker to be pre-installed:
343
+
344
+ ```bash
345
+ chmod +x ./supacloud-lite-linux-x64
346
+ ./supacloud-lite-linux-x64 start --project-dir /path/to/project
347
+ ```
348
+
349
+ The single binary still reads the project's `supabase/` directory and writes `.supacloud-lite/` persistent state outside the project; it does not include a web console or Supabase Studio. Linux x64/arm64, macOS x64/arm64, and Windows x64 use separate artifacts and cannot be mixed across operating systems or CPU architectures.
350
+
351
+ Get the anon key:
352
+
353
+ ```bash
354
+ bunx supacloud-lite keys
355
+ ```
356
+
357
+ Print the `service_role` key only when the server side genuinely needs to bypass RLS:
358
+
359
+ ```bash
360
+ bunx supacloud-lite keys --service-role
361
+ ```
362
+
363
+ Client code does not need to switch to a proprietary SDK:
364
+
365
+ ```ts
366
+ import { createClient } from '@supabase/supabase-js'
367
+
368
+ const supabase = createClient('http://127.0.0.1:54321', process.env.SUPACLOUD_LITE_ANON_KEY!)
369
+
370
+ const { data, error } = await supabase.from('todos').select('*')
371
+ ```
372
+
373
+ ### Project Conventions
374
+
375
+ SupaCloud Lite reads the existing Supabase CLI directory directly:
376
+
377
+ ```text
378
+ supabase/
379
+ config.toml
380
+ migrations/*.sql
381
+ seed.sql
382
+ functions/<name>/index.ts
383
+ functions/.env
384
+ webhooks.json
385
+ ```
386
+
387
+ `config.toml` currently supports common configuration such as Auth, API schema/max rows, Storage bucket/size limit, seed, and function entrypoint.
388
+
389
+ #### How Auth Works
390
+
391
+ Lite does not download, install, or start a standalone GoTrue process. `/auth/v1/*` is handled by a built-in Auth implementation in the same Bun process, sharing its lifecycle with that Lite project's PGlite `auth` schema; this avoids the configuration, port, and session-consistency burden of a sidecar.
392
+
393
+ Auth is enabled by default. If your project does not need a client login interface, you can disable this route in `supabase/config.toml`:
394
+
395
+ ```toml
396
+ [auth]
397
+ enabled = false
398
+ ```
399
+
400
+ When disabled, `/auth/v1/*` returns `404`, but this does not turn Lite into a full GoTrue runtime, nor does it automatically remove the existing `auth` schema or API keys. When you need full GoTrue behavior, multi-project authentication, or a standalone authentication process, use the full SupaCloud platform.
401
+
402
+ ### CLI
403
+
404
+ ```text
405
+ supacloud-lite start
406
+ supacloud-lite migrate
407
+ supacloud-lite status
408
+ supacloud-lite keys [--service-role]
409
+ supacloud-lite gen types [-o database.types.ts]
410
+ supacloud-lite db reset
411
+ supacloud-lite db diff [-f migration_name]
412
+ supacloud-lite db pull [migration_name]
413
+ supacloud-lite snapshot create [-o backup.tar.gz]
414
+ supacloud-lite snapshot restore <backup.tar.gz> [--force]
415
+ supacloud-lite upgrade [-o pre-upgrade.tar.gz]
416
+ supacloud-lite inspect
417
+ supacloud-lite version
418
+ ```
419
+
420
+ Common flags:
421
+
422
+ - `--project-dir`: the project directory containing `supabase/`
423
+ - `--host` / `--port`: listen address and port
424
+ - `--api-url`: public API URL, used for Auth issuer, OAuth callback, email links, and Functions environment
425
+ - `--site-url`: frontend site URL, used as the default Auth redirect target
426
+ - `--state-dir`: Lite state root directory
427
+ - `--data-dir`: PGlite data directory
428
+ - `--storage-dir`: object storage directory
429
+ - `--storage-backend`: `fs`, `memory`, or `s3`
430
+ - `--s3-prefix`: remote S3 object key prefix
431
+ - `--memory`: use an in-memory database
432
+
433
+ Environment variables:
434
+
435
+ - `SUPACLOUD_LITE_HOST`
436
+ - `SUPACLOUD_LITE_PORT`
437
+ - `SUPACLOUD_LITE_API_URL`
438
+ - `SUPACLOUD_LITE_SITE_URL`
439
+ - `SUPACLOUD_LITE_STATE_DIR`
440
+ - `SUPACLOUD_LITE_DATA_DIR`
441
+ - `SUPACLOUD_LITE_STORAGE_DIR`
442
+ - `SUPACLOUD_LITE_STORAGE_BACKEND`: `fs` (default), `memory`, or `s3`
443
+ - `SUPACLOUD_LITE_S3_PREFIX`: S3 object key prefix, can be overridden by `--s3-prefix`
444
+ - `SUPACLOUD_LITE_JWT_SECRET`
445
+ - `SUPACLOUD_LITE_VAULT_KEY`
446
+
447
+ When using remote S3, set `SUPACLOUD_LITE_STORAGE_BACKEND=s3` before starting, and provide variables such as `S3_BUCKET`, `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY`, `S3_ENDPOINT`, and `S3_REGION` according to Bun S3 conventions; the corresponding `AWS_*` variables are also supported. The CLI does not accept secret parameters to avoid credentials appearing in the process list.
448
+
449
+ In S3 mode, `db reset` is rejected because Lite cannot make database metadata cleanup and remote object deletion an atomic operation; you must explicitly handle the remote bucket/prefix first, then switch back to local or memory storage to perform the reset.
450
+
451
+ When exposed to the network, you must provide a sufficiently strong JWT secret and an independent vault key. The default generated keys are suitable for single-machine projects; do not commit `.supacloud-lite/secrets.json` to version control.
452
+
453
+ ### Windows Embedded Terminal Troubleshooting
454
+
455
+ Lite requires Bun to read the installed `dist/cli.js`, project configuration, and PGlite WASM files. If you encounter `EPERM reading` in an IDE-embedded PowerShell such as TRAE, first run a minimal file read test in the same terminal:
456
+
457
+ ```powershell
458
+ Set-Content .\bun-read-test.js 'console.log("ok")'
459
+ bun .\bun-read-test.js
460
+ ```
461
+
462
+ If this command, which does not involve Lite, also returns `EPERM`, the failure occurs before Bun starts the application, and Lite cannot work around the host terminal's file access restrictions within application code. Switch to the system PowerShell or Windows Terminal; then upgrade to the current stable version of Bun, and check the IDE sandbox, terminal isolation, and security software policies. The fact that `node` can read the same file does not mean the Bun process has the same host permissions. After fixing the environment, run `npx supacloud-lite --help` to verify.
463
+
464
+ If the minimal test succeeds but Lite still fails, keep the full error, `bun --version`, terminal type, and project path, then submit a Lite issue. Do not loosen the global ACL of the project directory to work around `EPERM`.
465
+
466
+ ### Upgrade, Snapshot, and Restore
467
+
468
+ When upgrading a production or persistent environment, you must stop the current Lite process first. For npm installs, update the project's locked dependency first, then run the controlled upgrade command:
469
+
470
+ ```bash
471
+ # Specify the target version explicitly; do not implicitly use @latest in production startup commands
472
+ bun add @supacloud/lite@0.2.0
473
+
474
+ # Automatically create a pre-upgrade snapshot, then apply any pending supabase/migrations
475
+ bunx supacloud-lite upgrade
476
+ ```
477
+
478
+ For single-binary installs, download and verify the candidate file first, then have the candidate binary migrate the existing project:
479
+
480
+ ```bash
481
+ ./supacloud-lite-new version
482
+ ./supacloud-lite-new upgrade --project-dir /path/to/project
483
+ ./supacloud-lite-new start --project-dir /path/to/project
484
+ ```
485
+
486
+ Replacing the program file and migrating the database are two separate actions. `upgrade` does not go online, self-replace the binary, or modify `package.json`; it first writes a pre-upgrade snapshot to `.supacloud-lite/backups/pre-upgrade-<timestamp>.tar.gz` by default, and only after the snapshot succeeds does it apply the unrecorded migrations and seed. If the upgrade fails, the snapshot is retained and a restore command is printed. To roll back, stop the candidate process, restore state from the pre-upgrade snapshot, and restart the last verified version.
487
+
488
+ You can also create a portable snapshot separately:
489
+
490
+ ```bash
491
+ # Use the default filename and directory
492
+ bunx supacloud-lite snapshot create
493
+
494
+ # Specify the output location
495
+ bunx supacloud-lite snapshot create -o ./backups/project-a.tar.gz
496
+ ```
497
+
498
+ A snapshot is a gzip-compressed tar file containing:
499
+
500
+ - the PGlite data directory;
501
+ - object files in `fs` mode;
502
+ - `secrets.json`, to keep JWT, session, and Vault decryption compatible;
503
+ - a manifest of the snapshot format, Lite version, and Storage backend.
504
+
505
+ Snapshots contain sensitive secrets; the output file is set to `0600` on Unix systems. You should still encrypt, restrict access to, and set a retention period for it at the database backup level. Lite must be stopped before creating a snapshot. If a data directory lock is detected, the command refuses to proceed; a stale lock can only be deleted manually after confirming the process has exited.
506
+
507
+ Restore to a new project or an empty state directory:
508
+
509
+ ```bash
510
+ bunx supacloud-lite snapshot restore ./backups/project-a.tar.gz
511
+ ```
512
+
513
+ When the target state directory is non-empty, overwriting is rejected by default. To explicitly replace the existing state, use:
514
+
515
+ ```bash
516
+ bunx supacloud-lite snapshot restore ./backups/project-a.tar.gz --force
517
+ ```
518
+
519
+ `--force` does not directly delete old data; instead, it renames the old state directory to a rollback copy in the form `.supacloud-lite.restore-<id>` and prints the full path in the output. Operators should clean up that directory only after verifying the new state.
520
+
521
+ When using custom `--state-dir`, `--data-dir`, or `--storage-dir`, the same arguments must be passed for both create and restore. The database and Storage directories must not overlap, nor can they point to the filesystem root or symbolic links.
522
+
523
+ Snapshots in S3 mode only contain the Storage metadata and secrets in the database; they do not copy remote objects, nor do they read or save S3 credentials. When restoring, you must pass `--storage-backend s3` and re-provide the environment variables for the original bucket/prefix; cross-bucket migration still requires the object storage's own replication tool.
524
+
525
+ In-memory databases have no persistable data, so `snapshot` and `upgrade` reject `--memory`.
526
+
527
+ ### Compatibility Scope
528
+
529
+ | Capability | V1 Status | Notes |
530
+ | --- | --- | --- |
531
+ | `supabase.from()` | Verified core | Automated tests cover CRUD, filtering, and RLS; nested relations, RPC, and advanced PostgREST syntax are experimentally compatible |
532
+ | `supabase.auth` | Verified core | Provided by the built-in Auth implementation rather than a standalone GoTrue process; automated tests cover email/password, sessions, and bcrypt; OTP/Magic Link, anonymous users, OAuth, and MFA are experimentally compatible |
533
+ | `supabase.storage` | Verified core | Covers upload/download, list, delete, TUS/RLS, remote S3 driver, and a subset of Bun.Image `contain`/`fill`, format, and quality transforms; `cover` is explicitly unsupported |
534
+ | `supabase.channel()` | Verified core | Automated tests cover `postgres_changes`, DELETE RLS isolation, and event snapshot validation; Broadcast and Presence are experimentally compatible |
535
+ | `supabase.functions.invoke()` | Verified core | Automated tests cover Bun.build, `Deno.serve()`, public functions, and in-process restart |
536
+ | Supabase Queues / PGMQ | Verified core | Provides `send`, `send_batch`, `read`, `pop`, `archive`, and `delete` RPCs for `pgmq_public`; queue data is persisted in the same PGlite project |
537
+ | 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 |
538
+ | Supabase migrations | Supported | Sorted by filename, recorded in `supabase_migrations` |
539
+ | PostgreSQL RLS | Supported | Executed using the `anon`, `authenticated`, and `service_role` database roles |
540
+ | Full PostgREST wire protocol | Partial | Targets common `supabase-js` behavior; does not promise all PostgREST edge-case behavior |
541
+ | PostgreSQL extensions | Partial | Only supports extensions built into PGlite or emulated by Lite |
542
+ | Supabase Studio | Not supported | V1 does not provide an admin UI |
543
+ | Multi-project control plane | Not supported | V1 runs only one project per process; multiple projects can be deployed via multiple processes |
544
+
545
+ 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.
546
+
547
+ ### Migrating from Supabase
548
+
549
+ 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:
550
+
551
+ 1. Bring the existing `supabase/migrations`, `config.toml`, Functions, and seed files into the Lite project.
552
+ 2. Use `supacloud-lite db reset` to replay the schema on an empty database, then import business data.
553
+ 3. Provide alternatives for SQL/API that use extensions not offered by PGlite or advanced PostgREST syntax.
554
+ 4. Verify key queries, RLS, Storage, and Realtime through real `@supabase/supabase-js` integration tests.
555
+
556
+ Lite uses Bun's native bcrypt and is compatible with validating common GoTrue bcrypt password hashes, so mapped `auth.users` users can keep their passwords. Auth table structure, identity, refresh tokens, and provider metadata still need to be converted via a controlled migration script; do not directly overwrite the entire `auth` schema. After migration, you must sample-verify logins and prepare a password reset flow for unrecognized hashes.
557
+
558
+ ### Queues and Edge Cache
559
+
560
+ Lite provides a public RPC façade for Supabase Queues within the same PGlite database. Applications can directly use the official client's
561
+ `supabase.schema('pgmq_public').rpc(...)` without an additional queue process:
562
+
563
+ ```sql
564
+ -- Queue creation is an administrative operation and should be placed in a project migration, not in the anonymous request path.
565
+ select pgmq.create('emails');
566
+ ```
567
+
568
+ ```ts
569
+ const queues = supabase.schema('pgmq_public')
570
+ const { data: ids } = await queues.rpc('send_batch', {
571
+ queue_name: 'emails',
572
+ messages: [{ to: 'user@example.com' }],
573
+ sleep_seconds: 0,
574
+ })
575
+ const { data: messages } = await queues.rpc('read', {
576
+ queue_name: 'emails',
577
+ sleep_seconds: 60,
578
+ n: 10,
579
+ })
580
+ ```
581
+
582
+ Lite's `pgmq` emulation layer also provides `set_vt`, allowing direct SQL adjustment of visibility timeouts. Messages are delivered at least once according to PGMQ semantics; `pop` deletes the message immediately, and `archive` is the acknowledgment path. Queue creation, metrics, purge, settings, and management APIs are not part of Lite's public RPC façade and must still be handled by project SQL or the full SupaCloud control plane.
583
+ Queue names follow the standard 1-128 character lowercase letter, digit, underscore, and hyphen rule, and must start with a letter or digit; Lite safely maps names that exceed PostgreSQL's 63-byte identifier limit to avoid cross-queue collisions after truncation. The default Data API exposes `public` and `pgmq_public`; if `dbSchemas` is set explicitly, Lite uses that list strictly, and `pgmq_public` should be explicitly included when queue RPCs are needed.
584
+
585
+ Within an Edge Function, you can use `globalThis.SupaCloud.pgredis`:
586
+
587
+ ```ts
588
+ const cache = globalThis.SupaCloud.pgredis
589
+ await cache.set('welcome:user:42', { rendered: true }, 60_000)
590
+ const value = await cache.get<{ rendered: boolean }>('welcome:user:42')
591
+ ```
592
+
593
+ The cache implementation uses the project's own PGlite tables and supports `get`, `set`, `delete`, `ttl`, atomic `getset`, and atomic `getdel`. The default boundaries are consistent with the standard version: keys up to 512 characters, JSON values up to 1,048,576 bytes, and TTLs up to 31,536,000,000ms. Values with a TTL are lazily cleaned up on read, and Lite's retention sweeper periodically deletes expired rows; the file database retains the cache across restarts, while the `--memory` database loses it when the process exits. The binding is isolated by function request and by project; detached Promises started after the function returns cannot continue to access it; Lite does not provide cross-project sharing, a Redis protocol, queues, or rate-limiting capabilities.
594
+ Lite's cache calls are in-process database operations and do not have the timeout and request-abort propagation of the standard version's cross-process HTTP binding; do not mix loading Lite and the standard Edge Runtime in the same JavaScript process, as both own the global `SupaCloud` binding, and Lite will refuse to start if it detects that another implementation is already present.
595
+
596
+ ### Multiple Projects
597
+
598
+ V1 does not multiplex multiple PGlite projects within a single process. When multiple projects are needed, configure an independent working directory, port, and `.supacloud-lite` state directory for each project, and start them separately with a process manager. This keeps the database, JWT, Storage, and Realtime failure domains isolated.
599
+
600
+ ### Resource Boundaries
601
+
602
+ PGlite is WebAssembly PostgreSQL, not SQLite. It trades off for PostgreSQL SQL, roles, RLS, and Supabase migration compatibility, but its memory footprint is typically higher than PocketBase/SQLite. Before production deployment, you should perform capacity testing against the real schema, concurrency, and Realtime load.
603
+
604
+ The npm package continues to load PGlite through the dependency directory. The platform single binary from the GitHub Release embeds Bun, PGlite JS, core WASM/data, and the contrib extensions used by Lite; on startup, it extracts the extension archives to a restricted temporary directory and cleans them up immediately after PGlite initialization. Project configuration, Functions, database, object storage, and secrets remain external.
605
+
606
+ ### API
607
+
608
+ ```ts
609
+ import { createProjectBackend, startProjectServer } from '@supacloud/lite'
610
+
611
+ const running = await startProjectServer({
612
+ projectDir: process.cwd(),
613
+ host: '127.0.0.1',
614
+ port: 54321,
615
+ storageBackend: 's3',
616
+ })
617
+
618
+ await running.close()
619
+ ```
620
+
621
+ Image transforms currently provide a compatible subset of Bun.Image: `width`, `height`, `resize=fill|contain`, as well as `format=origin|jpeg|png|webp` and JPEG/WebP `quality`. `resize=cover` requires cropping capability, which the current Bun runtime does not have a corresponding API for, so it explicitly returns an unsupported error instead of incorrectly stretching the image to `cover`.
622
+
623
+ You can also use `createLiteBackend()` to directly create an embedded backend with an in-memory or custom directory, and pass its `fetch` to a custom host.
624
+
625
+ ### Provenance and License
308
626
 
309
- 协议实现派生并精简自 Tinbase,保留其 MIT 许可;PGlite 使用 Apache-2.0。完整说明见 `THIRD_PARTY_NOTICES.md` `LICENSES/`。
627
+ The protocol implementation is derived and slimmed down from an MIT-licensed upstream protocol implementation; PGlite uses Apache-2.0. See `THIRD_PARTY_NOTICES.md` and `LICENSES/` for full details.
@@ -1,13 +1,12 @@
1
1
  # Third-Party Notices
2
2
 
3
- ## Tinbase
3
+ ## Upstream protocol implementation
4
4
 
5
- SupaCloud Lite 的 Supabase 兼容协议实现包含从 Tinbase 0.10.0 派生并修改的源代码。
5
+ SupaCloud Lite 的 Supabase 兼容协议实现包含从一个 MIT 许可的上游协议实现派生并修改的源代码。
6
6
 
7
7
  - Copyright: 2026 Sanket Sahu
8
8
  - License: MIT
9
- - Upstream: `https://github.com/sanketmysore/tinbase`
10
- - Local license copy: `LICENSES/TINBASE-MIT.txt`
9
+ - Local license copy: `LICENSES/UPSTREAM-PROTOCOL-MIT.txt`
11
10
 
12
11
  主要修改包括:删除 Admin UI、Node HTTP server、native PostgreSQL 和 pg-mem 路径;固定为单项目 PGlite;改用 Bun.serve 和 Bun.build;增加 SupaCloud Lite 密钥、CLI、测试、文档和发布集成。
13
12