@supacloud/lite 0.2.0 → 0.5.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSES/BUN-1.3.14-RUNTIME-NOTICES.txt +78 -0
  3. package/LICENSES/CHOWNR-BLUEOAK-1.0.0.txt +63 -0
  4. package/LICENSES/FS-MINIPASS-ISC.txt +15 -0
  5. package/LICENSES/MINIPASS-BLUEOAK-1.0.0.txt +55 -0
  6. package/LICENSES/MINIZLIB-MIT.txt +26 -0
  7. package/LICENSES/NODE-TAR-BLUEOAK-1.0.0.txt +55 -0
  8. package/LICENSES/YALLIST-BLUEOAK-1.0.0.txt +63 -0
  9. package/README.md +142 -3
  10. package/RELEASING.md +14 -1
  11. package/THIRD_PARTY_NOTICES.md +44 -0
  12. package/dist/cli.js +965 -104
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +867 -80
  16. package/dist/launcher.cjs +22 -0
  17. package/dist/snapshot.d.ts +41 -0
  18. package/dist/snapshot.d.ts.map +1 -0
  19. package/dist/standalone-assets-protocol.d.ts +13 -0
  20. package/dist/standalone-assets-protocol.d.ts.map +1 -0
  21. package/dist/vendor/tinbase/auth/handler.d.ts +4 -0
  22. package/dist/vendor/tinbase/auth/handler.d.ts.map +1 -1
  23. package/dist/vendor/tinbase/db/database.d.ts +5 -1
  24. package/dist/vendor/tinbase/db/database.d.ts.map +1 -1
  25. package/dist/vendor/tinbase/db/emulated.d.ts +1 -1
  26. package/dist/vendor/tinbase/db/emulated.d.ts.map +1 -1
  27. package/dist/vendor/tinbase/db/pglite-engine.d.ts.map +1 -1
  28. package/dist/vendor/tinbase/functions/handler.d.ts +3 -1
  29. package/dist/vendor/tinbase/functions/handler.d.ts.map +1 -1
  30. package/dist/vendor/tinbase/functions/pgredis.d.ts +26 -0
  31. package/dist/vendor/tinbase/functions/pgredis.d.ts.map +1 -0
  32. package/dist/vendor/tinbase/index.d.ts +1 -0
  33. package/dist/vendor/tinbase/index.d.ts.map +1 -1
  34. package/dist/vendor/tinbase/retention/service.d.ts.map +1 -1
  35. package/package.json +14 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.0](https://github.com/zuohuadong/supacloud/compare/supacloud-lite-v0.4.0...supacloud-lite-v0.5.0) (2026-07-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * **lite:** build standalone single-file binaries with embedded PGlite assets ([#644](https://github.com/zuohuadong/supacloud/issues/644)) ([50da574](https://github.com/zuohuadong/supacloud/commit/50da574a4643fba9d5027464b501e18afe79926b))
9
+
10
+ ## [0.4.0](https://github.com/zuohuadong/supacloud/compare/supacloud-lite-v0.3.0...supacloud-lite-v0.4.0) (2026-07-29)
11
+
12
+
13
+ ### Features
14
+
15
+ * **lite:** align auth queue and cache compatibility ([f6efcd3](https://github.com/zuohuadong/supacloud/commit/f6efcd3168392f96b36ad4a9b89fafd379f523a4))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * resolve remaining reported runtime and console issues ([5fda9f0](https://github.com/zuohuadong/supacloud/commit/5fda9f0960fe7c1a03765f69cc59ebe847016a2c))
21
+ * resolve reported console and Lite issues ([781fba4](https://github.com/zuohuadong/supacloud/commit/781fba47412ed44272dc355d484c9d2c283151c9))
22
+
23
+ ## [0.3.0](https://github.com/zuohuadong/supacloud/compare/supacloud-lite-v0.2.0...supacloud-lite-v0.3.0) (2026-07-28)
24
+
25
+
26
+ ### Features
27
+
28
+ * extend Supabase-compatible platform capabilities ([adef019](https://github.com/zuohuadong/supacloud/commit/adef019261f82f123043ab4c7a047e6ad6956e56))
29
+ * harden Supabase Cloud compatibility ([ab64374](https://github.com/zuohuadong/supacloud/commit/ab643743b058ad08a0d32c124d26bed0863db397))
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * use installed TypeScript in Lite smoke ([8a64050](https://github.com/zuohuadong/supacloud/commit/8a64050833c47778e931067f8f30e541141256bf))
35
+
36
+
37
+ ### Documentation
38
+
39
+ * **lite:** document snapshot archive dependency ([1c0a8cc](https://github.com/zuohuadong/supacloud/commit/1c0a8cccc4e6cbb0804c7badf6573d6d986c2528))
40
+
3
41
  ## [0.2.0](https://github.com/zuohuadong/supacloud/compare/supacloud-lite-v0.1.0...supacloud-lite-v0.2.0) (2026-07-28)
4
42
 
5
43
 
@@ -0,0 +1,78 @@
1
+ ---
2
+ title: License
3
+ description: License for Bun
4
+ ---
5
+
6
+ Bun itself is MIT-licensed.
7
+
8
+ ## JavaScriptCore
9
+
10
+ Bun statically links JavaScriptCore (and WebKit) which is LGPL-2 licensed. WebCore files from WebKit are also licensed under LGPL2. Per LGPL2:
11
+
12
+ > (1) If you statically link against an LGPL'd library, you must also provide your application in an object (not necessarily source) format, so that a user has the opportunity to modify the library and relink the application.
13
+
14
+ You can find the patched version of WebKit used by Bun here: https://github.com/oven-sh/webkit. If you would like to relink Bun with changes:
15
+
16
+ - `git submodule update --init --recursive`
17
+ - `make jsc`
18
+ - `zig build`
19
+
20
+ This compiles JavaScriptCore, compiles Bun's `.cpp` bindings for JavaScriptCore (which are the object files using JavaScriptCore) and outputs a new `bun` binary with your changes.
21
+
22
+ ## Linked libraries
23
+
24
+ Bun statically links these libraries:
25
+
26
+ | Library | License |
27
+ | ------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
28
+ | [`boringssl`](https://boringssl.googlesource.com/boringssl/) | [several licenses](https://boringssl.googlesource.com/boringssl/+/refs/heads/master/LICENSE) |
29
+ | [`brotli`](https://github.com/google/brotli) | MIT |
30
+ | [`libarchive`](https://github.com/libarchive/libarchive) | [several licenses](https://github.com/libarchive/libarchive/blob/master/COPYING) |
31
+ | [`lol-html`](https://github.com/cloudflare/lol-html/tree/master/c-api) | BSD 3-Clause |
32
+ | [`mimalloc`](https://github.com/microsoft/mimalloc) | MIT |
33
+ | [`picohttp`](https://github.com/h2o/picohttpparser) | dual-licensed under the Perl License or the MIT License |
34
+ | [`zstd`](https://github.com/facebook/zstd) | dual-licensed under the BSD License or GPLv2 license |
35
+ | [`simdutf`](https://github.com/simdutf/simdutf) | Apache 2.0 |
36
+ | [`tinycc`](https://github.com/tinycc/tinycc) | LGPL v2.1 |
37
+ | [`uSockets`](https://github.com/uNetworking/uSockets) | Apache 2.0 |
38
+ | [`zlib-ng`](https://github.com/zlib-ng/zlib-ng) | zlib |
39
+ | [`c-ares`](https://github.com/c-ares/c-ares) | MIT licensed |
40
+ | [`libicu`](https://github.com/unicode-org/icu) 72 | [license here](https://github.com/unicode-org/icu/blob/main/icu4c/LICENSE) |
41
+ | [`libbase64`](https://github.com/aklomp/base64/blob/master/LICENSE) | BSD 2-Clause |
42
+ | [`libuv`](https://github.com/libuv/libuv) (on Windows) | MIT |
43
+ | [`libdeflate`](https://github.com/ebiggers/libdeflate) | MIT |
44
+ | A fork of [`uWebsockets`](https://github.com/jarred-sumner/uwebsockets) | Apache 2.0 licensed |
45
+ | Parts of [Tigerbeetle's IO code](https://github.com/tigerbeetle/tigerbeetle/blob/532c8b70b9142c17e07737ab6d3da68d7500cbca/src/io/windows.zig#L1) | Apache 2.0 licensed |
46
+
47
+ ## Polyfills
48
+
49
+ For compatibility reasons, the following packages are embedded into Bun's binary and injected if imported.
50
+
51
+ | Package | License |
52
+ | ------------------------------------------------------------------------ | ------- |
53
+ | [`assert`](https://npmjs.com/package/assert) | MIT |
54
+ | [`browserify-zlib`](https://npmjs.com/package/browserify-zlib) | MIT |
55
+ | [`buffer`](https://npmjs.com/package/buffer) | MIT |
56
+ | [`constants-browserify`](https://npmjs.com/package/constants-browserify) | MIT |
57
+ | [`crypto-browserify`](https://npmjs.com/package/crypto-browserify) | MIT |
58
+ | [`domain-browser`](https://npmjs.com/package/domain-browser) | MIT |
59
+ | [`events`](https://npmjs.com/package/events) | MIT |
60
+ | [`https-browserify`](https://npmjs.com/package/https-browserify) | MIT |
61
+ | [`os-browserify`](https://npmjs.com/package/os-browserify) | MIT |
62
+ | [`path-browserify`](https://npmjs.com/package/path-browserify) | MIT |
63
+ | [`process`](https://npmjs.com/package/process) | MIT |
64
+ | [`punycode`](https://npmjs.com/package/punycode) | MIT |
65
+ | [`querystring-es3`](https://npmjs.com/package/querystring-es3) | MIT |
66
+ | [`stream-browserify`](https://npmjs.com/package/stream-browserify) | MIT |
67
+ | [`stream-http`](https://npmjs.com/package/stream-http) | MIT |
68
+ | [`string_decoder`](https://npmjs.com/package/string_decoder) | MIT |
69
+ | [`timers-browserify`](https://npmjs.com/package/timers-browserify) | MIT |
70
+ | [`tty-browserify`](https://npmjs.com/package/tty-browserify) | MIT |
71
+ | [`url`](https://npmjs.com/package/url) | MIT |
72
+ | [`util`](https://npmjs.com/package/util) | MIT |
73
+ | [`vm-browserify`](https://npmjs.com/package/vm-browserify) | MIT |
74
+
75
+ ## Additional credits
76
+
77
+ - Bun's JS transpiler, CSS lexer, and Node.js module resolver source code is a Zig port of [@evanw](https://github.com/evanw)’s [esbuild](https://github.com/evanw/esbuild) project.
78
+ - Credit to [@kipply](https://github.com/kipply) for the name "Bun"!
@@ -0,0 +1,63 @@
1
+ All packages under `src/` are licensed according to the terms in
2
+ their respective `LICENSE` or `LICENSE.md` files.
3
+
4
+ The remainder of this project is licensed under the Blue Oak
5
+ Model License, as follows:
6
+
7
+ -----
8
+
9
+ # Blue Oak Model License
10
+
11
+ Version 1.0.0
12
+
13
+ ## Purpose
14
+
15
+ This license gives everyone as much permission to work with
16
+ this software as possible, while protecting contributors
17
+ from liability.
18
+
19
+ ## Acceptance
20
+
21
+ In order to receive this license, you must agree to its
22
+ rules. The rules of this license are both obligations
23
+ under that agreement and conditions to your license.
24
+ You must not do anything with this software that triggers
25
+ a rule that you cannot or will not follow.
26
+
27
+ ## Copyright
28
+
29
+ Each contributor licenses you to do everything with this
30
+ software that would otherwise infringe that contributor's
31
+ copyright in it.
32
+
33
+ ## Notices
34
+
35
+ You must ensure that everyone who gets a copy of
36
+ any part of this software from you, with or without
37
+ changes, also gets the text of this license or a link to
38
+ <https://blueoakcouncil.org/license/1.0.0>.
39
+
40
+ ## Excuse
41
+
42
+ If anyone notifies you in writing that you have not
43
+ complied with [Notices](#notices), you can keep your
44
+ license by taking all practical steps to comply within 30
45
+ days after the notice. If you do not do so, your license
46
+ ends immediately.
47
+
48
+ ## Patent
49
+
50
+ Each contributor licenses you to do everything with this
51
+ software that would otherwise infringe any patent claims
52
+ they can license or become able to license.
53
+
54
+ ## Reliability
55
+
56
+ No contributor can revoke this license.
57
+
58
+ ## No Liability
59
+
60
+ ***As far as the law allows, this software comes as is,
61
+ without any warranty or condition, and no contributor
62
+ will be liable to anyone for any damages related to this
63
+ software or this license, under any kind of legal claim.***
@@ -0,0 +1,15 @@
1
+ The ISC License
2
+
3
+ Copyright (c) Isaac Z. Schlueter and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15
+ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # Blue Oak Model License
2
+
3
+ Version 1.0.0
4
+
5
+ ## Purpose
6
+
7
+ This license gives everyone as much permission to work with
8
+ this software as possible, while protecting contributors
9
+ from liability.
10
+
11
+ ## Acceptance
12
+
13
+ In order to receive this license, you must agree to its
14
+ rules. The rules of this license are both obligations
15
+ under that agreement and conditions to your license.
16
+ You must not do anything with this software that triggers
17
+ a rule that you cannot or will not follow.
18
+
19
+ ## Copyright
20
+
21
+ Each contributor licenses you to do everything with this
22
+ software that would otherwise infringe that contributor's
23
+ copyright in it.
24
+
25
+ ## Notices
26
+
27
+ You must ensure that everyone who gets a copy of
28
+ any part of this software from you, with or without
29
+ changes, also gets the text of this license or a link to
30
+ <https://blueoakcouncil.org/license/1.0.0>.
31
+
32
+ ## Excuse
33
+
34
+ If anyone notifies you in writing that you have not
35
+ complied with [Notices](#notices), you can keep your
36
+ license by taking all practical steps to comply within 30
37
+ days after the notice. If you do not do so, your license
38
+ ends immediately.
39
+
40
+ ## Patent
41
+
42
+ Each contributor licenses you to do everything with this
43
+ software that would otherwise infringe any patent claims
44
+ they can license or become able to license.
45
+
46
+ ## Reliability
47
+
48
+ No contributor can revoke this license.
49
+
50
+ ## No Liability
51
+
52
+ ***As far as the law allows, this software comes as is,
53
+ without any warranty or condition, and no contributor
54
+ will be liable to anyone for any damages related to this
55
+ software or this license, under any kind of legal claim.***
@@ -0,0 +1,26 @@
1
+ Minizlib was created by Isaac Z. Schlueter.
2
+ It is a derivative work of the Node.js project.
3
+
4
+ """
5
+ Copyright (c) 2017-2023 Isaac Z. Schlueter and Contributors
6
+ Copyright (c) 2017-2023 Node.js contributors. All rights reserved.
7
+ Copyright (c) 2017-2023 Joyent, Inc. and other Node contributors. All rights reserved.
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a
10
+ copy of this software and associated documentation files (the "Software"),
11
+ to deal in the Software without restriction, including without limitation
12
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
13
+ and/or sell copies of the Software, and to permit persons to whom the
14
+ Software is furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in
17
+ all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ """
@@ -0,0 +1,55 @@
1
+ # Blue Oak Model License
2
+
3
+ Version 1.0.0
4
+
5
+ ## Purpose
6
+
7
+ This license gives everyone as much permission to work with
8
+ this software as possible, while protecting contributors
9
+ from liability.
10
+
11
+ ## Acceptance
12
+
13
+ In order to receive this license, you must agree to its
14
+ rules. The rules of this license are both obligations
15
+ under that agreement and conditions to your license.
16
+ You must not do anything with this software that triggers
17
+ a rule that you cannot or will not follow.
18
+
19
+ ## Copyright
20
+
21
+ Each contributor licenses you to do everything with this
22
+ software that would otherwise infringe that contributor's
23
+ copyright in it.
24
+
25
+ ## Notices
26
+
27
+ You must ensure that everyone who gets a copy of
28
+ any part of this software from you, with or without
29
+ changes, also gets the text of this license or a link to
30
+ <https://blueoakcouncil.org/license/1.0.0>.
31
+
32
+ ## Excuse
33
+
34
+ If anyone notifies you in writing that you have not
35
+ complied with [Notices](#notices), you can keep your
36
+ license by taking all practical steps to comply within 30
37
+ days after the notice. If you do not do so, your license
38
+ ends immediately.
39
+
40
+ ## Patent
41
+
42
+ Each contributor licenses you to do everything with this
43
+ software that would otherwise infringe any patent claims
44
+ they can license or become able to license.
45
+
46
+ ## Reliability
47
+
48
+ No contributor can revoke this license.
49
+
50
+ ## No Liability
51
+
52
+ ***As far as the law allows, this software comes as is,
53
+ without any warranty or condition, and no contributor
54
+ will be liable to anyone for any damages related to this
55
+ software or this license, under any kind of legal claim.***
@@ -0,0 +1,63 @@
1
+ All packages under `src/` are licensed according to the terms in
2
+ their respective `LICENSE` or `LICENSE.md` files.
3
+
4
+ The remainder of this project is licensed under the Blue Oak
5
+ Model License, as follows:
6
+
7
+ -----
8
+
9
+ # Blue Oak Model License
10
+
11
+ Version 1.0.0
12
+
13
+ ## Purpose
14
+
15
+ This license gives everyone as much permission to work with
16
+ this software as possible, while protecting contributors
17
+ from liability.
18
+
19
+ ## Acceptance
20
+
21
+ In order to receive this license, you must agree to its
22
+ rules. The rules of this license are both obligations
23
+ under that agreement and conditions to your license.
24
+ You must not do anything with this software that triggers
25
+ a rule that you cannot or will not follow.
26
+
27
+ ## Copyright
28
+
29
+ Each contributor licenses you to do everything with this
30
+ software that would otherwise infringe that contributor's
31
+ copyright in it.
32
+
33
+ ## Notices
34
+
35
+ You must ensure that everyone who gets a copy of
36
+ any part of this software from you, with or without
37
+ changes, also gets the text of this license or a link to
38
+ <https://blueoakcouncil.org/license/1.0.0>.
39
+
40
+ ## Excuse
41
+
42
+ If anyone notifies you in writing that you have not
43
+ complied with [Notices](#notices), you can keep your
44
+ license by taking all practical steps to comply within 30
45
+ days after the notice. If you do not do so, your license
46
+ ends immediately.
47
+
48
+ ## Patent
49
+
50
+ Each contributor licenses you to do everything with this
51
+ software that would otherwise infringe any patent claims
52
+ they can license or become able to license.
53
+
54
+ ## Reliability
55
+
56
+ No contributor can revoke this license.
57
+
58
+ ## No Liability
59
+
60
+ ***As far as the law allows, this software comes as is,
61
+ without any warranty or condition, and no contributor
62
+ will be liable to anyone for any damages related to this
63
+ software or this license, under any kind of legal claim.***
package/README.md CHANGED
@@ -6,7 +6,7 @@ V1 的目标不是复刻完整 Supabase 平台控制面,而是让现有应用
6
6
 
7
7
  ## 状态
8
8
 
9
- - 运行时:Bun 1.3+
9
+ - 运行时:npm 包需要 Bun 1.3+;单二进制发行版已内嵌 Bun 和 PGlite 资源
10
10
  - 数据库:PGlite 0.5.4
11
11
  - 项目模型:单进程、单项目,内部 project ref 固定为 `local`
12
12
  - 客户端:直接使用官方 `@supabase/supabase-js`
@@ -21,6 +21,15 @@ bun add @supacloud/lite
21
21
  bunx supacloud-lite start
22
22
  ```
23
23
 
24
+ 也可以从 GitHub Release 下载当前平台的 `supacloud-lite-*` 单二进制。该文件不需要预装 Bun、Node、npm 或 Docker:
25
+
26
+ ```bash
27
+ chmod +x ./supacloud-lite-linux-x64
28
+ ./supacloud-lite-linux-x64 start --project-dir /path/to/project
29
+ ```
30
+
31
+ 单二进制仍读取项目的 `supabase/` 目录,并在项目外部写入 `.supacloud-lite/` 持久化状态;它不包含 Web 控制台或 Supabase Studio。Linux x64/arm64、macOS x64/arm64 和 Windows x64 分别使用独立产物,不能跨操作系统或 CPU 架构混用。
32
+
24
33
  获取匿名 key:
25
34
 
26
35
  ```bash
@@ -59,6 +68,19 @@ supabase/
59
68
 
60
69
  `config.toml` 当前支持 Auth、API schema/max rows、Storage bucket/size limit、seed 和 function entrypoint 等常用配置。
61
70
 
71
+ ### Auth 运行方式
72
+
73
+ Lite 不下载、安装或启动独立的 GoTrue 进程。`/auth/v1/*` 由同一个 Bun 进程中的内置 Auth 实现处理,并与该 Lite 项目的 PGlite `auth` schema 共享生命周期;这避免了 sidecar 的配置、端口和会话一致性负担。
74
+
75
+ Auth 默认启用。如项目不需要客户端登录接口,可在 `supabase/config.toml` 中关闭该路由:
76
+
77
+ ```toml
78
+ [auth]
79
+ enabled = false
80
+ ```
81
+
82
+ 关闭后 `/auth/v1/*` 返回 `404`,但不会把 Lite 变成完整 GoTrue 运行时,也不会自动移除已有的 `auth` schema 或 API key。需要完整 GoTrue 行为、多项目鉴权或独立鉴权进程时,应使用完整 SupaCloud 平台。
83
+
62
84
  ## CLI
63
85
 
64
86
  ```text
@@ -70,6 +92,9 @@ supacloud-lite gen types [-o database.types.ts]
70
92
  supacloud-lite db reset
71
93
  supacloud-lite db diff [-f migration_name]
72
94
  supacloud-lite db pull [migration_name]
95
+ supacloud-lite snapshot create [-o backup.tar.gz]
96
+ supacloud-lite snapshot restore <backup.tar.gz> [--force]
97
+ supacloud-lite upgrade [-o pre-upgrade.tar.gz]
73
98
  supacloud-lite inspect
74
99
  supacloud-lite version
75
100
  ```
@@ -107,15 +132,91 @@ S3 模式下 `db reset` 会被拒绝,因为 Lite 不能把数据库元数据
107
132
 
108
133
  网络暴露时必须提供足够强的 JWT secret 和独立 vault key。默认生成的密钥适合单机项目;不要把 `.supacloud-lite/secrets.json` 提交到版本库。
109
134
 
135
+ ## Windows 内嵌终端排障
136
+
137
+ Lite 需要 Bun 读取已安装的 `dist/cli.js`、项目配置和 PGlite WASM 文件。若在 TRAE 等 IDE 内嵌 PowerShell 中出现 `EPERM reading`,先在同一终端运行最小文件读取测试:
138
+
139
+ ```powershell
140
+ Set-Content .\bun-read-test.js 'console.log("ok")'
141
+ bun .\bun-read-test.js
142
+ ```
143
+
144
+ 如果这个不含 Lite 的命令也返回 `EPERM`,故障发生在 Bun 启动应用之前,Lite 无法在应用代码内绕过宿主终端的文件访问限制。请切换到系统 PowerShell 或 Windows Terminal;随后升级到当前稳定版 Bun,并检查 IDE 沙箱、终端隔离和安全软件策略。`node` 能读取同一文件不代表 Bun 进程获得了相同的宿主权限。修复环境后再运行 `npx supacloud-lite --help` 验证。
145
+
146
+ 若最小测试成功而 Lite 仍失败,请保留完整错误、`bun --version`、终端类型和项目路径,再提交 Lite 问题。不要为绕过 `EPERM` 放宽项目目录的全局 ACL。
147
+
148
+ ## 升级、快照与恢复
149
+
150
+ 生产或持久化环境升级时,必须先停止当前 Lite 进程。npm 安装先更新项目锁定的依赖,再运行受控升级命令:
151
+
152
+ ```bash
153
+ # 明确指定目标版本;不要在生产启动命令中隐式使用 @latest
154
+ bun add @supacloud/lite@0.2.0
155
+
156
+ # 自动创建升级前快照,然后执行尚未应用的 supabase/migrations
157
+ bunx supacloud-lite upgrade
158
+ ```
159
+
160
+ 单二进制安装需要先下载并校验候选文件,再由候选二进制迁移现有项目:
161
+
162
+ ```bash
163
+ ./supacloud-lite-new version
164
+ ./supacloud-lite-new upgrade --project-dir /path/to/project
165
+ ./supacloud-lite-new start --project-dir /path/to/project
166
+ ```
167
+
168
+ 替换程序文件与数据库迁移是两个独立动作。`upgrade` 不会联网、自我替换二进制或修改 `package.json`;它默认先把升级前快照写入 `.supacloud-lite/backups/pre-upgrade-<timestamp>.tar.gz`,快照成功后才执行尚未记录的 migrations 和 seed。升级失败时快照会保留,并打印恢复命令。需要回滚时,停止候选进程,用升级前快照恢复状态,再重新启动上一个已验证版本。
169
+
170
+ 也可以单独创建可移植快照:
171
+
172
+ ```bash
173
+ # 使用默认文件名和目录
174
+ bunx supacloud-lite snapshot create
175
+
176
+ # 指定输出位置
177
+ bunx supacloud-lite snapshot create -o ./backups/project-a.tar.gz
178
+ ```
179
+
180
+ 快照是一个 gzip 压缩的 tar 文件,包含:
181
+
182
+ - PGlite 数据目录;
183
+ - `fs` 模式的对象文件;
184
+ - `secrets.json`,用于保持 JWT、会话和 Vault 解密兼容;
185
+ - 快照格式、Lite 版本和 Storage backend 清单。
186
+
187
+ 快照包含敏感密钥,输出文件在 Unix 系统上会设置为 `0600`;仍应按数据库备份级别加密、限制访问并设置保留周期。创建快照前必须停止 Lite。若检测到数据目录锁,命令会拒绝继续;只有确认进程已退出后才能人工删除陈旧锁。
188
+
189
+ 恢复到新项目或空状态目录:
190
+
191
+ ```bash
192
+ bunx supacloud-lite snapshot restore ./backups/project-a.tar.gz
193
+ ```
194
+
195
+ 目标状态目录非空时默认拒绝覆盖。确认要替换现有状态时显式使用:
196
+
197
+ ```bash
198
+ bunx supacloud-lite snapshot restore ./backups/project-a.tar.gz --force
199
+ ```
200
+
201
+ `--force` 不会直接删除旧数据,而是把旧状态目录重命名为 `.supacloud-lite.restore-<id>` 形式的回滚副本,并在输出中打印完整路径。验证新状态后再由运维人员清理该目录。
202
+
203
+ 使用自定义 `--state-dir`、`--data-dir` 或 `--storage-dir` 时,创建和恢复必须传入相同参数。数据库与 Storage 目录不得重叠,也不能指向文件系统根目录或符号链接。
204
+
205
+ S3 模式的快照只包含数据库中的 Storage 元数据和密钥,不复制远端对象,也不会读取或保存 S3 凭据。恢复时必须传入 `--storage-backend s3`,并重新提供原 bucket/prefix 的环境变量;跨 bucket 迁移仍需使用对象存储自身的复制工具。
206
+
207
+ 内存数据库没有可持久化的数据,因此 `snapshot` 和 `upgrade` 会拒绝 `--memory`。
208
+
110
209
  ## 兼容范围
111
210
 
112
211
  | 能力 | V1 状态 | 说明 |
113
212
  | --- | --- | --- |
114
213
  | `supabase.from()` | 已验证核心 | 自动测试覆盖 CRUD、过滤、RLS;嵌套关系、RPC 和高级 PostgREST 语法属于实验性兼容 |
115
- | `supabase.auth` | 已验证核心 | 自动测试覆盖邮箱密码、会话和 bcrypt;OTP/Magic Link、匿名用户、OAuth、MFA 属于实验性兼容 |
214
+ | `supabase.auth` | 已验证核心 | 由内置 Auth 实现而非独立 GoTrue 进程提供;自动测试覆盖邮箱密码、会话和 bcrypt;OTP/Magic Link、匿名用户、OAuth、MFA 属于实验性兼容 |
116
215
  | `supabase.storage` | 已验证核心 | 覆盖上传下载、列表、删除、TUS/RLS、远端 S3 驱动,以及 Bun.Image 的 `contain`/`fill`、格式和质量变换子集;`cover` 明确不支持 |
117
216
  | `supabase.channel()` | 已验证核心 | 自动测试覆盖 `postgres_changes`、DELETE RLS 隔离和事件快照校验;Broadcast、Presence 属于实验性兼容 |
118
217
  | `supabase.functions.invoke()` | 已验证核心 | 自动测试覆盖 Bun.build、`Deno.serve()`、公开函数和同进程重启 |
218
+ | Supabase Queues / PGMQ | 已验证核心 | 提供 `pgmq_public` 的 `send`、`send_batch`、`read`、`pop`、`archive`、`delete` RPC;队列数据持久化在同一 PGlite 项目中 |
219
+ | Edge Functions `SupaCloud.pgredis` | 已验证核心 | 提供单项目持久 KV、TTL、原子 `getset`/`getdel`;绑定只在当前函数请求内可用 |
119
220
  | Supabase migrations | 支持 | 按文件名排序,记录到 `supabase_migrations` |
120
221
  | PostgreSQL RLS | 支持 | 使用 `anon`、`authenticated`、`service_role` 数据库角色执行 |
121
222
  | PostgREST 完整线协议 | 部分支持 | 目标是常用 `supabase-js` 行为,不承诺所有 PostgREST 边角行为 |
@@ -136,6 +237,44 @@ RLS 表的 Realtime DELETE 无法在行删除后安全重放 SELECT policy,因
136
237
 
137
238
  Lite 使用 Bun 原生 bcrypt,并兼容验证常见 GoTrue bcrypt 密码散列,因此经过映射的 `auth.users` 用户可保留密码。Auth 表结构、identity、refresh token 和 provider metadata 仍需通过受控迁移脚本转换;不要直接覆盖整个 `auth` schema。迁移后必须抽样验证登录,并为无法识别的散列准备密码重置流程。
138
239
 
240
+ ## 队列与 Edge 缓存
241
+
242
+ Lite 在同一个 PGlite 数据库中提供 Supabase Queues 的公开 RPC façade。应用可以直接使用官方客户端的
243
+ `supabase.schema('pgmq_public').rpc(...)`,无需额外的队列进程:
244
+
245
+ ```sql
246
+ -- 队列创建属于管理操作,应放在项目 migration 中,而不是匿名请求路径。
247
+ select pgmq.create('emails');
248
+ ```
249
+
250
+ ```ts
251
+ const queues = supabase.schema('pgmq_public')
252
+ const { data: ids } = await queues.rpc('send_batch', {
253
+ queue_name: 'emails',
254
+ messages: [{ to: 'user@example.com' }],
255
+ sleep_seconds: 0,
256
+ })
257
+ const { data: messages } = await queues.rpc('read', {
258
+ queue_name: 'emails',
259
+ sleep_seconds: 60,
260
+ n: 10,
261
+ })
262
+ ```
263
+
264
+ Lite 的 `pgmq` 模拟层还提供 `set_vt`,支持直接 SQL 调整可见性超时。消息按 PGMQ 语义至少投递一次;`pop` 会立即删除消息,`archive` 是确认路径。队列创建、指标、purge、设置和管理 API 不属于 Lite 的公开 RPC façade,仍需由项目 SQL 或完整 SupaCloud 控制面处理。
265
+ 队列名遵循标准版的 1-128 位小写字母、数字、下划线和短横线规则,并且必须以字母或数字开头;Lite 会安全映射超出 PostgreSQL 63-byte 标识符上限的名称,避免截断后串队。默认 Data API 暴露 `public` 和 `pgmq_public`;如果显式设置 `dbSchemas`,Lite 会严格使用该列表,需要队列 RPC 时应把 `pgmq_public` 明确加入。
266
+
267
+ Edge Function 内可使用 `globalThis.SupaCloud.pgredis`:
268
+
269
+ ```ts
270
+ const cache = globalThis.SupaCloud.pgredis
271
+ await cache.set('welcome:user:42', { rendered: true }, 60_000)
272
+ const value = await cache.get<{ rendered: boolean }>('welcome:user:42')
273
+ ```
274
+
275
+ 缓存实现使用项目自己的 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
+ Lite 的缓存调用是进程内数据库操作,不具备标准版跨进程 HTTP binding 的超时和请求中止传播;不要在同一 JavaScript 进程中混合加载 Lite 与标准 Edge Runtime,两者都拥有全局 `SupaCloud` binding,Lite 检测到已有其他实现时会拒绝启动。
277
+
139
278
  ## 多项目
140
279
 
141
280
  V1 不在一个进程内复用多个 PGlite 项目。需要多个项目时,为每个项目配置独立的工作目录、端口和 `.supacloud-lite` 状态目录,并用进程管理器分别启动。这样可保持数据库、JWT、Storage 和 Realtime 的故障域隔离。
@@ -144,7 +283,7 @@ V1 不在一个进程内复用多个 PGlite 项目。需要多个项目时,为
144
283
 
145
284
  PGlite 是 WebAssembly PostgreSQL,不是 SQLite。它换来了 PostgreSQL SQL、角色、RLS 和 Supabase 迁移兼容性,但内存占用通常高于 PocketBase/SQLite。生产部署前应按真实 schema、并发和 Realtime 负载做容量测试。
146
285
 
147
- 当前 npm 包依赖 PGlite WASM 资源,不承诺 Bun `--compile` 单文件二进制可直接携带全部资源。V1 推荐通过 Bun + npm 包部署。
286
+ npm 包继续通过依赖目录加载 PGlite。GitHub Release 的平台单二进制则内嵌 Bun、PGlite JS、核心 WASM/data Lite 使用的 contrib 扩展;启动时会把扩展压缩包释放到受限的临时目录,PGlite 初始化完成后立即清理。项目配置、Functions、数据库、对象存储和密钥仍保持外置。
148
287
 
149
288
  ## API
150
289
 
package/RELEASING.md CHANGED
@@ -19,4 +19,17 @@ bun run check
19
19
  bun audit --audit-level high
20
20
  ```
21
21
 
22
- `bun run check` 会构建包、执行真实 `supabase-js` 集成测试、生成 npm tarball、在临时消费者项目中安装 tarball,并验证 CLI、公开 API、PGlite WASM 和版本一致性。
22
+ `bun run check` 会构建包、执行真实 `supabase-js` 集成测试、生成 npm tarball、在临时消费者项目中安装 tarball,并验证 npm CLI、公开 API、PGlite WASM 和版本一致性。它还会构建 host 单二进制,在不含 Bun/Node/npm 的 `PATH` 下验证 Functions、PGlite contrib 扩展、持久数据升级、升级前快照和恢复。
23
+
24
+ ## Standalone binaries
25
+
26
+ 本地构建当前平台:
27
+
28
+ ```bash
29
+ bun run build:standalone:host
30
+ bun run test:standalone
31
+ ```
32
+
33
+ Release workflow 为 Linux x64 baseline/arm64、macOS x64/arm64 和 Windows x64 baseline 构建独立产物。Linux x64 产物必须在发布 runner 上完成真实黑盒测试;其他交叉编译产物在具备对应原生 runner 前只视为已构建,不能替代平台验收。
34
+
35
+ Lite release 会同时上传 `SHA256SUMS`、项目自身的 `SUPACLOUD-LITE-APACHE-2.0.txt`、`THIRD_PARTY_NOTICES.md` 和 `LICENSES/*.txt`,并为发布资产生成 provenance。正式对外分发 macOS 或 Windows 产物前,还应按项目发布策略完成代码签名;构建成功不代表已经签名或公证。