@supacloud/lite 0.5.6 → 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 +7 -0
- package/README.md +2 -2
- 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/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var __require = import.meta.require;
|
|
3
3
|
|
|
4
|
-
// src/
|
|
4
|
+
// src/runtime/jwt.ts
|
|
5
5
|
var encoder = new TextEncoder;
|
|
6
6
|
var decoder = new TextDecoder;
|
|
7
7
|
function bytesToBase64Url(bytes) {
|
|
@@ -71,7 +71,7 @@ function randomToken(bytes = 32) {
|
|
|
71
71
|
// package.json
|
|
72
72
|
var package_default = {
|
|
73
73
|
name: "@supacloud/lite",
|
|
74
|
-
version: "0.5.
|
|
74
|
+
version: "0.5.7",
|
|
75
75
|
description: "Bun-native, single-project Supabase-compatible backend powered by PGlite",
|
|
76
76
|
type: "module",
|
|
77
77
|
license: "Apache-2.0",
|
|
@@ -96,7 +96,7 @@ var package_default = {
|
|
|
96
96
|
],
|
|
97
97
|
scripts: {
|
|
98
98
|
build: "bun run build:js && bun run build:types",
|
|
99
|
-
"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",
|
|
99
|
+
"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",
|
|
100
100
|
"build:standalone:host": "bun run scripts/build-standalone.ts host",
|
|
101
101
|
"build:standalone:linux": "bun run scripts/build-standalone.ts linux-x64 linux-arm64",
|
|
102
102
|
"build:standalone:macos": "bun run scripts/build-standalone.ts macos-x64 macos-arm64",
|
|
@@ -104,6 +104,7 @@ var package_default = {
|
|
|
104
104
|
"build:standalone:release": "bun run scripts/build-standalone.ts linux-x64 linux-arm64 macos-x64 macos-arm64 windows-x64",
|
|
105
105
|
"build:types": "bun x tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
106
106
|
check: "bun run typecheck && bun run test && bun run build && bun run test:package && bun run build:standalone:host && bun run test:standalone",
|
|
107
|
+
clean: `bun -e "import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true })"`,
|
|
107
108
|
dev: "bun run src/cli.ts start",
|
|
108
109
|
start: "bun run src/cli.ts start",
|
|
109
110
|
test: "bun test --timeout 20000",
|
|
@@ -145,7 +146,7 @@ var package_default = {
|
|
|
145
146
|
// src/version.ts
|
|
146
147
|
var SUPACLOUD_LITE_VERSION = package_default.version;
|
|
147
148
|
|
|
148
|
-
// src/
|
|
149
|
+
// src/runtime/auth/redirect.ts
|
|
149
150
|
function globToRegExp(pattern) {
|
|
150
151
|
let out = "";
|
|
151
152
|
for (let i = 0;i < pattern.length; i++) {
|
|
@@ -194,7 +195,7 @@ function isAllowedRedirect(requested, siteUrl, allowList = []) {
|
|
|
194
195
|
return allowList.some((entry) => globToRegExp(entry).test(requested));
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
// src/
|
|
198
|
+
// src/runtime/auth/oauth.ts
|
|
198
199
|
var PRESETS = {
|
|
199
200
|
google: {
|
|
200
201
|
authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
|
|
@@ -415,7 +416,7 @@ function base64url(bytes) {
|
|
|
415
416
|
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
416
417
|
}
|
|
417
418
|
|
|
418
|
-
// src/
|
|
419
|
+
// src/runtime/auth/password.ts
|
|
419
420
|
function toHex(bytes) {
|
|
420
421
|
return [...bytes].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
421
422
|
}
|
|
@@ -470,7 +471,7 @@ async function verifyPassword(password, stored) {
|
|
|
470
471
|
return diff === 0;
|
|
471
472
|
}
|
|
472
473
|
|
|
473
|
-
// src/
|
|
474
|
+
// src/runtime/auth/qr.ts
|
|
474
475
|
var ECC_M = { ordinal: 0, formatBits: 0 };
|
|
475
476
|
var ECC_CODEWORDS_PER_BLOCK = [
|
|
476
477
|
-1,
|
|
@@ -905,7 +906,7 @@ function qrSvgDataUri(text) {
|
|
|
905
906
|
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
|
|
906
907
|
}
|
|
907
908
|
|
|
908
|
-
// src/
|
|
909
|
+
// src/runtime/auth/settings.ts
|
|
909
910
|
var DEFAULT_AUTH_SETTINGS = {
|
|
910
911
|
disableSignup: false,
|
|
911
912
|
anonymousUsers: true,
|
|
@@ -958,7 +959,7 @@ async function loadAuthSettings(db, defaults = {}) {
|
|
|
958
959
|
}
|
|
959
960
|
}
|
|
960
961
|
|
|
961
|
-
// src/
|
|
962
|
+
// src/runtime/auth/rate-limit.ts
|
|
962
963
|
var DEFAULT_AUTH_RATE_LIMITS = {
|
|
963
964
|
token: { limit: 30, windowMs: 5 * 60 * 1000 },
|
|
964
965
|
signup: { limit: 30, windowMs: 60 * 60 * 1000 },
|
|
@@ -1003,7 +1004,7 @@ class RateLimiter {
|
|
|
1003
1004
|
}
|
|
1004
1005
|
}
|
|
1005
1006
|
|
|
1006
|
-
// src/
|
|
1007
|
+
// src/runtime/auth/totp.ts
|
|
1007
1008
|
var B32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
1008
1009
|
function base32Encode(bytes) {
|
|
1009
1010
|
let bits = 0;
|
|
@@ -1081,7 +1082,7 @@ async function verifyTotp(secretBase32, code, window = 1, atMs = Date.now()) {
|
|
|
1081
1082
|
return false;
|
|
1082
1083
|
}
|
|
1083
1084
|
|
|
1084
|
-
// src/
|
|
1085
|
+
// src/runtime/auth/handler.ts
|
|
1085
1086
|
function authError(status, errorCode, msg) {
|
|
1086
1087
|
return json(status, { code: status, error_code: errorCode, msg });
|
|
1087
1088
|
}
|
|
@@ -1833,7 +1834,7 @@ Or sign in with this link: ${link}`
|
|
|
1833
1834
|
}
|
|
1834
1835
|
}
|
|
1835
1836
|
|
|
1836
|
-
// src/
|
|
1837
|
+
// src/runtime/auth/inbox.ts
|
|
1837
1838
|
var CAP = 200;
|
|
1838
1839
|
|
|
1839
1840
|
class InboxMailer {
|
|
@@ -1945,7 +1946,7 @@ var INBOX_HTML = `<!doctype html>
|
|
|
1945
1946
|
</body>
|
|
1946
1947
|
</html>`;
|
|
1947
1948
|
|
|
1948
|
-
// src/
|
|
1949
|
+
// src/runtime/log-buffer.ts
|
|
1949
1950
|
class LogBuffer {
|
|
1950
1951
|
cap;
|
|
1951
1952
|
entries = [];
|
|
@@ -1965,7 +1966,7 @@ class LogBuffer {
|
|
|
1965
1966
|
}
|
|
1966
1967
|
}
|
|
1967
1968
|
|
|
1968
|
-
// src/
|
|
1969
|
+
// src/runtime/functions/deno-shim.ts
|
|
1969
1970
|
import { AsyncLocalStorage } from "async_hooks";
|
|
1970
1971
|
var captured = {};
|
|
1971
1972
|
var envStore = new AsyncLocalStorage;
|
|
@@ -1974,11 +1975,11 @@ function runWithDenoEnv(env, fn) {
|
|
|
1974
1975
|
}
|
|
1975
1976
|
function installDenoShim() {
|
|
1976
1977
|
const g = globalThis;
|
|
1977
|
-
if (g.
|
|
1978
|
+
if (g.__supacloudLiteDeno)
|
|
1978
1979
|
return;
|
|
1979
1980
|
if (g.Deno && typeof g.Deno.serve === "function")
|
|
1980
1981
|
return;
|
|
1981
|
-
g.
|
|
1982
|
+
g.__supacloudLiteDeno = true;
|
|
1982
1983
|
g.Deno = {
|
|
1983
1984
|
serve(arg1, arg2) {
|
|
1984
1985
|
captured.handler = typeof arg1 === "function" ? arg1 : arg2;
|
|
@@ -2014,7 +2015,7 @@ function resetCapturedHandler() {
|
|
|
2014
2015
|
captured.handler = undefined;
|
|
2015
2016
|
}
|
|
2016
2017
|
|
|
2017
|
-
// src/
|
|
2018
|
+
// src/runtime/functions/pgredis.ts
|
|
2018
2019
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
2019
2020
|
var CACHE_NAMESPACE = "supacloud-edge-runtime";
|
|
2020
2021
|
var CACHE_TABLE = "public.supacloud_pgredis_kv";
|
|
@@ -2181,7 +2182,7 @@ async function upsertWithoutTtl(query, key, serializedValue) {
|
|
|
2181
2182
|
on conflict (namespace, key) do update set value = excluded.value, expires_at = null, updated_at = now()`, [CACHE_NAMESPACE, key, serializedValue]);
|
|
2182
2183
|
}
|
|
2183
2184
|
|
|
2184
|
-
// src/
|
|
2185
|
+
// src/runtime/functions/handler.ts
|
|
2185
2186
|
class FunctionsHandler {
|
|
2186
2187
|
functions;
|
|
2187
2188
|
env;
|
|
@@ -2226,7 +2227,7 @@ function json2(status, body) {
|
|
|
2226
2227
|
});
|
|
2227
2228
|
}
|
|
2228
2229
|
|
|
2229
|
-
// src/
|
|
2230
|
+
// src/runtime/db/bootstrap.ts
|
|
2230
2231
|
var MINIMAL_BOOTSTRAP_SQL = `
|
|
2231
2232
|
create schema if not exists auth;
|
|
2232
2233
|
create schema if not exists storage;
|
|
@@ -2650,8 +2651,22 @@ $$;
|
|
|
2650
2651
|
|
|
2651
2652
|
alter table storage.objects enable row level security;
|
|
2652
2653
|
|
|
2653
|
-
drop policy if exists
|
|
2654
|
-
drop policy if exists
|
|
2654
|
+
drop policy if exists supacloud_lite_authenticated_all on storage.objects;
|
|
2655
|
+
drop policy if exists supacloud_lite_public_read on storage.objects;
|
|
2656
|
+
|
|
2657
|
+
do $legacy_policy_cleanup$
|
|
2658
|
+
declare
|
|
2659
|
+
legacy_prefix constant text := 'tin' || 'base';
|
|
2660
|
+
begin
|
|
2661
|
+
execute format(
|
|
2662
|
+
'drop policy if exists %I on storage.objects',
|
|
2663
|
+
legacy_prefix || '_authenticated_all'
|
|
2664
|
+
);
|
|
2665
|
+
execute format(
|
|
2666
|
+
'drop policy if exists %I on storage.objects',
|
|
2667
|
+
legacy_prefix || '_public_read'
|
|
2668
|
+
);
|
|
2669
|
+
end $legacy_policy_cleanup$;
|
|
2655
2670
|
|
|
2656
2671
|
-- \u2500\u2500 Migration bookkeeping (same table the Supabase CLI uses) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
2657
2672
|
create schema if not exists supabase_migrations;
|
|
@@ -2670,9 +2685,19 @@ create table if not exists supabase_migrations.seed_files (
|
|
|
2670
2685
|
);
|
|
2671
2686
|
|
|
2672
2687
|
-- \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
|
|
2673
|
-
|
|
2688
|
+
do $legacy_schema_upgrade$
|
|
2689
|
+
declare
|
|
2690
|
+
legacy_schema constant text := 'tin' || 'base';
|
|
2691
|
+
begin
|
|
2692
|
+
if exists (select 1 from pg_namespace where nspname = legacy_schema)
|
|
2693
|
+
and not exists (select 1 from pg_namespace where nspname = 'supacloud_lite') then
|
|
2694
|
+
execute format('alter schema %I rename to supacloud_lite', legacy_schema);
|
|
2695
|
+
end if;
|
|
2696
|
+
end $legacy_schema_upgrade$;
|
|
2697
|
+
|
|
2698
|
+
create schema if not exists supacloud_lite;
|
|
2674
2699
|
|
|
2675
|
-
create or replace function
|
|
2700
|
+
create or replace function supacloud_lite.cdc_notify() returns trigger
|
|
2676
2701
|
language plpgsql security definer as $$
|
|
2677
2702
|
declare
|
|
2678
2703
|
payload text;
|
|
@@ -2697,10 +2722,78 @@ begin
|
|
|
2697
2722
|
'errors', json_build_array('Payload too large')
|
|
2698
2723
|
)::text;
|
|
2699
2724
|
end if;
|
|
2700
|
-
perform pg_notify('
|
|
2725
|
+
perform pg_notify('supacloud_lite_cdc', payload);
|
|
2701
2726
|
return coalesce(NEW, OLD);
|
|
2702
2727
|
end $$;
|
|
2703
2728
|
|
|
2729
|
+
do $legacy_trigger_upgrade$
|
|
2730
|
+
declare
|
|
2731
|
+
legacy_schema constant text := 'tin' || 'base';
|
|
2732
|
+
legacy_trigger constant text := ('tin' || 'base') || '_cdc';
|
|
2733
|
+
trigger_record record;
|
|
2734
|
+
target_exists boolean;
|
|
2735
|
+
begin
|
|
2736
|
+
for trigger_record in
|
|
2737
|
+
select c.oid as relation_oid, n.nspname as schema_name, c.relname as table_name
|
|
2738
|
+
from pg_trigger tg
|
|
2739
|
+
join pg_class c on c.oid = tg.tgrelid
|
|
2740
|
+
join pg_namespace n on n.oid = c.relnamespace
|
|
2741
|
+
join pg_proc p on p.oid = tg.tgfoid
|
|
2742
|
+
join pg_namespace pn on pn.oid = p.pronamespace
|
|
2743
|
+
where not tg.tgisinternal
|
|
2744
|
+
and tg.tgname = legacy_trigger
|
|
2745
|
+
and p.proname = 'cdc_notify'
|
|
2746
|
+
and pn.nspname in (legacy_schema, 'supacloud_lite')
|
|
2747
|
+
loop
|
|
2748
|
+
select exists (
|
|
2749
|
+
select 1
|
|
2750
|
+
from pg_trigger
|
|
2751
|
+
where not tgisinternal
|
|
2752
|
+
and tgrelid = trigger_record.relation_oid
|
|
2753
|
+
and tgname = 'supacloud_lite_cdc'
|
|
2754
|
+
) into target_exists;
|
|
2755
|
+
|
|
2756
|
+
execute format(
|
|
2757
|
+
'drop trigger %I on %I.%I',
|
|
2758
|
+
legacy_trigger,
|
|
2759
|
+
trigger_record.schema_name,
|
|
2760
|
+
trigger_record.table_name
|
|
2761
|
+
);
|
|
2762
|
+
|
|
2763
|
+
if not target_exists then
|
|
2764
|
+
execute format(
|
|
2765
|
+
'create trigger supacloud_lite_cdc after insert or update or delete on %I.%I for each row execute function supacloud_lite.cdc_notify()',
|
|
2766
|
+
trigger_record.schema_name,
|
|
2767
|
+
trigger_record.table_name
|
|
2768
|
+
);
|
|
2769
|
+
end if;
|
|
2770
|
+
end loop;
|
|
2771
|
+
end $legacy_trigger_upgrade$;
|
|
2772
|
+
|
|
2773
|
+
do $legacy_schema_cleanup$
|
|
2774
|
+
declare
|
|
2775
|
+
legacy_schema constant text := 'tin' || 'base';
|
|
2776
|
+
begin
|
|
2777
|
+
if exists (
|
|
2778
|
+
select 1
|
|
2779
|
+
from pg_proc p
|
|
2780
|
+
join pg_namespace n on n.oid = p.pronamespace
|
|
2781
|
+
where n.nspname = legacy_schema
|
|
2782
|
+
and p.proname = 'cdc_notify'
|
|
2783
|
+
and p.pronargs = 0
|
|
2784
|
+
) then
|
|
2785
|
+
execute format('drop function %I.cdc_notify()', legacy_schema);
|
|
2786
|
+
end if;
|
|
2787
|
+
|
|
2788
|
+
if exists (select 1 from pg_namespace where nspname = legacy_schema) then
|
|
2789
|
+
begin
|
|
2790
|
+
execute format('drop schema %I', legacy_schema);
|
|
2791
|
+
exception when dependent_objects_still_exist then
|
|
2792
|
+
raise notice 'SupaCloud Lite: retained non-empty legacy runtime schema';
|
|
2793
|
+
end;
|
|
2794
|
+
end if;
|
|
2795
|
+
end $legacy_schema_cleanup$;
|
|
2796
|
+
|
|
2704
2797
|
-- \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
|
|
2705
2798
|
-- Mirrors Supabase Realtime: developers write RLS policies on
|
|
2706
2799
|
-- realtime.messages using realtime.topic(); a SELECT policy grants a private
|
|
@@ -2730,12 +2823,12 @@ create or replace function realtime.topic() returns text
|
|
|
2730
2823
|
|
|
2731
2824
|
-- push a broadcast message to all subscribers of <topic> from SQL / triggers.
|
|
2732
2825
|
-- Delivered over the websocket by the in-process realtime engine, which listens
|
|
2733
|
-
-- on the '
|
|
2826
|
+
-- on the 'supacloud_lite_realtime_broadcast' channel.
|
|
2734
2827
|
create or replace function realtime.send(payload jsonb, event text, topic text, private boolean default true)
|
|
2735
2828
|
returns void language plpgsql security definer as $$
|
|
2736
2829
|
begin
|
|
2737
2830
|
perform pg_notify(
|
|
2738
|
-
'
|
|
2831
|
+
'supacloud_lite_realtime_broadcast',
|
|
2739
2832
|
json_build_object('topic', topic, 'event', event, 'payload', payload, 'private', private)::text
|
|
2740
2833
|
);
|
|
2741
2834
|
exception when others then
|
|
@@ -2747,7 +2840,7 @@ grant execute on function realtime.topic() to anon, authenticated, service_role;
|
|
|
2747
2840
|
grant execute on function realtime.send(jsonb, text, text, boolean) to anon, authenticated, service_role;
|
|
2748
2841
|
`;
|
|
2749
2842
|
|
|
2750
|
-
// src/
|
|
2843
|
+
// src/runtime/db/emulated.ts
|
|
2751
2844
|
var PGMQ_SQL = `
|
|
2752
2845
|
create schema if not exists pgmq;
|
|
2753
2846
|
revoke all on schema pgmq from public, anon, authenticated;
|
|
@@ -3198,7 +3291,7 @@ end $vault$;
|
|
|
3198
3291
|
grant execute on function vault.create_secret(text,text,text,uuid), vault.update_secret(uuid,text,text,text,uuid) to service_role;
|
|
3199
3292
|
`;
|
|
3200
3293
|
|
|
3201
|
-
// src/
|
|
3294
|
+
// src/runtime/db/sql-compat.ts
|
|
3202
3295
|
function rewriteMigrationSql(sql) {
|
|
3203
3296
|
const out = [];
|
|
3204
3297
|
const n = sql.length;
|
|
@@ -3279,7 +3372,7 @@ function rewriteStatement(stmt) {
|
|
|
3279
3372
|
return stmt;
|
|
3280
3373
|
const inner = pickTag(bare, "tb_ext_stmt");
|
|
3281
3374
|
const outer = pickTag(bare, "tb_ext");
|
|
3282
|
-
return `${trivia}DO ${outer} BEGIN EXECUTE ${inner}${bare}${inner}; ` + `EXCEPTION WHEN OTHERS THEN RAISE NOTICE '
|
|
3375
|
+
return `${trivia}DO ${outer} BEGIN EXECUTE ${inner}${bare}${inner}; ` + `EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'SupaCloud Lite: skipped extension statement (%)', SQLERRM; END ${outer};`;
|
|
3283
3376
|
}
|
|
3284
3377
|
if (/^(?:create\s+(?:unique\s+)?index|drop\s+index|reindex)\b/i.test(rest)) {
|
|
3285
3378
|
return trivia + rest.replace(/\s+concurrently\b/i, " ");
|
|
@@ -3294,11 +3387,11 @@ function pickTag(text, base) {
|
|
|
3294
3387
|
return tag;
|
|
3295
3388
|
}
|
|
3296
3389
|
|
|
3297
|
-
// src/
|
|
3390
|
+
// src/runtime/db/pglite-engine.ts
|
|
3298
3391
|
import { mkdir, open, unlink as unlink2 } from "fs/promises";
|
|
3299
3392
|
import { dirname, resolve } from "path";
|
|
3300
3393
|
|
|
3301
|
-
// src/
|
|
3394
|
+
// src/runtime/db/data-dir-lock.ts
|
|
3302
3395
|
import { readFile, unlink } from "fs/promises";
|
|
3303
3396
|
async function recoverStaleDataDirLock(lockPath) {
|
|
3304
3397
|
const lockState = await inspectDataDirLock(lockPath);
|
|
@@ -3349,7 +3442,7 @@ function isProcessAlive(pid) {
|
|
|
3349
3442
|
// src/standalone-assets-protocol.ts
|
|
3350
3443
|
var STANDALONE_PGLITE_ASSETS = Symbol.for("supacloud-lite.pglite-standalone-assets");
|
|
3351
3444
|
|
|
3352
|
-
// src/
|
|
3445
|
+
// src/runtime/db/pglite-engine.ts
|
|
3353
3446
|
async function createPgliteEngine(dataDir) {
|
|
3354
3447
|
const releaseLock = await acquireDataDirLock(dataDir);
|
|
3355
3448
|
let PGlite, extensions;
|
|
@@ -3524,7 +3617,7 @@ function unreadableLockError(lockPath) {
|
|
|
3524
3617
|
return new Error(`PGlite data directory has an unreadable lock: ${lockPath}. Confirm no SupaCloud Lite process is using it, then remove the lock manually.`);
|
|
3525
3618
|
}
|
|
3526
3619
|
|
|
3527
|
-
// src/
|
|
3620
|
+
// src/runtime/db/database.ts
|
|
3528
3621
|
var DEFAULT_SEARCH_PATH_SQL = `set search_path to "$user", public, extensions`;
|
|
3529
3622
|
|
|
3530
3623
|
class Database {
|
|
@@ -3768,13 +3861,13 @@ class Database {
|
|
|
3768
3861
|
select from pg_trigger tg
|
|
3769
3862
|
join pg_class c on c.oid = tg.tgrelid
|
|
3770
3863
|
join pg_namespace n on n.oid = c.relnamespace
|
|
3771
|
-
where tg.tgname = '
|
|
3864
|
+
where tg.tgname = 'supacloud_lite_cdc'
|
|
3772
3865
|
and n.nspname = ${quoteLiteral(schema)}
|
|
3773
3866
|
and c.relname = ${quoteLiteral(table)}
|
|
3774
3867
|
) then
|
|
3775
|
-
create trigger
|
|
3868
|
+
create trigger supacloud_lite_cdc
|
|
3776
3869
|
after insert or update or delete on ${s}.${t}
|
|
3777
|
-
for each row execute function
|
|
3870
|
+
for each row execute function supacloud_lite.cdc_notify();
|
|
3778
3871
|
end if;
|
|
3779
3872
|
end $$;
|
|
3780
3873
|
`);
|
|
@@ -3808,7 +3901,7 @@ class Database {
|
|
|
3808
3901
|
}
|
|
3809
3902
|
}
|
|
3810
3903
|
async attachCdcListener() {
|
|
3811
|
-
this.cdcUnsubscribe = await this.engine.listen("
|
|
3904
|
+
this.cdcUnsubscribe = await this.engine.listen("supacloud_lite_cdc", (payload) => {
|
|
3812
3905
|
try {
|
|
3813
3906
|
const event = JSON.parse(payload);
|
|
3814
3907
|
for (const listener of this.cdcListeners)
|
|
@@ -3896,7 +3989,7 @@ async function sha256Hex(text) {
|
|
|
3896
3989
|
return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
3897
3990
|
}
|
|
3898
3991
|
|
|
3899
|
-
// src/
|
|
3992
|
+
// src/runtime/realtime/engine.ts
|
|
3900
3993
|
class RealtimeEngine {
|
|
3901
3994
|
db;
|
|
3902
3995
|
jwtSecret;
|
|
@@ -3961,7 +4054,7 @@ class RealtimeEngine {
|
|
|
3961
4054
|
if (this.stopCdc)
|
|
3962
4055
|
return;
|
|
3963
4056
|
this.stopCdc = await this.db.onCdcEvent((e) => this.dispatchCdc(e));
|
|
3964
|
-
this.stopDbBroadcast = await this.db.engine.listen("
|
|
4057
|
+
this.stopDbBroadcast = await this.db.engine.listen("supacloud_lite_realtime_broadcast", (payload) => {
|
|
3965
4058
|
try {
|
|
3966
4059
|
this.dispatchDbBroadcast(JSON.parse(payload));
|
|
3967
4060
|
} catch {}
|
|
@@ -4433,7 +4526,7 @@ function encodeUserBroadcast(topic, event, payload) {
|
|
|
4433
4526
|
return out;
|
|
4434
4527
|
}
|
|
4435
4528
|
|
|
4436
|
-
// src/
|
|
4529
|
+
// src/runtime/types.ts
|
|
4437
4530
|
var DEFAULT_JWT_SECRET = "";
|
|
4438
4531
|
|
|
4439
4532
|
class ApiError extends Error {
|
|
@@ -4446,7 +4539,7 @@ class ApiError extends Error {
|
|
|
4446
4539
|
}
|
|
4447
4540
|
}
|
|
4448
4541
|
|
|
4449
|
-
// src/
|
|
4542
|
+
// src/runtime/rest/parse.ts
|
|
4450
4543
|
class ParseError extends Error {
|
|
4451
4544
|
}
|
|
4452
4545
|
var RESERVED = new Set(["select", "order", "limit", "offset", "on_conflict", "columns"]);
|
|
@@ -4720,7 +4813,7 @@ function findAliasColon(item) {
|
|
|
4720
4813
|
return -1;
|
|
4721
4814
|
}
|
|
4722
4815
|
|
|
4723
|
-
// src/
|
|
4816
|
+
// src/runtime/rest/build.ts
|
|
4724
4817
|
var AGG_EMPTY = `'[]'::json`;
|
|
4725
4818
|
|
|
4726
4819
|
class QueryBuilder {
|
|
@@ -5228,7 +5321,7 @@ function renderFilter(f, alias) {
|
|
|
5228
5321
|
return f.negated ? `not (${expr})` : expr;
|
|
5229
5322
|
}
|
|
5230
5323
|
|
|
5231
|
-
// src/
|
|
5324
|
+
// src/runtime/rest/errors.ts
|
|
5232
5325
|
function statusForSqlState(code) {
|
|
5233
5326
|
switch (code) {
|
|
5234
5327
|
case "42501":
|
|
@@ -5274,7 +5367,7 @@ function jsonResponse(status, body, headers = {}) {
|
|
|
5274
5367
|
});
|
|
5275
5368
|
}
|
|
5276
5369
|
|
|
5277
|
-
// src/
|
|
5370
|
+
// src/runtime/rest/handler.ts
|
|
5278
5371
|
function parsePrefer(header) {
|
|
5279
5372
|
const prefer = {};
|
|
5280
5373
|
if (!header)
|
|
@@ -5684,7 +5777,7 @@ async function readJsonBody(req) {
|
|
|
5684
5777
|
}
|
|
5685
5778
|
}
|
|
5686
5779
|
|
|
5687
|
-
// src/
|
|
5780
|
+
// src/runtime/storage/driver.ts
|
|
5688
5781
|
class MemoryStorageDriver {
|
|
5689
5782
|
files = new Map;
|
|
5690
5783
|
async put(key, data) {
|
|
@@ -5702,7 +5795,7 @@ class MemoryStorageDriver {
|
|
|
5702
5795
|
}
|
|
5703
5796
|
}
|
|
5704
5797
|
|
|
5705
|
-
// src/
|
|
5798
|
+
// src/runtime/storage/image-transform.ts
|
|
5706
5799
|
var IMAGE_FORMAT_CONTENT_TYPES = {
|
|
5707
5800
|
jpeg: "image/jpeg",
|
|
5708
5801
|
png: "image/png",
|
|
@@ -5888,7 +5981,7 @@ async function transformImage(bytes, options) {
|
|
|
5888
5981
|
}
|
|
5889
5982
|
}
|
|
5890
5983
|
|
|
5891
|
-
// src/
|
|
5984
|
+
// src/runtime/storage/handler.ts
|
|
5892
5985
|
var MAX_SIGNED_URL_EXPIRY = 7 * 24 * 60 * 60;
|
|
5893
5986
|
function clampExpiry(expiresIn) {
|
|
5894
5987
|
if (!Number.isFinite(expiresIn) || expiresIn <= 0)
|
|
@@ -6935,7 +7028,7 @@ function parseTusMetadata(header) {
|
|
|
6935
7028
|
return out;
|
|
6936
7029
|
}
|
|
6937
7030
|
|
|
6938
|
-
// src/
|
|
7031
|
+
// src/runtime/net/service.ts
|
|
6939
7032
|
var MAX_RESPONSE_BYTES = 10 * 1024 * 1024;
|
|
6940
7033
|
var MAX_REDIRECTS = 5;
|
|
6941
7034
|
function blockedNetTarget(rawUrl) {
|
|
@@ -7132,7 +7225,7 @@ async function readCapped(res, maxBytes) {
|
|
|
7132
7225
|
return new TextDecoder().decode(merged);
|
|
7133
7226
|
}
|
|
7134
7227
|
|
|
7135
|
-
// src/
|
|
7228
|
+
// src/runtime/webhooks/service.ts
|
|
7136
7229
|
class WebhooksService {
|
|
7137
7230
|
db;
|
|
7138
7231
|
fetchImpl;
|
|
@@ -7220,7 +7313,7 @@ class WebhooksService {
|
|
|
7220
7313
|
}
|
|
7221
7314
|
}
|
|
7222
7315
|
|
|
7223
|
-
// src/
|
|
7316
|
+
// src/runtime/cron/service.ts
|
|
7224
7317
|
class CronService {
|
|
7225
7318
|
db;
|
|
7226
7319
|
tickMs;
|
|
@@ -7365,7 +7458,7 @@ function matchPart(part, value, min, max) {
|
|
|
7365
7458
|
return (value - lo) % step === 0;
|
|
7366
7459
|
}
|
|
7367
7460
|
|
|
7368
|
-
// src/
|
|
7461
|
+
// src/runtime/retention/service.ts
|
|
7369
7462
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
7370
7463
|
|
|
7371
7464
|
class RetentionService {
|
|
@@ -7439,7 +7532,7 @@ class RetentionService {
|
|
|
7439
7532
|
}
|
|
7440
7533
|
}
|
|
7441
7534
|
|
|
7442
|
-
// src/
|
|
7535
|
+
// src/runtime/security.ts
|
|
7443
7536
|
var LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "::1", "", undefined]);
|
|
7444
7537
|
function isNetworkExposed(host) {
|
|
7445
7538
|
return !LOOPBACK_HOSTS.has(host);
|
|
@@ -7463,7 +7556,7 @@ function assertSecretsSafe(input) {
|
|
|
7463
7556
|
warn("\u26A0 Vault key derived from the JWT secret - set an independent vaultKey before exposing this server.");
|
|
7464
7557
|
}
|
|
7465
7558
|
}
|
|
7466
|
-
// src/
|
|
7559
|
+
// src/runtime/gen-types.ts
|
|
7467
7560
|
var JSON_TYPE = "Json";
|
|
7468
7561
|
async function generateTypes(db, schema = "public") {
|
|
7469
7562
|
const enums = await loadEnums(db, schema);
|
|
@@ -7689,7 +7782,7 @@ async function loadFunctions(db, schema) {
|
|
|
7689
7782
|
args_json: parseIdentityArgs(r.identity_args)
|
|
7690
7783
|
}));
|
|
7691
7784
|
}
|
|
7692
|
-
// src/
|
|
7785
|
+
// src/runtime/db/inspect.ts
|
|
7693
7786
|
async function inspectDb(db, schema = "public") {
|
|
7694
7787
|
const tables = await db.query(`select c.relname as table,
|
|
7695
7788
|
pg_size_pretty(pg_total_relation_size(c.oid)) as size
|
|
@@ -7705,7 +7798,7 @@ async function inspectDb(db, schema = "public") {
|
|
|
7705
7798
|
return out;
|
|
7706
7799
|
}
|
|
7707
7800
|
|
|
7708
|
-
// src/
|
|
7801
|
+
// src/runtime/index.ts
|
|
7709
7802
|
var CORS_HEADERS = {
|
|
7710
7803
|
"access-control-allow-origin": "*",
|
|
7711
7804
|
"access-control-allow-methods": "GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD",
|
|
@@ -7991,7 +8084,7 @@ function withCors(res) {
|
|
|
7991
8084
|
}
|
|
7992
8085
|
return res;
|
|
7993
8086
|
}
|
|
7994
|
-
// src/
|
|
8087
|
+
// src/runtime/storage/s3-driver.ts
|
|
7995
8088
|
function normalizePath(value, label, allowEmpty) {
|
|
7996
8089
|
if (value.includes("\x00")) {
|
|
7997
8090
|
throw new TypeError(`${label} must not contain null bytes`);
|
|
@@ -8069,7 +8162,7 @@ class S3StorageDriver {
|
|
|
8069
8162
|
return `${this.prefix}${normalizeKey(key)}`;
|
|
8070
8163
|
}
|
|
8071
8164
|
}
|
|
8072
|
-
// src/
|
|
8165
|
+
// src/runtime/node/fs-driver.ts
|
|
8073
8166
|
import { mkdir as mkdir2, readFile as readFile2, rename, rm, writeFile } from "fs/promises";
|
|
8074
8167
|
import { dirname as dirname2, join, normalize, sep } from "path";
|
|
8075
8168
|
|
|
@@ -8114,7 +8207,7 @@ class FsStorageDriver {
|
|
|
8114
8207
|
await this.delete(k);
|
|
8115
8208
|
}
|
|
8116
8209
|
}
|
|
8117
|
-
// src/
|
|
8210
|
+
// src/runtime/node/bun-server.ts
|
|
8118
8211
|
async function serveBun(backend, opts = {}) {
|
|
8119
8212
|
const host = opts.host ?? "127.0.0.1";
|
|
8120
8213
|
const server = Bun.serve({
|
|
@@ -8164,7 +8257,7 @@ async function serveBun(backend, opts = {}) {
|
|
|
8164
8257
|
import { chmod, link, lstat, mkdir as mkdir4, readFile as readFile6, realpath as realpath2, unlink as unlink3, writeFile as writeFile3 } from "fs/promises";
|
|
8165
8258
|
import { dirname as dirname3, isAbsolute, join as join6, parse, relative, resolve as resolve2 } from "path";
|
|
8166
8259
|
|
|
8167
|
-
// src/
|
|
8260
|
+
// src/runtime/node/config-toml.ts
|
|
8168
8261
|
import { readFileSync } from "fs";
|
|
8169
8262
|
import { join as join2 } from "path";
|
|
8170
8263
|
function emptyTable() {
|
|
@@ -8310,7 +8403,7 @@ function getByteSize(table, key) {
|
|
|
8310
8403
|
return Math.round(n * (mult[unit] ?? 1));
|
|
8311
8404
|
}
|
|
8312
8405
|
|
|
8313
|
-
// src/
|
|
8406
|
+
// src/runtime/node/load-config.ts
|
|
8314
8407
|
function loadProjectConfig(projectDir, env = process.env) {
|
|
8315
8408
|
const root = loadConfigToml(projectDir, env);
|
|
8316
8409
|
return {
|
|
@@ -8521,12 +8614,12 @@ function readFunctions(root) {
|
|
|
8521
8614
|
return out;
|
|
8522
8615
|
}
|
|
8523
8616
|
|
|
8524
|
-
// src/
|
|
8617
|
+
// src/runtime/node/load-functions.ts
|
|
8525
8618
|
import { readdir, readFile as readFile4, realpath, rm as rm2, stat } from "fs/promises";
|
|
8526
8619
|
import { join as join4 } from "path";
|
|
8527
8620
|
import { pathToFileURL } from "url";
|
|
8528
8621
|
|
|
8529
|
-
// src/
|
|
8622
|
+
// src/runtime/node/bundle-function.ts
|
|
8530
8623
|
import { createHash } from "crypto";
|
|
8531
8624
|
import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
|
|
8532
8625
|
import { existsSync } from "fs";
|
|
@@ -8590,7 +8683,7 @@ async function bundleFunction(entryPath, name) {
|
|
|
8590
8683
|
return result.outputs[0].path;
|
|
8591
8684
|
}
|
|
8592
8685
|
|
|
8593
|
-
// src/
|
|
8686
|
+
// src/runtime/node/load-functions.ts
|
|
8594
8687
|
async function loadFunctionEnv(projectDir) {
|
|
8595
8688
|
let text;
|
|
8596
8689
|
try {
|
|
@@ -8693,7 +8786,7 @@ async function loadFunctionsUnlocked(projectDir, options) {
|
|
|
8693
8786
|
return functions;
|
|
8694
8787
|
}
|
|
8695
8788
|
|
|
8696
|
-
// src/
|
|
8789
|
+
// src/runtime/node/project.ts
|
|
8697
8790
|
import { readdir as readdir2, readFile as readFile5 } from "fs/promises";
|
|
8698
8791
|
import { join as join5 } from "path";
|
|
8699
8792
|
async function loadSupabaseProject(projectDir, seed = {}) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type RunningServer } from './
|
|
3
|
-
import { type ProjectConfig } from './
|
|
4
|
-
import { type S3StorageDriverOptions } from './
|
|
5
|
-
import type { StorageDriver } from './
|
|
1
|
+
import { type SupaCloudLiteBackend } from './runtime/index.js';
|
|
2
|
+
import { type RunningServer } from './runtime/node/bun-server.js';
|
|
3
|
+
import { type ProjectConfig } from './runtime/node/load-config.js';
|
|
4
|
+
import { type S3StorageDriverOptions } from './runtime/storage/s3-driver.js';
|
|
5
|
+
import type { StorageDriver } from './runtime/types.js';
|
|
6
6
|
export interface ProjectSecrets {
|
|
7
7
|
jwtSecret: string;
|
|
8
8
|
vaultKey: string;
|
|
@@ -36,7 +36,7 @@ export interface ProjectRuntimeOptions {
|
|
|
36
36
|
log?: (message: string) => void;
|
|
37
37
|
}
|
|
38
38
|
export interface ProjectBackend {
|
|
39
|
-
backend:
|
|
39
|
+
backend: SupaCloudLiteBackend;
|
|
40
40
|
config: ProjectConfig;
|
|
41
41
|
paths: ProjectPaths;
|
|
42
42
|
host: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-runtime.d.ts","sourceRoot":"","sources":["../src/project-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,
|
|
1
|
+
{"version":3,"file":"project-runtime.d.ts","sourceRoot":"","sources":["../src/project-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAA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;YAgEV,MAAM;YAwBN,UAAU;YA4CV,OAAO;YAMP,YAAY;IAM1B,+EAA+E;IAC/E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAI;YAE9B,MAAM;YAqCN,WAAW;YAaX,UAAU;YAuBV,KAAK;IA2FnB;;;OAGG;YACW,KAAK;IAqBnB;;;;;OAKG;YACW,UAAU;IA2CxB;;;;;;;;;OASG;YACW,SAAS;YAqBT,YAAY;YAyDZ,eAAe;YAqBf,YAAY;YAyCZ,cAAc;YAWd,cAAc;IAmB5B,oFAAoF;YACtE,iBAAiB;YAuBjB,kBAAkB;YAqBlB,iBAAiB;YAUjB,uBAAuB;IASrC,OAAO,CAAC,kBAAkB;YAoBZ,cAAc;YAOd,gBAAgB;IAM9B,wEAAwE;IACxE,QAAQ,CACN,CAAC,EAAE,OAAO,EACV,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAO,EACvC,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAO,GACzC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAoB1B,+EAA+E;YACjE,gBAAgB;YAUhB,UAAU;CAqDzB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Local email inbox - the
|
|
2
|
+
* Local email inbox - the SupaCloud Lite equivalent of Supabase local's Inbucket /
|
|
3
3
|
* Mailpit. When no custom mailer is configured, outgoing auth emails (magic
|
|
4
4
|
* links, OTP codes, password recovery, email-change confirmations) are captured
|
|
5
5
|
* in memory and viewable at /inbox, so you can test those flows locally without
|