@supacloud/lite 0.28.1 → 0.28.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.
- package/CHANGELOG.md +7 -0
- package/dist/cli.js +12 -5
- package/dist/index.js +12 -5
- package/dist/runtime/rest/errors.d.ts.map +1 -1
- package/dist/runtime/rest/handler.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.28.2](https://github.com/vibeunion/supacloud/compare/supacloud-lite-v0.28.1...supacloud-lite-v0.28.2) (2026-10-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **lite:** enforce RPC transaction access modes ([#1936](https://github.com/vibeunion/supacloud/issues/1936)) ([fb90dcc](https://github.com/vibeunion/supacloud/commit/fb90dcc43ed49a45656e1877493eaa641ef494da))
|
|
9
|
+
|
|
3
10
|
## [0.28.1](https://github.com/vibeunion/supacloud/compare/supacloud-lite-v0.28.0...supacloud-lite-v0.28.1) (2026-10-15)
|
|
4
11
|
|
|
5
12
|
|
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { dirname as dirname8, join as join10, resolve as resolve6 } from "path";
|
|
|
8
8
|
// package.json
|
|
9
9
|
var package_default = {
|
|
10
10
|
name: "@supacloud/lite",
|
|
11
|
-
version: "0.28.
|
|
11
|
+
version: "0.28.2",
|
|
12
12
|
description: "Bun-native, single-project Supabase-compatible backend powered by PGlite or native PostgreSQL",
|
|
13
13
|
type: "module",
|
|
14
14
|
license: "Apache-2.0",
|
|
@@ -8368,6 +8368,8 @@ function statusForSqlState(code) {
|
|
|
8368
8368
|
switch (code) {
|
|
8369
8369
|
case "42501":
|
|
8370
8370
|
return 403;
|
|
8371
|
+
case "25006":
|
|
8372
|
+
return 405;
|
|
8371
8373
|
case "23503":
|
|
8372
8374
|
case "23505":
|
|
8373
8375
|
return 409;
|
|
@@ -8719,17 +8721,22 @@ class RestHandler {
|
|
|
8719
8721
|
return await this.runRpc(ctx, fn, call, q, prefer, wantsObject, wantsCsv, schema, method);
|
|
8720
8722
|
}
|
|
8721
8723
|
async runRpc(ctx, fn, call, q, prefer, wantsObject, wantsCsv, schema, method) {
|
|
8724
|
+
const withRpcContext = (run) => this.db.withContext(ctx, async (query) => {
|
|
8725
|
+
if (method !== "POST" || fn.volatility !== "v")
|
|
8726
|
+
await query("set transaction read only");
|
|
8727
|
+
return run(query);
|
|
8728
|
+
});
|
|
8722
8729
|
if (fn.returnType === "void" && !fn.returnsSet) {
|
|
8723
|
-
await
|
|
8730
|
+
await withRpcContext((query) => query(`select ${call}`, []));
|
|
8724
8731
|
return new Response(null, { status: 204 });
|
|
8725
8732
|
}
|
|
8726
8733
|
if (!fn.returnsSet && ["b", "d", "e"].includes(fn.returnTypType)) {
|
|
8727
|
-
const res = await
|
|
8734
|
+
const res = await withRpcContext((query) => query(`select to_json(${call}) as result`, []));
|
|
8728
8735
|
const value = res.rows[0].result;
|
|
8729
8736
|
return jsonResponse(200, value);
|
|
8730
8737
|
}
|
|
8731
8738
|
if (fn.returnsSet && ["b", "d", "e"].includes(fn.returnTypType)) {
|
|
8732
|
-
const res = await
|
|
8739
|
+
const res = await withRpcContext((query) => query(`select coalesce(json_agg(_v), '[]'::json) as body from ${call} as _t(_v)`, []));
|
|
8733
8740
|
return jsonResponse(200, res.rows[0].body);
|
|
8734
8741
|
}
|
|
8735
8742
|
const alias = "_f";
|
|
@@ -8757,7 +8764,7 @@ class RestHandler {
|
|
|
8757
8764
|
const core = `select ${exprs.join(", ")} from ${resultSource} as ${quoteIdent(alias)}${where}${order}${limitOffset}`;
|
|
8758
8765
|
const bodySql = `select coalesce(json_agg(row_to_json(_r)), '[]'::json) as body from (${core}) _r`;
|
|
8759
8766
|
const sql = wantsCount ? `with ${quoteIdent("_rpc_result")} as (select * from ${call}) select (${bodySql}) as body, (select count(*)::int from ${resultSource} as ${quoteIdent(alias)}${where}) as count` : bodySql;
|
|
8760
|
-
const { rows, count } = await
|
|
8767
|
+
const { rows, count } = await withRpcContext(async (query) => {
|
|
8761
8768
|
const res = await query(sql, []);
|
|
8762
8769
|
const rows = res.rows[0].body;
|
|
8763
8770
|
if (wantsObject && !wantsCsv)
|
package/dist/index.js
CHANGED
|
@@ -88,7 +88,7 @@ function randomToken(bytes = 32) {
|
|
|
88
88
|
// package.json
|
|
89
89
|
var package_default = {
|
|
90
90
|
name: "@supacloud/lite",
|
|
91
|
-
version: "0.28.
|
|
91
|
+
version: "0.28.2",
|
|
92
92
|
description: "Bun-native, single-project Supabase-compatible backend powered by PGlite or native PostgreSQL",
|
|
93
93
|
type: "module",
|
|
94
94
|
license: "Apache-2.0",
|
|
@@ -8362,6 +8362,8 @@ function statusForSqlState(code) {
|
|
|
8362
8362
|
switch (code) {
|
|
8363
8363
|
case "42501":
|
|
8364
8364
|
return 403;
|
|
8365
|
+
case "25006":
|
|
8366
|
+
return 405;
|
|
8365
8367
|
case "23503":
|
|
8366
8368
|
case "23505":
|
|
8367
8369
|
return 409;
|
|
@@ -8713,17 +8715,22 @@ class RestHandler {
|
|
|
8713
8715
|
return await this.runRpc(ctx, fn, call, q, prefer, wantsObject, wantsCsv, schema, method);
|
|
8714
8716
|
}
|
|
8715
8717
|
async runRpc(ctx, fn, call, q, prefer, wantsObject, wantsCsv, schema, method) {
|
|
8718
|
+
const withRpcContext = (run) => this.db.withContext(ctx, async (query) => {
|
|
8719
|
+
if (method !== "POST" || fn.volatility !== "v")
|
|
8720
|
+
await query("set transaction read only");
|
|
8721
|
+
return run(query);
|
|
8722
|
+
});
|
|
8716
8723
|
if (fn.returnType === "void" && !fn.returnsSet) {
|
|
8717
|
-
await
|
|
8724
|
+
await withRpcContext((query) => query(`select ${call}`, []));
|
|
8718
8725
|
return new Response(null, { status: 204 });
|
|
8719
8726
|
}
|
|
8720
8727
|
if (!fn.returnsSet && ["b", "d", "e"].includes(fn.returnTypType)) {
|
|
8721
|
-
const res = await
|
|
8728
|
+
const res = await withRpcContext((query) => query(`select to_json(${call}) as result`, []));
|
|
8722
8729
|
const value = res.rows[0].result;
|
|
8723
8730
|
return jsonResponse(200, value);
|
|
8724
8731
|
}
|
|
8725
8732
|
if (fn.returnsSet && ["b", "d", "e"].includes(fn.returnTypType)) {
|
|
8726
|
-
const res = await
|
|
8733
|
+
const res = await withRpcContext((query) => query(`select coalesce(json_agg(_v), '[]'::json) as body from ${call} as _t(_v)`, []));
|
|
8727
8734
|
return jsonResponse(200, res.rows[0].body);
|
|
8728
8735
|
}
|
|
8729
8736
|
const alias = "_f";
|
|
@@ -8751,7 +8758,7 @@ class RestHandler {
|
|
|
8751
8758
|
const core = `select ${exprs.join(", ")} from ${resultSource} as ${quoteIdent(alias)}${where}${order}${limitOffset}`;
|
|
8752
8759
|
const bodySql = `select coalesce(json_agg(row_to_json(_r)), '[]'::json) as body from (${core}) _r`;
|
|
8753
8760
|
const sql = wantsCount ? `with ${quoteIdent("_rpc_result")} as (select * from ${call}) select (${bodySql}) as body, (select count(*)::int from ${resultSource} as ${quoteIdent(alias)}${where}) as count` : bodySql;
|
|
8754
|
-
const { rows, count } = await
|
|
8761
|
+
const { rows, count } = await withRpcContext(async (query) => {
|
|
8755
8762
|
const res = await query(sql, []);
|
|
8756
8763
|
const rows = res.rows[0].body;
|
|
8757
8764
|
if (wantsObject && !wantsCsv)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/runtime/rest/errors.ts"],"names":[],"mappings":"AAQA,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/runtime/rest/errors.ts"],"names":[],"mappings":"AAQA,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoBtD;AAUD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,QAAQ,CAkBpD;AAED,sDAAsD;AACtD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACnC,QAAQ,CAKV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/runtime/rest/handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAA4B,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/runtime/rest/handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAA4B,KAAK,QAAQ,EAAmC,MAAM,mBAAmB,CAAA;AAC5G,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,aAAa,CAAA;AAyF3D,oFAAoF;AACpF,qBAAa,WAAW;IAOpB,OAAO,CAAC,EAAE;IANZ,8FAA8F;IAC9F,OAAO,CAAC,cAAc,CAAU;IAChC,8EAA8E;IAC9E,OAAO,CAAC,OAAO,CAAC,CAAQ;gBAGd,EAAE,EAAE,QAAQ,EACpB,IAAI,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAMxD,4FAA4F;IACtF,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC;YAmC9D,WAAW;YAsHX,WAAW;IAgDzB,OAAO,CAAC,YAAY;YAqCN,SAAS;YAqET,MAAM;CA4FrB"}
|