@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.
- package/CHANGELOG.md +14 -0
- package/README.md +333 -15
- package/THIRD_PARTY_NOTICES.md +3 -4
- package/dist/cli.js +159 -66
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +157 -64
- package/dist/project-runtime.d.ts +6 -6
- package/dist/project-runtime.d.ts.map +1 -1
- package/dist/runtime/auth/handler.d.ts.map +1 -0
- package/dist/{vendor/tinbase → runtime}/auth/inbox.d.ts +1 -1
- package/dist/runtime/auth/inbox.d.ts.map +1 -0
- package/dist/runtime/auth/oauth.d.ts.map +1 -0
- package/dist/runtime/auth/password.d.ts.map +1 -0
- package/dist/runtime/auth/qr.d.ts.map +1 -0
- package/dist/{vendor/tinbase → runtime}/auth/rate-limit.d.ts +1 -1
- package/dist/runtime/auth/rate-limit.d.ts.map +1 -0
- package/dist/runtime/auth/redirect.d.ts.map +1 -0
- package/dist/runtime/auth/settings.d.ts.map +1 -0
- package/dist/runtime/auth/totp.d.ts.map +1 -0
- package/dist/runtime/cron/service.d.ts.map +1 -0
- package/dist/{vendor/tinbase → runtime}/db/bootstrap.d.ts +1 -1
- package/dist/runtime/db/bootstrap.d.ts.map +1 -0
- package/dist/runtime/db/data-dir-lock.d.ts.map +1 -0
- package/dist/{vendor/tinbase → runtime}/db/database.d.ts +1 -1
- package/dist/runtime/db/database.d.ts.map +1 -0
- package/dist/runtime/db/emulated.d.ts.map +1 -0
- package/dist/{vendor/tinbase → runtime}/db/engine.d.ts +2 -2
- package/dist/runtime/db/engine.d.ts.map +1 -0
- package/dist/{vendor/tinbase → runtime}/db/inspect.d.ts +1 -1
- package/dist/runtime/db/inspect.d.ts.map +1 -0
- package/dist/runtime/db/pglite-engine.d.ts.map +1 -0
- package/dist/runtime/db/schema-diff.d.ts.map +1 -0
- package/dist/{vendor/tinbase → runtime}/db/sql-compat.d.ts +2 -2
- package/dist/runtime/db/sql-compat.d.ts.map +1 -0
- package/dist/runtime/functions/deno-shim.d.ts.map +1 -0
- package/dist/runtime/functions/handler.d.ts.map +1 -0
- package/dist/runtime/functions/pgredis.d.ts.map +1 -0
- package/dist/runtime/gen-types.d.ts.map +1 -0
- package/dist/{vendor/tinbase → runtime}/index.d.ts +6 -6
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/jwt.d.ts.map +1 -0
- package/dist/runtime/log-buffer.d.ts.map +1 -0
- package/dist/runtime/net/service.d.ts.map +1 -0
- package/dist/runtime/node/bun-server.d.ts.map +1 -0
- package/dist/runtime/node/bundle-function.d.ts.map +1 -0
- package/dist/runtime/node/config-toml.d.ts.map +1 -0
- package/dist/runtime/node/fs-driver.d.ts.map +1 -0
- package/dist/{vendor/tinbase → runtime}/node/load-config.d.ts +4 -4
- package/dist/runtime/node/load-config.d.ts.map +1 -0
- package/dist/runtime/node/load-functions.d.ts.map +1 -0
- package/dist/runtime/node/project.d.ts.map +1 -0
- package/dist/runtime/node/server-shared.d.ts.map +1 -0
- package/dist/runtime/realtime/engine.d.ts.map +1 -0
- package/dist/runtime/rest/build.d.ts.map +1 -0
- package/dist/runtime/rest/errors.d.ts.map +1 -0
- package/dist/runtime/rest/handler.d.ts.map +1 -0
- package/dist/runtime/rest/parse.d.ts.map +1 -0
- package/dist/runtime/retention/service.d.ts.map +1 -0
- package/dist/runtime/security.d.ts.map +1 -0
- package/dist/runtime/storage/driver.d.ts.map +1 -0
- package/dist/runtime/storage/handler.d.ts.map +1 -0
- package/dist/runtime/storage/image-transform.d.ts.map +1 -0
- package/dist/runtime/storage/s3-driver.d.ts.map +1 -0
- package/dist/{vendor/tinbase → runtime}/types.d.ts +2 -2
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/{vendor/tinbase → runtime}/webhooks/service.d.ts +1 -1
- package/dist/runtime/webhooks/service.d.ts.map +1 -0
- package/package.json +3 -2
- package/dist/vendor/tinbase/auth/handler.d.ts.map +0 -1
- package/dist/vendor/tinbase/auth/inbox.d.ts.map +0 -1
- package/dist/vendor/tinbase/auth/oauth.d.ts.map +0 -1
- package/dist/vendor/tinbase/auth/password.d.ts.map +0 -1
- package/dist/vendor/tinbase/auth/qr.d.ts.map +0 -1
- package/dist/vendor/tinbase/auth/rate-limit.d.ts.map +0 -1
- package/dist/vendor/tinbase/auth/redirect.d.ts.map +0 -1
- package/dist/vendor/tinbase/auth/settings.d.ts.map +0 -1
- package/dist/vendor/tinbase/auth/totp.d.ts.map +0 -1
- package/dist/vendor/tinbase/cron/service.d.ts.map +0 -1
- package/dist/vendor/tinbase/db/bootstrap.d.ts.map +0 -1
- package/dist/vendor/tinbase/db/data-dir-lock.d.ts.map +0 -1
- package/dist/vendor/tinbase/db/database.d.ts.map +0 -1
- package/dist/vendor/tinbase/db/emulated.d.ts.map +0 -1
- package/dist/vendor/tinbase/db/engine.d.ts.map +0 -1
- package/dist/vendor/tinbase/db/inspect.d.ts.map +0 -1
- package/dist/vendor/tinbase/db/pglite-engine.d.ts.map +0 -1
- package/dist/vendor/tinbase/db/schema-diff.d.ts.map +0 -1
- package/dist/vendor/tinbase/db/sql-compat.d.ts.map +0 -1
- package/dist/vendor/tinbase/functions/deno-shim.d.ts.map +0 -1
- package/dist/vendor/tinbase/functions/handler.d.ts.map +0 -1
- package/dist/vendor/tinbase/functions/pgredis.d.ts.map +0 -1
- package/dist/vendor/tinbase/gen-types.d.ts.map +0 -1
- package/dist/vendor/tinbase/index.d.ts.map +0 -1
- package/dist/vendor/tinbase/jwt.d.ts.map +0 -1
- package/dist/vendor/tinbase/log-buffer.d.ts.map +0 -1
- package/dist/vendor/tinbase/net/service.d.ts.map +0 -1
- package/dist/vendor/tinbase/node/bun-server.d.ts.map +0 -1
- package/dist/vendor/tinbase/node/bundle-function.d.ts.map +0 -1
- package/dist/vendor/tinbase/node/config-toml.d.ts.map +0 -1
- package/dist/vendor/tinbase/node/fs-driver.d.ts.map +0 -1
- package/dist/vendor/tinbase/node/load-config.d.ts.map +0 -1
- package/dist/vendor/tinbase/node/load-functions.d.ts.map +0 -1
- package/dist/vendor/tinbase/node/project.d.ts.map +0 -1
- package/dist/vendor/tinbase/node/server-shared.d.ts.map +0 -1
- package/dist/vendor/tinbase/realtime/engine.d.ts.map +0 -1
- package/dist/vendor/tinbase/rest/build.d.ts.map +0 -1
- package/dist/vendor/tinbase/rest/errors.d.ts.map +0 -1
- package/dist/vendor/tinbase/rest/handler.d.ts.map +0 -1
- package/dist/vendor/tinbase/rest/parse.d.ts.map +0 -1
- package/dist/vendor/tinbase/retention/service.d.ts.map +0 -1
- package/dist/vendor/tinbase/security.d.ts.map +0 -1
- package/dist/vendor/tinbase/storage/driver.d.ts.map +0 -1
- package/dist/vendor/tinbase/storage/handler.d.ts.map +0 -1
- package/dist/vendor/tinbase/storage/image-transform.d.ts.map +0 -1
- package/dist/vendor/tinbase/storage/s3-driver.d.ts.map +0 -1
- package/dist/vendor/tinbase/types.d.ts.map +0 -1
- package/dist/vendor/tinbase/webhooks/service.d.ts.map +0 -1
- /package/LICENSES/{TINBASE-MIT.txt → UPSTREAM-PROTOCOL-MIT.txt} +0 -0
- /package/dist/{vendor/tinbase → runtime}/auth/handler.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/auth/oauth.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/auth/password.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/auth/qr.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/auth/redirect.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/auth/settings.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/auth/totp.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/cron/service.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/db/data-dir-lock.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/db/emulated.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/db/pglite-engine.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/db/schema-diff.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/functions/deno-shim.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/functions/handler.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/functions/pgredis.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/gen-types.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/jwt.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/log-buffer.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/net/service.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/node/bun-server.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/node/bundle-function.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/node/config-toml.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/node/fs-driver.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/node/load-functions.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/node/project.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/node/server-shared.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/realtime/engine.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/rest/build.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/rest/errors.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/rest/handler.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/rest/parse.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/retention/service.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/security.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/storage/driver.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/storage/handler.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/storage/image-transform.d.ts +0 -0
- /package/dist/{vendor/tinbase → runtime}/storage/s3-driver.d.ts +0 -0
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
|
|
|
8
8
|
// package.json
|
|
9
9
|
var package_default = {
|
|
10
10
|
name: "@supacloud/lite",
|
|
11
|
-
version: "0.5.
|
|
11
|
+
version: "0.5.7",
|
|
12
12
|
description: "Bun-native, single-project Supabase-compatible backend powered by PGlite",
|
|
13
13
|
type: "module",
|
|
14
14
|
license: "Apache-2.0",
|
|
@@ -33,7 +33,7 @@ var package_default = {
|
|
|
33
33
|
],
|
|
34
34
|
scripts: {
|
|
35
35
|
build: "bun run build:js && bun run build:types",
|
|
36
|
-
"build:js": "bun build src/index.ts --target=bun --format=esm --outdir=dist --external @electric-sql/pglite --external tar && bun build src/cli.ts --target=bun --format=esm --outdir=dist --external @electric-sql/pglite --external tar && bun run scripts/build-launcher.ts",
|
|
36
|
+
"build:js": "bun run clean && bun build src/index.ts --target=bun --format=esm --outdir=dist --external @electric-sql/pglite --external tar && bun build src/cli.ts --target=bun --format=esm --outdir=dist --external @electric-sql/pglite --external tar && bun run scripts/build-launcher.ts",
|
|
37
37
|
"build:standalone:host": "bun run scripts/build-standalone.ts host",
|
|
38
38
|
"build:standalone:linux": "bun run scripts/build-standalone.ts linux-x64 linux-arm64",
|
|
39
39
|
"build:standalone:macos": "bun run scripts/build-standalone.ts macos-x64 macos-arm64",
|
|
@@ -41,6 +41,7 @@ var package_default = {
|
|
|
41
41
|
"build:standalone:release": "bun run scripts/build-standalone.ts linux-x64 linux-arm64 macos-x64 macos-arm64 windows-x64",
|
|
42
42
|
"build:types": "bun x tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
43
43
|
check: "bun run typecheck && bun run test && bun run build && bun run test:package && bun run build:standalone:host && bun run test:standalone",
|
|
44
|
+
clean: `bun -e "import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true })"`,
|
|
44
45
|
dev: "bun run src/cli.ts start",
|
|
45
46
|
start: "bun run src/cli.ts start",
|
|
46
47
|
test: "bun test --timeout 20000",
|
|
@@ -79,7 +80,7 @@ var package_default = {
|
|
|
79
80
|
]
|
|
80
81
|
};
|
|
81
82
|
|
|
82
|
-
// src/
|
|
83
|
+
// src/runtime/jwt.ts
|
|
83
84
|
var encoder = new TextEncoder;
|
|
84
85
|
var decoder = new TextDecoder;
|
|
85
86
|
function bytesToBase64Url(bytes) {
|
|
@@ -140,7 +141,7 @@ function randomToken(bytes = 32) {
|
|
|
140
141
|
// src/version.ts
|
|
141
142
|
var SUPACLOUD_LITE_VERSION = package_default.version;
|
|
142
143
|
|
|
143
|
-
// src/
|
|
144
|
+
// src/runtime/auth/redirect.ts
|
|
144
145
|
function globToRegExp(pattern) {
|
|
145
146
|
let out = "";
|
|
146
147
|
for (let i = 0;i < pattern.length; i++) {
|
|
@@ -189,7 +190,7 @@ function isAllowedRedirect(requested, siteUrl, allowList = []) {
|
|
|
189
190
|
return allowList.some((entry) => globToRegExp(entry).test(requested));
|
|
190
191
|
}
|
|
191
192
|
|
|
192
|
-
// src/
|
|
193
|
+
// src/runtime/auth/oauth.ts
|
|
193
194
|
var PRESETS = {
|
|
194
195
|
google: {
|
|
195
196
|
authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
|
|
@@ -410,7 +411,7 @@ function base64url(bytes) {
|
|
|
410
411
|
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
411
412
|
}
|
|
412
413
|
|
|
413
|
-
// src/
|
|
414
|
+
// src/runtime/auth/password.ts
|
|
414
415
|
function toHex(bytes) {
|
|
415
416
|
return [...bytes].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
416
417
|
}
|
|
@@ -465,7 +466,7 @@ async function verifyPassword(password, stored) {
|
|
|
465
466
|
return diff === 0;
|
|
466
467
|
}
|
|
467
468
|
|
|
468
|
-
// src/
|
|
469
|
+
// src/runtime/auth/qr.ts
|
|
469
470
|
var ECC_M = { ordinal: 0, formatBits: 0 };
|
|
470
471
|
var ECC_CODEWORDS_PER_BLOCK = [
|
|
471
472
|
-1,
|
|
@@ -900,7 +901,7 @@ function qrSvgDataUri(text) {
|
|
|
900
901
|
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
|
|
901
902
|
}
|
|
902
903
|
|
|
903
|
-
// src/
|
|
904
|
+
// src/runtime/auth/settings.ts
|
|
904
905
|
var DEFAULT_AUTH_SETTINGS = {
|
|
905
906
|
disableSignup: false,
|
|
906
907
|
anonymousUsers: true,
|
|
@@ -953,7 +954,7 @@ async function loadAuthSettings(db, defaults = {}) {
|
|
|
953
954
|
}
|
|
954
955
|
}
|
|
955
956
|
|
|
956
|
-
// src/
|
|
957
|
+
// src/runtime/auth/rate-limit.ts
|
|
957
958
|
var DEFAULT_AUTH_RATE_LIMITS = {
|
|
958
959
|
token: { limit: 30, windowMs: 5 * 60 * 1000 },
|
|
959
960
|
signup: { limit: 30, windowMs: 60 * 60 * 1000 },
|
|
@@ -998,7 +999,7 @@ class RateLimiter {
|
|
|
998
999
|
}
|
|
999
1000
|
}
|
|
1000
1001
|
|
|
1001
|
-
// src/
|
|
1002
|
+
// src/runtime/auth/totp.ts
|
|
1002
1003
|
var B32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
1003
1004
|
function base32Encode(bytes) {
|
|
1004
1005
|
let bits = 0;
|
|
@@ -1076,7 +1077,7 @@ async function verifyTotp(secretBase32, code, window = 1, atMs = Date.now()) {
|
|
|
1076
1077
|
return false;
|
|
1077
1078
|
}
|
|
1078
1079
|
|
|
1079
|
-
// src/
|
|
1080
|
+
// src/runtime/auth/handler.ts
|
|
1080
1081
|
function authError(status, errorCode, msg) {
|
|
1081
1082
|
return json(status, { code: status, error_code: errorCode, msg });
|
|
1082
1083
|
}
|
|
@@ -1828,7 +1829,7 @@ Or sign in with this link: ${link}`
|
|
|
1828
1829
|
}
|
|
1829
1830
|
}
|
|
1830
1831
|
|
|
1831
|
-
// src/
|
|
1832
|
+
// src/runtime/auth/inbox.ts
|
|
1832
1833
|
var CAP = 200;
|
|
1833
1834
|
|
|
1834
1835
|
class InboxMailer {
|
|
@@ -1940,7 +1941,7 @@ var INBOX_HTML = `<!doctype html>
|
|
|
1940
1941
|
</body>
|
|
1941
1942
|
</html>`;
|
|
1942
1943
|
|
|
1943
|
-
// src/
|
|
1944
|
+
// src/runtime/log-buffer.ts
|
|
1944
1945
|
class LogBuffer {
|
|
1945
1946
|
cap;
|
|
1946
1947
|
entries = [];
|
|
@@ -1960,7 +1961,7 @@ class LogBuffer {
|
|
|
1960
1961
|
}
|
|
1961
1962
|
}
|
|
1962
1963
|
|
|
1963
|
-
// src/
|
|
1964
|
+
// src/runtime/functions/deno-shim.ts
|
|
1964
1965
|
import { AsyncLocalStorage } from "async_hooks";
|
|
1965
1966
|
var captured = {};
|
|
1966
1967
|
var envStore = new AsyncLocalStorage;
|
|
@@ -1969,11 +1970,11 @@ function runWithDenoEnv(env, fn) {
|
|
|
1969
1970
|
}
|
|
1970
1971
|
function installDenoShim() {
|
|
1971
1972
|
const g = globalThis;
|
|
1972
|
-
if (g.
|
|
1973
|
+
if (g.__supacloudLiteDeno)
|
|
1973
1974
|
return;
|
|
1974
1975
|
if (g.Deno && typeof g.Deno.serve === "function")
|
|
1975
1976
|
return;
|
|
1976
|
-
g.
|
|
1977
|
+
g.__supacloudLiteDeno = true;
|
|
1977
1978
|
g.Deno = {
|
|
1978
1979
|
serve(arg1, arg2) {
|
|
1979
1980
|
captured.handler = typeof arg1 === "function" ? arg1 : arg2;
|
|
@@ -2009,7 +2010,7 @@ function resetCapturedHandler() {
|
|
|
2009
2010
|
captured.handler = undefined;
|
|
2010
2011
|
}
|
|
2011
2012
|
|
|
2012
|
-
// src/
|
|
2013
|
+
// src/runtime/functions/pgredis.ts
|
|
2013
2014
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
2014
2015
|
var CACHE_NAMESPACE = "supacloud-edge-runtime";
|
|
2015
2016
|
var CACHE_TABLE = "public.supacloud_pgredis_kv";
|
|
@@ -2176,7 +2177,7 @@ async function upsertWithoutTtl(query, key, serializedValue) {
|
|
|
2176
2177
|
on conflict (namespace, key) do update set value = excluded.value, expires_at = null, updated_at = now()`, [CACHE_NAMESPACE, key, serializedValue]);
|
|
2177
2178
|
}
|
|
2178
2179
|
|
|
2179
|
-
// src/
|
|
2180
|
+
// src/runtime/functions/handler.ts
|
|
2180
2181
|
class FunctionsHandler {
|
|
2181
2182
|
functions;
|
|
2182
2183
|
env;
|
|
@@ -2221,7 +2222,7 @@ function json2(status, body) {
|
|
|
2221
2222
|
});
|
|
2222
2223
|
}
|
|
2223
2224
|
|
|
2224
|
-
// src/
|
|
2225
|
+
// src/runtime/db/bootstrap.ts
|
|
2225
2226
|
var MINIMAL_BOOTSTRAP_SQL = `
|
|
2226
2227
|
create schema if not exists auth;
|
|
2227
2228
|
create schema if not exists storage;
|
|
@@ -2645,8 +2646,22 @@ $$;
|
|
|
2645
2646
|
|
|
2646
2647
|
alter table storage.objects enable row level security;
|
|
2647
2648
|
|
|
2648
|
-
drop policy if exists
|
|
2649
|
-
drop policy if exists
|
|
2649
|
+
drop policy if exists supacloud_lite_authenticated_all on storage.objects;
|
|
2650
|
+
drop policy if exists supacloud_lite_public_read on storage.objects;
|
|
2651
|
+
|
|
2652
|
+
do $legacy_policy_cleanup$
|
|
2653
|
+
declare
|
|
2654
|
+
legacy_prefix constant text := 'tin' || 'base';
|
|
2655
|
+
begin
|
|
2656
|
+
execute format(
|
|
2657
|
+
'drop policy if exists %I on storage.objects',
|
|
2658
|
+
legacy_prefix || '_authenticated_all'
|
|
2659
|
+
);
|
|
2660
|
+
execute format(
|
|
2661
|
+
'drop policy if exists %I on storage.objects',
|
|
2662
|
+
legacy_prefix || '_public_read'
|
|
2663
|
+
);
|
|
2664
|
+
end $legacy_policy_cleanup$;
|
|
2650
2665
|
|
|
2651
2666
|
-- \u2500\u2500 Migration bookkeeping (same table the Supabase CLI uses) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
2652
2667
|
create schema if not exists supabase_migrations;
|
|
@@ -2665,9 +2680,19 @@ create table if not exists supabase_migrations.seed_files (
|
|
|
2665
2680
|
);
|
|
2666
2681
|
|
|
2667
2682
|
-- \u2500\u2500 Realtime CDC plumbing \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
2668
|
-
|
|
2683
|
+
do $legacy_schema_upgrade$
|
|
2684
|
+
declare
|
|
2685
|
+
legacy_schema constant text := 'tin' || 'base';
|
|
2686
|
+
begin
|
|
2687
|
+
if exists (select 1 from pg_namespace where nspname = legacy_schema)
|
|
2688
|
+
and not exists (select 1 from pg_namespace where nspname = 'supacloud_lite') then
|
|
2689
|
+
execute format('alter schema %I rename to supacloud_lite', legacy_schema);
|
|
2690
|
+
end if;
|
|
2691
|
+
end $legacy_schema_upgrade$;
|
|
2692
|
+
|
|
2693
|
+
create schema if not exists supacloud_lite;
|
|
2669
2694
|
|
|
2670
|
-
create or replace function
|
|
2695
|
+
create or replace function supacloud_lite.cdc_notify() returns trigger
|
|
2671
2696
|
language plpgsql security definer as $$
|
|
2672
2697
|
declare
|
|
2673
2698
|
payload text;
|
|
@@ -2692,10 +2717,78 @@ begin
|
|
|
2692
2717
|
'errors', json_build_array('Payload too large')
|
|
2693
2718
|
)::text;
|
|
2694
2719
|
end if;
|
|
2695
|
-
perform pg_notify('
|
|
2720
|
+
perform pg_notify('supacloud_lite_cdc', payload);
|
|
2696
2721
|
return coalesce(NEW, OLD);
|
|
2697
2722
|
end $$;
|
|
2698
2723
|
|
|
2724
|
+
do $legacy_trigger_upgrade$
|
|
2725
|
+
declare
|
|
2726
|
+
legacy_schema constant text := 'tin' || 'base';
|
|
2727
|
+
legacy_trigger constant text := ('tin' || 'base') || '_cdc';
|
|
2728
|
+
trigger_record record;
|
|
2729
|
+
target_exists boolean;
|
|
2730
|
+
begin
|
|
2731
|
+
for trigger_record in
|
|
2732
|
+
select c.oid as relation_oid, n.nspname as schema_name, c.relname as table_name
|
|
2733
|
+
from pg_trigger tg
|
|
2734
|
+
join pg_class c on c.oid = tg.tgrelid
|
|
2735
|
+
join pg_namespace n on n.oid = c.relnamespace
|
|
2736
|
+
join pg_proc p on p.oid = tg.tgfoid
|
|
2737
|
+
join pg_namespace pn on pn.oid = p.pronamespace
|
|
2738
|
+
where not tg.tgisinternal
|
|
2739
|
+
and tg.tgname = legacy_trigger
|
|
2740
|
+
and p.proname = 'cdc_notify'
|
|
2741
|
+
and pn.nspname in (legacy_schema, 'supacloud_lite')
|
|
2742
|
+
loop
|
|
2743
|
+
select exists (
|
|
2744
|
+
select 1
|
|
2745
|
+
from pg_trigger
|
|
2746
|
+
where not tgisinternal
|
|
2747
|
+
and tgrelid = trigger_record.relation_oid
|
|
2748
|
+
and tgname = 'supacloud_lite_cdc'
|
|
2749
|
+
) into target_exists;
|
|
2750
|
+
|
|
2751
|
+
execute format(
|
|
2752
|
+
'drop trigger %I on %I.%I',
|
|
2753
|
+
legacy_trigger,
|
|
2754
|
+
trigger_record.schema_name,
|
|
2755
|
+
trigger_record.table_name
|
|
2756
|
+
);
|
|
2757
|
+
|
|
2758
|
+
if not target_exists then
|
|
2759
|
+
execute format(
|
|
2760
|
+
'create trigger supacloud_lite_cdc after insert or update or delete on %I.%I for each row execute function supacloud_lite.cdc_notify()',
|
|
2761
|
+
trigger_record.schema_name,
|
|
2762
|
+
trigger_record.table_name
|
|
2763
|
+
);
|
|
2764
|
+
end if;
|
|
2765
|
+
end loop;
|
|
2766
|
+
end $legacy_trigger_upgrade$;
|
|
2767
|
+
|
|
2768
|
+
do $legacy_schema_cleanup$
|
|
2769
|
+
declare
|
|
2770
|
+
legacy_schema constant text := 'tin' || 'base';
|
|
2771
|
+
begin
|
|
2772
|
+
if exists (
|
|
2773
|
+
select 1
|
|
2774
|
+
from pg_proc p
|
|
2775
|
+
join pg_namespace n on n.oid = p.pronamespace
|
|
2776
|
+
where n.nspname = legacy_schema
|
|
2777
|
+
and p.proname = 'cdc_notify'
|
|
2778
|
+
and p.pronargs = 0
|
|
2779
|
+
) then
|
|
2780
|
+
execute format('drop function %I.cdc_notify()', legacy_schema);
|
|
2781
|
+
end if;
|
|
2782
|
+
|
|
2783
|
+
if exists (select 1 from pg_namespace where nspname = legacy_schema) then
|
|
2784
|
+
begin
|
|
2785
|
+
execute format('drop schema %I', legacy_schema);
|
|
2786
|
+
exception when dependent_objects_still_exist then
|
|
2787
|
+
raise notice 'SupaCloud Lite: retained non-empty legacy runtime schema';
|
|
2788
|
+
end;
|
|
2789
|
+
end if;
|
|
2790
|
+
end $legacy_schema_cleanup$;
|
|
2791
|
+
|
|
2699
2792
|
-- \u2500\u2500 Realtime Authorization + broadcast-from-database \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
2700
2793
|
-- Mirrors Supabase Realtime: developers write RLS policies on
|
|
2701
2794
|
-- realtime.messages using realtime.topic(); a SELECT policy grants a private
|
|
@@ -2725,12 +2818,12 @@ create or replace function realtime.topic() returns text
|
|
|
2725
2818
|
|
|
2726
2819
|
-- push a broadcast message to all subscribers of <topic> from SQL / triggers.
|
|
2727
2820
|
-- Delivered over the websocket by the in-process realtime engine, which listens
|
|
2728
|
-
-- on the '
|
|
2821
|
+
-- on the 'supacloud_lite_realtime_broadcast' channel.
|
|
2729
2822
|
create or replace function realtime.send(payload jsonb, event text, topic text, private boolean default true)
|
|
2730
2823
|
returns void language plpgsql security definer as $$
|
|
2731
2824
|
begin
|
|
2732
2825
|
perform pg_notify(
|
|
2733
|
-
'
|
|
2826
|
+
'supacloud_lite_realtime_broadcast',
|
|
2734
2827
|
json_build_object('topic', topic, 'event', event, 'payload', payload, 'private', private)::text
|
|
2735
2828
|
);
|
|
2736
2829
|
exception when others then
|
|
@@ -2742,7 +2835,7 @@ grant execute on function realtime.topic() to anon, authenticated, service_role;
|
|
|
2742
2835
|
grant execute on function realtime.send(jsonb, text, text, boolean) to anon, authenticated, service_role;
|
|
2743
2836
|
`;
|
|
2744
2837
|
|
|
2745
|
-
// src/
|
|
2838
|
+
// src/runtime/db/emulated.ts
|
|
2746
2839
|
var PGMQ_SQL = `
|
|
2747
2840
|
create schema if not exists pgmq;
|
|
2748
2841
|
revoke all on schema pgmq from public, anon, authenticated;
|
|
@@ -3193,7 +3286,7 @@ end $vault$;
|
|
|
3193
3286
|
grant execute on function vault.create_secret(text,text,text,uuid), vault.update_secret(uuid,text,text,text,uuid) to service_role;
|
|
3194
3287
|
`;
|
|
3195
3288
|
|
|
3196
|
-
// src/
|
|
3289
|
+
// src/runtime/db/sql-compat.ts
|
|
3197
3290
|
function rewriteMigrationSql(sql) {
|
|
3198
3291
|
const out = [];
|
|
3199
3292
|
const n = sql.length;
|
|
@@ -3274,7 +3367,7 @@ function rewriteStatement(stmt) {
|
|
|
3274
3367
|
return stmt;
|
|
3275
3368
|
const inner = pickTag(bare, "tb_ext_stmt");
|
|
3276
3369
|
const outer = pickTag(bare, "tb_ext");
|
|
3277
|
-
return `${trivia}DO ${outer} BEGIN EXECUTE ${inner}${bare}${inner}; ` + `EXCEPTION WHEN OTHERS THEN RAISE NOTICE '
|
|
3370
|
+
return `${trivia}DO ${outer} BEGIN EXECUTE ${inner}${bare}${inner}; ` + `EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'SupaCloud Lite: skipped extension statement (%)', SQLERRM; END ${outer};`;
|
|
3278
3371
|
}
|
|
3279
3372
|
if (/^(?:create\s+(?:unique\s+)?index|drop\s+index|reindex)\b/i.test(rest)) {
|
|
3280
3373
|
return trivia + rest.replace(/\s+concurrently\b/i, " ");
|
|
@@ -3289,11 +3382,11 @@ function pickTag(text, base) {
|
|
|
3289
3382
|
return tag;
|
|
3290
3383
|
}
|
|
3291
3384
|
|
|
3292
|
-
// src/
|
|
3385
|
+
// src/runtime/db/pglite-engine.ts
|
|
3293
3386
|
import { mkdir, open, unlink as unlink2 } from "fs/promises";
|
|
3294
3387
|
import { dirname, resolve } from "path";
|
|
3295
3388
|
|
|
3296
|
-
// src/
|
|
3389
|
+
// src/runtime/db/data-dir-lock.ts
|
|
3297
3390
|
import { readFile, unlink } from "fs/promises";
|
|
3298
3391
|
async function recoverStaleDataDirLock(lockPath) {
|
|
3299
3392
|
const lockState = await inspectDataDirLock(lockPath);
|
|
@@ -3344,7 +3437,7 @@ function isProcessAlive(pid) {
|
|
|
3344
3437
|
// src/standalone-assets-protocol.ts
|
|
3345
3438
|
var STANDALONE_PGLITE_ASSETS = Symbol.for("supacloud-lite.pglite-standalone-assets");
|
|
3346
3439
|
|
|
3347
|
-
// src/
|
|
3440
|
+
// src/runtime/db/pglite-engine.ts
|
|
3348
3441
|
async function createPgliteEngine(dataDir) {
|
|
3349
3442
|
const releaseLock = await acquireDataDirLock(dataDir);
|
|
3350
3443
|
let PGlite, extensions;
|
|
@@ -3519,7 +3612,7 @@ function unreadableLockError(lockPath) {
|
|
|
3519
3612
|
return new Error(`PGlite data directory has an unreadable lock: ${lockPath}. Confirm no SupaCloud Lite process is using it, then remove the lock manually.`);
|
|
3520
3613
|
}
|
|
3521
3614
|
|
|
3522
|
-
// src/
|
|
3615
|
+
// src/runtime/db/database.ts
|
|
3523
3616
|
var DEFAULT_SEARCH_PATH_SQL = `set search_path to "$user", public, extensions`;
|
|
3524
3617
|
|
|
3525
3618
|
class Database {
|
|
@@ -3763,13 +3856,13 @@ class Database {
|
|
|
3763
3856
|
select from pg_trigger tg
|
|
3764
3857
|
join pg_class c on c.oid = tg.tgrelid
|
|
3765
3858
|
join pg_namespace n on n.oid = c.relnamespace
|
|
3766
|
-
where tg.tgname = '
|
|
3859
|
+
where tg.tgname = 'supacloud_lite_cdc'
|
|
3767
3860
|
and n.nspname = ${quoteLiteral(schema)}
|
|
3768
3861
|
and c.relname = ${quoteLiteral(table)}
|
|
3769
3862
|
) then
|
|
3770
|
-
create trigger
|
|
3863
|
+
create trigger supacloud_lite_cdc
|
|
3771
3864
|
after insert or update or delete on ${s}.${t}
|
|
3772
|
-
for each row execute function
|
|
3865
|
+
for each row execute function supacloud_lite.cdc_notify();
|
|
3773
3866
|
end if;
|
|
3774
3867
|
end $$;
|
|
3775
3868
|
`);
|
|
@@ -3803,7 +3896,7 @@ class Database {
|
|
|
3803
3896
|
}
|
|
3804
3897
|
}
|
|
3805
3898
|
async attachCdcListener() {
|
|
3806
|
-
this.cdcUnsubscribe = await this.engine.listen("
|
|
3899
|
+
this.cdcUnsubscribe = await this.engine.listen("supacloud_lite_cdc", (payload) => {
|
|
3807
3900
|
try {
|
|
3808
3901
|
const event = JSON.parse(payload);
|
|
3809
3902
|
for (const listener of this.cdcListeners)
|
|
@@ -3891,7 +3984,7 @@ async function sha256Hex(text) {
|
|
|
3891
3984
|
return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
3892
3985
|
}
|
|
3893
3986
|
|
|
3894
|
-
// src/
|
|
3987
|
+
// src/runtime/realtime/engine.ts
|
|
3895
3988
|
class RealtimeEngine {
|
|
3896
3989
|
db;
|
|
3897
3990
|
jwtSecret;
|
|
@@ -3956,7 +4049,7 @@ class RealtimeEngine {
|
|
|
3956
4049
|
if (this.stopCdc)
|
|
3957
4050
|
return;
|
|
3958
4051
|
this.stopCdc = await this.db.onCdcEvent((e) => this.dispatchCdc(e));
|
|
3959
|
-
this.stopDbBroadcast = await this.db.engine.listen("
|
|
4052
|
+
this.stopDbBroadcast = await this.db.engine.listen("supacloud_lite_realtime_broadcast", (payload) => {
|
|
3960
4053
|
try {
|
|
3961
4054
|
this.dispatchDbBroadcast(JSON.parse(payload));
|
|
3962
4055
|
} catch {}
|
|
@@ -4428,7 +4521,7 @@ function encodeUserBroadcast(topic, event, payload) {
|
|
|
4428
4521
|
return out;
|
|
4429
4522
|
}
|
|
4430
4523
|
|
|
4431
|
-
// src/
|
|
4524
|
+
// src/runtime/types.ts
|
|
4432
4525
|
var DEFAULT_JWT_SECRET = "";
|
|
4433
4526
|
|
|
4434
4527
|
class ApiError extends Error {
|
|
@@ -4441,7 +4534,7 @@ class ApiError extends Error {
|
|
|
4441
4534
|
}
|
|
4442
4535
|
}
|
|
4443
4536
|
|
|
4444
|
-
// src/
|
|
4537
|
+
// src/runtime/rest/parse.ts
|
|
4445
4538
|
class ParseError extends Error {
|
|
4446
4539
|
}
|
|
4447
4540
|
var RESERVED = new Set(["select", "order", "limit", "offset", "on_conflict", "columns"]);
|
|
@@ -4715,7 +4808,7 @@ function findAliasColon(item) {
|
|
|
4715
4808
|
return -1;
|
|
4716
4809
|
}
|
|
4717
4810
|
|
|
4718
|
-
// src/
|
|
4811
|
+
// src/runtime/rest/build.ts
|
|
4719
4812
|
var AGG_EMPTY = `'[]'::json`;
|
|
4720
4813
|
|
|
4721
4814
|
class QueryBuilder {
|
|
@@ -5223,7 +5316,7 @@ function renderFilter(f, alias) {
|
|
|
5223
5316
|
return f.negated ? `not (${expr})` : expr;
|
|
5224
5317
|
}
|
|
5225
5318
|
|
|
5226
|
-
// src/
|
|
5319
|
+
// src/runtime/rest/errors.ts
|
|
5227
5320
|
function statusForSqlState(code) {
|
|
5228
5321
|
switch (code) {
|
|
5229
5322
|
case "42501":
|
|
@@ -5269,7 +5362,7 @@ function jsonResponse(status, body, headers = {}) {
|
|
|
5269
5362
|
});
|
|
5270
5363
|
}
|
|
5271
5364
|
|
|
5272
|
-
// src/
|
|
5365
|
+
// src/runtime/rest/handler.ts
|
|
5273
5366
|
function parsePrefer(header) {
|
|
5274
5367
|
const prefer = {};
|
|
5275
5368
|
if (!header)
|
|
@@ -5679,7 +5772,7 @@ async function readJsonBody(req) {
|
|
|
5679
5772
|
}
|
|
5680
5773
|
}
|
|
5681
5774
|
|
|
5682
|
-
// src/
|
|
5775
|
+
// src/runtime/storage/driver.ts
|
|
5683
5776
|
class MemoryStorageDriver {
|
|
5684
5777
|
files = new Map;
|
|
5685
5778
|
async put(key, data) {
|
|
@@ -5697,7 +5790,7 @@ class MemoryStorageDriver {
|
|
|
5697
5790
|
}
|
|
5698
5791
|
}
|
|
5699
5792
|
|
|
5700
|
-
// src/
|
|
5793
|
+
// src/runtime/storage/image-transform.ts
|
|
5701
5794
|
var IMAGE_FORMAT_CONTENT_TYPES = {
|
|
5702
5795
|
jpeg: "image/jpeg",
|
|
5703
5796
|
png: "image/png",
|
|
@@ -5883,7 +5976,7 @@ async function transformImage(bytes, options) {
|
|
|
5883
5976
|
}
|
|
5884
5977
|
}
|
|
5885
5978
|
|
|
5886
|
-
// src/
|
|
5979
|
+
// src/runtime/storage/handler.ts
|
|
5887
5980
|
var MAX_SIGNED_URL_EXPIRY = 7 * 24 * 60 * 60;
|
|
5888
5981
|
function clampExpiry(expiresIn) {
|
|
5889
5982
|
if (!Number.isFinite(expiresIn) || expiresIn <= 0)
|
|
@@ -6930,7 +7023,7 @@ function parseTusMetadata(header) {
|
|
|
6930
7023
|
return out;
|
|
6931
7024
|
}
|
|
6932
7025
|
|
|
6933
|
-
// src/
|
|
7026
|
+
// src/runtime/net/service.ts
|
|
6934
7027
|
var MAX_RESPONSE_BYTES = 10 * 1024 * 1024;
|
|
6935
7028
|
var MAX_REDIRECTS = 5;
|
|
6936
7029
|
function blockedNetTarget(rawUrl) {
|
|
@@ -7127,7 +7220,7 @@ async function readCapped(res, maxBytes) {
|
|
|
7127
7220
|
return new TextDecoder().decode(merged);
|
|
7128
7221
|
}
|
|
7129
7222
|
|
|
7130
|
-
// src/
|
|
7223
|
+
// src/runtime/webhooks/service.ts
|
|
7131
7224
|
class WebhooksService {
|
|
7132
7225
|
db;
|
|
7133
7226
|
fetchImpl;
|
|
@@ -7215,7 +7308,7 @@ class WebhooksService {
|
|
|
7215
7308
|
}
|
|
7216
7309
|
}
|
|
7217
7310
|
|
|
7218
|
-
// src/
|
|
7311
|
+
// src/runtime/cron/service.ts
|
|
7219
7312
|
class CronService {
|
|
7220
7313
|
db;
|
|
7221
7314
|
tickMs;
|
|
@@ -7360,7 +7453,7 @@ function matchPart(part, value, min, max) {
|
|
|
7360
7453
|
return (value - lo) % step === 0;
|
|
7361
7454
|
}
|
|
7362
7455
|
|
|
7363
|
-
// src/
|
|
7456
|
+
// src/runtime/retention/service.ts
|
|
7364
7457
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
7365
7458
|
|
|
7366
7459
|
class RetentionService {
|
|
@@ -7434,7 +7527,7 @@ class RetentionService {
|
|
|
7434
7527
|
}
|
|
7435
7528
|
}
|
|
7436
7529
|
|
|
7437
|
-
// src/
|
|
7530
|
+
// src/runtime/security.ts
|
|
7438
7531
|
var LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "::1", "", undefined]);
|
|
7439
7532
|
function isNetworkExposed(host) {
|
|
7440
7533
|
return !LOOPBACK_HOSTS.has(host);
|
|
@@ -7458,7 +7551,7 @@ function assertSecretsSafe(input) {
|
|
|
7458
7551
|
warn("\u26A0 Vault key derived from the JWT secret - set an independent vaultKey before exposing this server.");
|
|
7459
7552
|
}
|
|
7460
7553
|
}
|
|
7461
|
-
// src/
|
|
7554
|
+
// src/runtime/gen-types.ts
|
|
7462
7555
|
var JSON_TYPE = "Json";
|
|
7463
7556
|
async function generateTypes(db, schema = "public") {
|
|
7464
7557
|
const enums = await loadEnums(db, schema);
|
|
@@ -7684,7 +7777,7 @@ async function loadFunctions(db, schema) {
|
|
|
7684
7777
|
args_json: parseIdentityArgs(r.identity_args)
|
|
7685
7778
|
}));
|
|
7686
7779
|
}
|
|
7687
|
-
// src/
|
|
7780
|
+
// src/runtime/db/schema-diff.ts
|
|
7688
7781
|
async function snapshotSchema(db, schema = "public") {
|
|
7689
7782
|
const cols = await db.query(`select c.relname as table, a.attname as column,
|
|
7690
7783
|
format_type(a.atttypid, a.atttypmod) as type,
|
|
@@ -7845,7 +7938,7 @@ function diffNamed(from, to, ops) {
|
|
|
7845
7938
|
}
|
|
7846
7939
|
}
|
|
7847
7940
|
}
|
|
7848
|
-
// src/
|
|
7941
|
+
// src/runtime/db/inspect.ts
|
|
7849
7942
|
async function inspectDb(db, schema = "public") {
|
|
7850
7943
|
const tables = await db.query(`select c.relname as table,
|
|
7851
7944
|
pg_size_pretty(pg_total_relation_size(c.oid)) as size
|
|
@@ -7861,7 +7954,7 @@ async function inspectDb(db, schema = "public") {
|
|
|
7861
7954
|
return out;
|
|
7862
7955
|
}
|
|
7863
7956
|
|
|
7864
|
-
// src/
|
|
7957
|
+
// src/runtime/index.ts
|
|
7865
7958
|
var CORS_HEADERS = {
|
|
7866
7959
|
"access-control-allow-origin": "*",
|
|
7867
7960
|
"access-control-allow-methods": "GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD",
|
|
@@ -8148,7 +8241,7 @@ function withCors(res) {
|
|
|
8148
8241
|
return res;
|
|
8149
8242
|
}
|
|
8150
8243
|
|
|
8151
|
-
// src/
|
|
8244
|
+
// src/runtime/node/db-diff.ts
|
|
8152
8245
|
import { mkdir as mkdir2, writeFile } from "fs/promises";
|
|
8153
8246
|
import { join } from "path";
|
|
8154
8247
|
async function computeDbDiff(opts) {
|
|
@@ -8235,7 +8328,7 @@ async function closeBackends(...backends) {
|
|
|
8235
8328
|
throw failed.reason;
|
|
8236
8329
|
}
|
|
8237
8330
|
|
|
8238
|
-
// src/
|
|
8331
|
+
// src/runtime/node/project.ts
|
|
8239
8332
|
import { readdir, readFile as readFile2 } from "fs/promises";
|
|
8240
8333
|
import { join as join2 } from "path";
|
|
8241
8334
|
async function loadSupabaseProject(projectDir, seed = {}) {
|
|
@@ -8284,7 +8377,7 @@ function isNotFound(error) {
|
|
|
8284
8377
|
import { chmod, link, lstat, mkdir as mkdir5, readFile as readFile6, realpath as realpath2, unlink as unlink3, writeFile as writeFile4 } from "fs/promises";
|
|
8285
8378
|
import { dirname as dirname3, isAbsolute, join as join7, parse, relative, resolve as resolve2 } from "path";
|
|
8286
8379
|
|
|
8287
|
-
// src/
|
|
8380
|
+
// src/runtime/node/bun-server.ts
|
|
8288
8381
|
async function serveBun(backend, opts = {}) {
|
|
8289
8382
|
const host = opts.host ?? "127.0.0.1";
|
|
8290
8383
|
const server = Bun.serve({
|
|
@@ -8331,7 +8424,7 @@ async function serveBun(backend, opts = {}) {
|
|
|
8331
8424
|
};
|
|
8332
8425
|
}
|
|
8333
8426
|
|
|
8334
|
-
// src/
|
|
8427
|
+
// src/runtime/node/fs-driver.ts
|
|
8335
8428
|
import { mkdir as mkdir3, readFile as readFile3, rename, rm, writeFile as writeFile2 } from "fs/promises";
|
|
8336
8429
|
import { dirname as dirname2, join as join3, normalize, sep } from "path";
|
|
8337
8430
|
|
|
@@ -8377,7 +8470,7 @@ class FsStorageDriver {
|
|
|
8377
8470
|
}
|
|
8378
8471
|
}
|
|
8379
8472
|
|
|
8380
|
-
// src/
|
|
8473
|
+
// src/runtime/node/config-toml.ts
|
|
8381
8474
|
import { readFileSync } from "fs";
|
|
8382
8475
|
import { join as join4 } from "path";
|
|
8383
8476
|
function emptyTable() {
|
|
@@ -8523,7 +8616,7 @@ function getByteSize(table, key) {
|
|
|
8523
8616
|
return Math.round(n * (mult[unit] ?? 1));
|
|
8524
8617
|
}
|
|
8525
8618
|
|
|
8526
|
-
// src/
|
|
8619
|
+
// src/runtime/node/load-config.ts
|
|
8527
8620
|
function loadProjectConfig(projectDir, env = process.env) {
|
|
8528
8621
|
const root = loadConfigToml(projectDir, env);
|
|
8529
8622
|
return {
|
|
@@ -8734,12 +8827,12 @@ function readFunctions(root) {
|
|
|
8734
8827
|
return out;
|
|
8735
8828
|
}
|
|
8736
8829
|
|
|
8737
|
-
// src/
|
|
8830
|
+
// src/runtime/node/load-functions.ts
|
|
8738
8831
|
import { readdir as readdir2, readFile as readFile5, realpath, rm as rm2, stat } from "fs/promises";
|
|
8739
8832
|
import { join as join6 } from "path";
|
|
8740
8833
|
import { pathToFileURL } from "url";
|
|
8741
8834
|
|
|
8742
|
-
// src/
|
|
8835
|
+
// src/runtime/node/bundle-function.ts
|
|
8743
8836
|
import { createHash } from "crypto";
|
|
8744
8837
|
import { mkdir as mkdir4, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
|
|
8745
8838
|
import { existsSync } from "fs";
|
|
@@ -8803,7 +8896,7 @@ async function bundleFunction(entryPath, name) {
|
|
|
8803
8896
|
return result.outputs[0].path;
|
|
8804
8897
|
}
|
|
8805
8898
|
|
|
8806
|
-
// src/
|
|
8899
|
+
// src/runtime/node/load-functions.ts
|
|
8807
8900
|
async function loadFunctionEnv(projectDir) {
|
|
8808
8901
|
let text;
|
|
8809
8902
|
try {
|
|
@@ -8906,7 +8999,7 @@ async function loadFunctionsUnlocked(projectDir, options) {
|
|
|
8906
8999
|
return functions;
|
|
8907
9000
|
}
|
|
8908
9001
|
|
|
8909
|
-
// src/
|
|
9002
|
+
// src/runtime/storage/s3-driver.ts
|
|
8910
9003
|
function normalizePath(value, label, allowEmpty) {
|
|
8911
9004
|
if (value.includes("\x00")) {
|
|
8912
9005
|
throw new TypeError(`${label} must not contain null bytes`);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { createBackend as createLiteBackend, createPgliteEngine, decodeJwt, generateTypes, inspectDb, signJwt, verifyJwt, } from './
|
|
2
|
-
export type { BackendConfig as SupaCloudLiteConfig,
|
|
3
|
-
export type { BucketSeed, Mailer, MailMessage, MigrationFile, RequestContext, StorageDriver, } from './
|
|
4
|
-
export { MemoryStorageDriver } from './
|
|
5
|
-
export { S3StorageDriver, type S3StorageClientLike, type S3StorageDriverOptions, type S3StorageFileLike, } from './
|
|
6
|
-
export type { EdgeFunction, FunctionContext } from './
|
|
7
|
-
export type { PgredisCacheBinding } from './
|
|
1
|
+
export { createBackend as createLiteBackend, createPgliteEngine, decodeJwt, generateTypes, inspectDb, signJwt, verifyJwt, } from './runtime/index.js';
|
|
2
|
+
export type { BackendConfig as SupaCloudLiteConfig, SupaCloudLiteBackend, } from './runtime/index.js';
|
|
3
|
+
export type { BucketSeed, Mailer, MailMessage, MigrationFile, RequestContext, StorageDriver, } from './runtime/types.js';
|
|
4
|
+
export { MemoryStorageDriver } from './runtime/storage/driver.js';
|
|
5
|
+
export { S3StorageDriver, type S3StorageClientLike, type S3StorageDriverOptions, type S3StorageFileLike, } from './runtime/storage/s3-driver.js';
|
|
6
|
+
export type { EdgeFunction, FunctionContext } from './runtime/functions/handler.js';
|
|
7
|
+
export type { PgredisCacheBinding } from './runtime/functions/pgredis.js';
|
|
8
8
|
export { SUPACLOUD_LITE_VERSION } from './version.js';
|
|
9
|
-
export { FsStorageDriver } from './
|
|
10
|
-
export { serveBun } from './
|
|
11
|
-
export type { RunningServer, ServerHandle, ServeOptions } from './
|
|
9
|
+
export { FsStorageDriver } from './runtime/node/fs-driver.js';
|
|
10
|
+
export { serveBun } from './runtime/node/bun-server.js';
|
|
11
|
+
export type { RunningServer, ServerHandle, ServeOptions } from './runtime/node/bun-server.js';
|
|
12
12
|
export { createProjectBackend, ensureProjectSecrets, mintProjectKeys, resolveStorageBackend, resolveProjectPaths, startProjectServer, } from './project-runtime.js';
|
|
13
13
|
export { createSnapshot, restoreSnapshot, type CreateSnapshotOptions, type RestoreSnapshotOptions, type RestoreSnapshotResult, type SnapshotManifest, } from './snapshot.js';
|
|
14
14
|
export type { ConfiguredStorageBackend, ProjectBackend, ProjectPaths, ProjectRuntimeOptions, ProjectSecrets, RunningProjectServer, StorageBackend, } from './project-runtime.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,IAAI,iBAAiB,EAClC,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,SAAS,EACT,OAAO,EACP,SAAS,GACV,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,IAAI,iBAAiB,EAClC,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,SAAS,EACT,OAAO,EACP,SAAS,GACV,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EACV,aAAa,IAAI,mBAAmB,EACpC,oBAAoB,GACrB,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EACV,UAAU,EACV,MAAM,EACN,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,GACd,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,GACvB,MAAM,gCAAgC,CAAA;AACvC,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AACnF,YAAY,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvD,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC7F,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,cAAc,EACd,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,cAAc,GACf,MAAM,sBAAsB,CAAA"}
|