@supacloud/lite 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +33 -0
- package/dist/cli.js +682 -81
- package/dist/index.js +250 -15
- package/dist/runtime/functions/edge-runtime-shim.d.ts +15 -0
- package/dist/runtime/functions/edge-runtime-shim.d.ts.map +1 -0
- package/dist/runtime/functions/fetch-policy.d.ts +7 -0
- package/dist/runtime/functions/fetch-policy.d.ts.map +1 -0
- package/dist/runtime/functions/handler.d.ts +49 -2
- package/dist/runtime/functions/handler.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/node/load-config.d.ts +14 -0
- package/dist/runtime/node/load-config.d.ts.map +1 -1
- package/dist/runtime/node/load-functions.d.ts +14 -0
- package/dist/runtime/node/load-functions.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -85,7 +85,7 @@ function randomToken(bytes = 32) {
|
|
|
85
85
|
// package.json
|
|
86
86
|
var package_default = {
|
|
87
87
|
name: "@supacloud/lite",
|
|
88
|
-
version: "0.
|
|
88
|
+
version: "0.11.0",
|
|
89
89
|
description: "Bun-native, single-project Supabase-compatible backend powered by PGlite or native PostgreSQL",
|
|
90
90
|
type: "module",
|
|
91
91
|
license: "Apache-2.0",
|
|
@@ -135,6 +135,7 @@ var package_default = {
|
|
|
135
135
|
},
|
|
136
136
|
dependencies: {
|
|
137
137
|
"@electric-sql/pglite": "0.5.8",
|
|
138
|
+
"@supacloud/db": "^0.1.0",
|
|
138
139
|
tar: "^7.5.22"
|
|
139
140
|
},
|
|
140
141
|
devDependencies: {
|
|
@@ -2529,8 +2530,99 @@ function resetCapturedHandler() {
|
|
|
2529
2530
|
captured.handler = undefined;
|
|
2530
2531
|
}
|
|
2531
2532
|
|
|
2532
|
-
// src/runtime/functions/
|
|
2533
|
+
// src/runtime/functions/edge-runtime-shim.ts
|
|
2533
2534
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
2535
|
+
var scopeStore = new AsyncLocalStorage2;
|
|
2536
|
+
var NOT_ENABLED_MESSAGE = "EdgeRuntime.waitUntil is not enabled by the Function capability policy";
|
|
2537
|
+
var installed;
|
|
2538
|
+
function installEdgeRuntimeShim() {
|
|
2539
|
+
if (installed)
|
|
2540
|
+
return;
|
|
2541
|
+
const runtime = {
|
|
2542
|
+
waitUntil(promise) {
|
|
2543
|
+
const scope = scopeStore.getStore();
|
|
2544
|
+
if (scope && !scope.allowed) {
|
|
2545
|
+
throw new Error(NOT_ENABLED_MESSAGE);
|
|
2546
|
+
}
|
|
2547
|
+
const task = Promise.resolve(promise).catch((error) => {
|
|
2548
|
+
console.error("[EdgeRuntime.waitUntil] background task failed", error);
|
|
2549
|
+
});
|
|
2550
|
+
scope?.tasks.push(task);
|
|
2551
|
+
}
|
|
2552
|
+
};
|
|
2553
|
+
installed = runtime;
|
|
2554
|
+
globalThis.EdgeRuntime = runtime;
|
|
2555
|
+
}
|
|
2556
|
+
function runWithBackgroundTasks(options, fn) {
|
|
2557
|
+
installEdgeRuntimeShim();
|
|
2558
|
+
const scope = { allowed: options.allowed, tasks: [] };
|
|
2559
|
+
return scopeStore.run(scope, async () => {
|
|
2560
|
+
try {
|
|
2561
|
+
return await fn();
|
|
2562
|
+
} finally {
|
|
2563
|
+
flushBackgroundTasks(scope.tasks, options.timeoutMs);
|
|
2564
|
+
}
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
async function flushBackgroundTasks(tasks, timeoutMs) {
|
|
2568
|
+
if (tasks.length === 0)
|
|
2569
|
+
return;
|
|
2570
|
+
const drain = (async () => {
|
|
2571
|
+
while (tasks.length > 0) {
|
|
2572
|
+
const batch = tasks.splice(0);
|
|
2573
|
+
await Promise.allSettled(batch);
|
|
2574
|
+
}
|
|
2575
|
+
})();
|
|
2576
|
+
if (timeoutMs === undefined) {
|
|
2577
|
+
await drain;
|
|
2578
|
+
return;
|
|
2579
|
+
}
|
|
2580
|
+
const timedOut = await Promise.race([
|
|
2581
|
+
drain.then(() => false),
|
|
2582
|
+
new Promise((resolve) => setTimeout(() => resolve(true), timeoutMs))
|
|
2583
|
+
]);
|
|
2584
|
+
if (timedOut) {
|
|
2585
|
+
console.warn(`[EdgeRuntime.waitUntil] background tasks did not settle within ${timeoutMs}ms; no longer waiting`);
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
// src/runtime/functions/fetch-policy.ts
|
|
2590
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
2591
|
+
var policyStore = new AsyncLocalStorage3;
|
|
2592
|
+
var LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "::1"]);
|
|
2593
|
+
var installed2 = false;
|
|
2594
|
+
function installFetchPolicyShim() {
|
|
2595
|
+
if (installed2)
|
|
2596
|
+
return;
|
|
2597
|
+
installed2 = true;
|
|
2598
|
+
const original = globalThis.fetch;
|
|
2599
|
+
globalThis.fetch = async (input, init) => {
|
|
2600
|
+
const allowed = policyStore.getStore();
|
|
2601
|
+
if (!allowed)
|
|
2602
|
+
return original(input, init);
|
|
2603
|
+
const host = hostOf(input);
|
|
2604
|
+
if (host !== undefined && !LOOPBACK_HOSTS.has(host) && !allowed.has(host)) {
|
|
2605
|
+
throw new Error(`outbound host not allowed: ${host}`);
|
|
2606
|
+
}
|
|
2607
|
+
return original(input, init);
|
|
2608
|
+
};
|
|
2609
|
+
}
|
|
2610
|
+
function runWithFetchPolicy(allowedHosts, fn) {
|
|
2611
|
+
installFetchPolicyShim();
|
|
2612
|
+
return policyStore.run(new Set(allowedHosts), fn);
|
|
2613
|
+
}
|
|
2614
|
+
function hostOf(input) {
|
|
2615
|
+
try {
|
|
2616
|
+
const raw = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
2617
|
+
const host = new URL(raw).hostname;
|
|
2618
|
+
return host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
|
|
2619
|
+
} catch {
|
|
2620
|
+
return;
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
// src/runtime/functions/pgredis.ts
|
|
2625
|
+
import { AsyncLocalStorage as AsyncLocalStorage4 } from "async_hooks";
|
|
2534
2626
|
var CACHE_NAMESPACE = "supacloud-edge-runtime";
|
|
2535
2627
|
var CACHE_TABLE = "public.supacloud_pgredis_kv";
|
|
2536
2628
|
var MAX_KEY_CHARACTERS = 512;
|
|
@@ -2623,7 +2715,7 @@ class PgredisCache {
|
|
|
2623
2715
|
});
|
|
2624
2716
|
}
|
|
2625
2717
|
}
|
|
2626
|
-
var cacheContexts = new
|
|
2718
|
+
var cacheContexts = new AsyncLocalStorage4;
|
|
2627
2719
|
var cacheFacade = Object.freeze({
|
|
2628
2720
|
get: async (key) => activeCache().get(key),
|
|
2629
2721
|
set: async (key, cacheValue, ttlMs) => activeCache().set(key, cacheValue, ttlMs),
|
|
@@ -2697,6 +2789,23 @@ async function upsertWithoutTtl(query, key, serializedValue) {
|
|
|
2697
2789
|
}
|
|
2698
2790
|
|
|
2699
2791
|
// src/runtime/functions/handler.ts
|
|
2792
|
+
var VERIFIED_JWT_SUBJECT_HEADER = "x-supacloud-jwt-sub";
|
|
2793
|
+
var UNSAFE_VERIFIED_JWT_SUBJECT = /[\u0000-\u001F\u007F-\u009F\u0100-\u{10FFFF}]/u;
|
|
2794
|
+
function verifiedSubject(value) {
|
|
2795
|
+
if (typeof value !== "string" || value.length === 0 || value.length > 1024)
|
|
2796
|
+
return null;
|
|
2797
|
+
if (value.trim() !== value || UNSAFE_VERIFIED_JWT_SUBJECT.test(value))
|
|
2798
|
+
return null;
|
|
2799
|
+
return value;
|
|
2800
|
+
}
|
|
2801
|
+
function withVerifiedJwtSubject(request, ctx) {
|
|
2802
|
+
const trustedRequest = request.clone();
|
|
2803
|
+
trustedRequest.headers.delete(VERIFIED_JWT_SUBJECT_HEADER);
|
|
2804
|
+
const subject = verifiedSubject(ctx.claims?.sub);
|
|
2805
|
+
if (subject !== null)
|
|
2806
|
+
trustedRequest.headers.set(VERIFIED_JWT_SUBJECT_HEADER, subject);
|
|
2807
|
+
return trustedRequest;
|
|
2808
|
+
}
|
|
2700
2809
|
function isLoadedFunction(value) {
|
|
2701
2810
|
return typeof value === "object" && value !== null && "handler" in value;
|
|
2702
2811
|
}
|
|
@@ -2709,9 +2818,7 @@ function isFrameworkRouterHandler(handler) {
|
|
|
2709
2818
|
const candidate = handler;
|
|
2710
2819
|
if (candidate.__supacloud?.routeAware === true)
|
|
2711
2820
|
return true;
|
|
2712
|
-
|
|
2713
|
-
return true;
|
|
2714
|
-
return Array.isArray(candidate.routes) && typeof candidate.fetch === "function";
|
|
2821
|
+
return Array.isArray(candidate.routes) && (typeof candidate.handle === "function" || typeof candidate.fetch === "function");
|
|
2715
2822
|
}
|
|
2716
2823
|
function toFunctionLocalUrl(requestUrl) {
|
|
2717
2824
|
const url = new URL(requestUrl);
|
|
@@ -2752,23 +2859,68 @@ class FunctionsHandler {
|
|
|
2752
2859
|
return json2(404, { error: `function "${name}" not found` });
|
|
2753
2860
|
}
|
|
2754
2861
|
const entry = normalizeEntry(value);
|
|
2862
|
+
const limits = entry.limits;
|
|
2863
|
+
const capabilities = entry.capabilities;
|
|
2864
|
+
const maxBody = limits?.maxRequestBodyBytes;
|
|
2865
|
+
let request = req;
|
|
2866
|
+
if (maxBody !== undefined) {
|
|
2867
|
+
const contentLength = req.headers.get("content-length");
|
|
2868
|
+
if (contentLength !== null && Number(contentLength) > maxBody) {
|
|
2869
|
+
return json2(413, { error: `function "${name}" request body exceeded ${maxBody} bytes` });
|
|
2870
|
+
}
|
|
2871
|
+
if (contentLength === null && req.body) {
|
|
2872
|
+
request = withCountedBody(request, maxBody);
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2755
2875
|
const routeAware = entry.framework !== undefined && entry.framework !== "fetch" || isFrameworkRouterHandler(entry.handler);
|
|
2756
|
-
|
|
2876
|
+
request = withVerifiedJwtSubject(request, ctx);
|
|
2877
|
+
if (routeAware)
|
|
2878
|
+
request = new Request(toFunctionLocalUrl(request.url), request);
|
|
2879
|
+
const timeoutMs = limits?.timeoutMs;
|
|
2880
|
+
const abort = timeoutMs !== undefined ? new AbortController : undefined;
|
|
2881
|
+
if (abort)
|
|
2882
|
+
request = withSignal(request, abort.signal);
|
|
2757
2883
|
try {
|
|
2758
|
-
const
|
|
2759
|
-
const
|
|
2884
|
+
const env = capabilities?.secrets ? filterSecretsEnv(this.env, capabilities.secrets) : this.env;
|
|
2885
|
+
const invoke = () => this.invoke(entry.handler, request, ctx, env);
|
|
2886
|
+
const inner = () => runWithDenoEnv(env, () => runWithPgredisCache(this.pgredis, invoke));
|
|
2887
|
+
const run = capabilities?.outboundHosts ? () => runWithFetchPolicy(capabilities.outboundHosts, inner) : inner;
|
|
2888
|
+
const invokeWithBackground = () => runWithBackgroundTasks({ allowed: capabilities?.background !== false, timeoutMs: limits?.waitUntilTimeoutMs }, run);
|
|
2889
|
+
const res = timeoutMs !== undefined ? await this.withTimeout(name, timeoutMs, invokeWithBackground, abort) : await invokeWithBackground();
|
|
2760
2890
|
if (!(res instanceof Response)) {
|
|
2761
2891
|
return json2(500, { error: `function "${name}" did not return a Response` });
|
|
2762
2892
|
}
|
|
2763
|
-
|
|
2893
|
+
const maxResponse = limits?.maxResponseBodyBytes;
|
|
2894
|
+
return maxResponse !== undefined ? withResponseLimit(name, res, maxResponse) : res;
|
|
2764
2895
|
} catch (e) {
|
|
2765
2896
|
const message = e instanceof Error ? e.message : String(e);
|
|
2766
2897
|
return json2(500, { error: message });
|
|
2767
2898
|
}
|
|
2768
2899
|
}
|
|
2769
|
-
|
|
2900
|
+
async withTimeout(name, timeoutMs, run, abort) {
|
|
2901
|
+
let timer;
|
|
2902
|
+
const pending = run();
|
|
2903
|
+
try {
|
|
2904
|
+
const winner = await Promise.race([
|
|
2905
|
+
pending.then((res) => ({ timedOut: false, res })),
|
|
2906
|
+
new Promise((resolve) => {
|
|
2907
|
+
timer = setTimeout(() => resolve({ timedOut: true }), timeoutMs);
|
|
2908
|
+
})
|
|
2909
|
+
]);
|
|
2910
|
+
if (winner.timedOut) {
|
|
2911
|
+
abort.abort();
|
|
2912
|
+
pending.then(() => {}, () => {});
|
|
2913
|
+
return json2(504, { error: `function "${name}" timed out after ${timeoutMs}ms` });
|
|
2914
|
+
}
|
|
2915
|
+
return winner.res;
|
|
2916
|
+
} finally {
|
|
2917
|
+
if (timer)
|
|
2918
|
+
clearTimeout(timer);
|
|
2919
|
+
}
|
|
2920
|
+
}
|
|
2921
|
+
invoke(handler, req, ctx, env) {
|
|
2770
2922
|
if (typeof handler === "function") {
|
|
2771
|
-
return Promise.resolve(handler(req, { auth: ctx, env
|
|
2923
|
+
return Promise.resolve(handler(req, { auth: ctx, env }));
|
|
2772
2924
|
}
|
|
2773
2925
|
if (typeof handler.handle === "function") {
|
|
2774
2926
|
return Promise.resolve(handler.handle.call(handler, req));
|
|
@@ -2779,6 +2931,54 @@ class FunctionsHandler {
|
|
|
2779
2931
|
throw new Error("function handler must be a function or an object with handle()/fetch()");
|
|
2780
2932
|
}
|
|
2781
2933
|
}
|
|
2934
|
+
var BASE_ENV_KEYS = ["SUPABASE_URL", "SUPABASE_ANON_KEY", "SUPABASE_SERVICE_ROLE_KEY"];
|
|
2935
|
+
function filterSecretsEnv(env, secrets) {
|
|
2936
|
+
const out = {};
|
|
2937
|
+
for (const key of BASE_ENV_KEYS)
|
|
2938
|
+
out[key] = env[key];
|
|
2939
|
+
for (const key of secrets) {
|
|
2940
|
+
if (env[key] !== undefined)
|
|
2941
|
+
out[key] = env[key];
|
|
2942
|
+
}
|
|
2943
|
+
return out;
|
|
2944
|
+
}
|
|
2945
|
+
function withCountedBody(req, limit) {
|
|
2946
|
+
let seen = 0;
|
|
2947
|
+
const counter = new TransformStream({
|
|
2948
|
+
transform(chunk, controller) {
|
|
2949
|
+
seen += chunk.byteLength;
|
|
2950
|
+
if (seen > limit) {
|
|
2951
|
+
controller.error(new Error(`request body exceeded ${limit} bytes`));
|
|
2952
|
+
return;
|
|
2953
|
+
}
|
|
2954
|
+
controller.enqueue(chunk);
|
|
2955
|
+
}
|
|
2956
|
+
});
|
|
2957
|
+
return new Request(req, { body: req.body.pipeThrough(counter), duplex: "half" });
|
|
2958
|
+
}
|
|
2959
|
+
function withResponseLimit(name, res, limit) {
|
|
2960
|
+
const contentLength = res.headers.get("content-length");
|
|
2961
|
+
if (contentLength !== null && Number(contentLength) > limit) {
|
|
2962
|
+
return json2(502, { error: `function "${name}" response exceeded ${limit} bytes` });
|
|
2963
|
+
}
|
|
2964
|
+
if (!res.body)
|
|
2965
|
+
return res;
|
|
2966
|
+
let seen = 0;
|
|
2967
|
+
const counter = new TransformStream({
|
|
2968
|
+
transform(chunk, controller) {
|
|
2969
|
+
seen += chunk.byteLength;
|
|
2970
|
+
if (seen > limit) {
|
|
2971
|
+
controller.error(new Error(`function "${name}" response exceeded ${limit} bytes`));
|
|
2972
|
+
return;
|
|
2973
|
+
}
|
|
2974
|
+
controller.enqueue(chunk);
|
|
2975
|
+
}
|
|
2976
|
+
});
|
|
2977
|
+
return new Response(res.body.pipeThrough(counter), res);
|
|
2978
|
+
}
|
|
2979
|
+
function withSignal(req, signal) {
|
|
2980
|
+
return new Request(req, { signal, ...req.body ? { duplex: "half" } : {} });
|
|
2981
|
+
}
|
|
2782
2982
|
function json2(status, body) {
|
|
2783
2983
|
return new Response(JSON.stringify(body), {
|
|
2784
2984
|
status,
|
|
@@ -10014,9 +10214,9 @@ class RetentionService {
|
|
|
10014
10214
|
}
|
|
10015
10215
|
|
|
10016
10216
|
// src/runtime/security.ts
|
|
10017
|
-
var
|
|
10217
|
+
var LOOPBACK_HOSTS2 = new Set(["127.0.0.1", "localhost", "::1", "", undefined]);
|
|
10018
10218
|
function isNetworkExposed(host) {
|
|
10019
|
-
return !
|
|
10219
|
+
return !LOOPBACK_HOSTS2.has(host);
|
|
10020
10220
|
}
|
|
10021
10221
|
function assertSecretsSafe(input) {
|
|
10022
10222
|
const { host, jwtSecret, vaultKeyDerived, warn } = input;
|
|
@@ -12458,6 +12658,27 @@ function readFunctions(root) {
|
|
|
12458
12658
|
console.warn(` warning: [functions.${name}] framework "${framework}" is not one of fetch/elysia/hono; falling back to fetch`);
|
|
12459
12659
|
}
|
|
12460
12660
|
}
|
|
12661
|
+
const timeoutMs = getInt(t, "timeout_ms");
|
|
12662
|
+
if (timeoutMs !== undefined && timeoutMs > 0)
|
|
12663
|
+
opts.timeoutMs = timeoutMs;
|
|
12664
|
+
const maxRequestBodyBytes = getInt(t, "max_request_body_bytes");
|
|
12665
|
+
if (maxRequestBodyBytes !== undefined && maxRequestBodyBytes > 0)
|
|
12666
|
+
opts.maxRequestBodyBytes = maxRequestBodyBytes;
|
|
12667
|
+
const maxResponseBodyBytes = getInt(t, "max_response_body_bytes");
|
|
12668
|
+
if (maxResponseBodyBytes !== undefined && maxResponseBodyBytes > 0)
|
|
12669
|
+
opts.maxResponseBodyBytes = maxResponseBodyBytes;
|
|
12670
|
+
const waitUntilTimeoutMs = getInt(t, "wait_until_timeout_ms");
|
|
12671
|
+
if (waitUntilTimeoutMs !== undefined && waitUntilTimeoutMs > 0)
|
|
12672
|
+
opts.waitUntilTimeoutMs = waitUntilTimeoutMs;
|
|
12673
|
+
const outboundHosts = getStringArray(t, "outbound_hosts");
|
|
12674
|
+
if (outboundHosts !== undefined)
|
|
12675
|
+
opts.outboundHosts = outboundHosts;
|
|
12676
|
+
const secrets = getStringArray(t, "secrets");
|
|
12677
|
+
if (secrets !== undefined)
|
|
12678
|
+
opts.secrets = secrets;
|
|
12679
|
+
const background = getBool(t, "background");
|
|
12680
|
+
if (background !== undefined)
|
|
12681
|
+
opts.background = background;
|
|
12461
12682
|
out[name] = opts;
|
|
12462
12683
|
}
|
|
12463
12684
|
return out;
|
|
@@ -12633,9 +12854,23 @@ async function loadFunctionsUnlocked(projectDir, options) {
|
|
|
12633
12854
|
const defaultExport = mod.default;
|
|
12634
12855
|
const handler = typeof defaultExport === "function" ? defaultExport : defaultExport && (typeof defaultExport.handle === "function" || typeof defaultExport.fetch === "function") ? defaultExport : denoHandler ? (req) => denoHandler(req) : undefined;
|
|
12635
12856
|
if (handler) {
|
|
12857
|
+
const opts = options[name];
|
|
12858
|
+
const limits = opts && (opts.timeoutMs !== undefined || opts.maxRequestBodyBytes !== undefined || opts.maxResponseBodyBytes !== undefined || opts.waitUntilTimeoutMs !== undefined) ? {
|
|
12859
|
+
...opts.timeoutMs !== undefined ? { timeoutMs: opts.timeoutMs } : {},
|
|
12860
|
+
...opts.maxRequestBodyBytes !== undefined ? { maxRequestBodyBytes: opts.maxRequestBodyBytes } : {},
|
|
12861
|
+
...opts.maxResponseBodyBytes !== undefined ? { maxResponseBodyBytes: opts.maxResponseBodyBytes } : {},
|
|
12862
|
+
...opts.waitUntilTimeoutMs !== undefined ? { waitUntilTimeoutMs: opts.waitUntilTimeoutMs } : {}
|
|
12863
|
+
} : undefined;
|
|
12864
|
+
const capabilities = opts && (opts.outboundHosts !== undefined || opts.secrets !== undefined || opts.background !== undefined) ? {
|
|
12865
|
+
...opts.outboundHosts !== undefined ? { outboundHosts: opts.outboundHosts } : {},
|
|
12866
|
+
...opts.secrets !== undefined ? { secrets: opts.secrets } : {},
|
|
12867
|
+
...opts.background !== undefined ? { background: opts.background } : {}
|
|
12868
|
+
} : undefined;
|
|
12636
12869
|
functions.set(name, {
|
|
12637
12870
|
handler,
|
|
12638
|
-
framework: resolveFramework(name,
|
|
12871
|
+
framework: resolveFramework(name, opts?.framework),
|
|
12872
|
+
...limits ? { limits } : {},
|
|
12873
|
+
...capabilities ? { capabilities } : {}
|
|
12639
12874
|
});
|
|
12640
12875
|
} else {
|
|
12641
12876
|
console.warn(` warning: function "${name}" has no default function, handle/fetch object, or Deno.serve() handler, skipped`);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Install globalThis.EdgeRuntime.waitUntil once per process (idempotent). */
|
|
2
|
+
export declare function installEdgeRuntimeShim(): void;
|
|
3
|
+
/**
|
|
4
|
+
* Run `fn` with an EdgeRuntime.waitUntil scope. When `fn` settles, its
|
|
5
|
+
* background tasks are flushed without blocking the returned value: the flush
|
|
6
|
+
* waits for allSettled up to `timeoutMs` (wait_until_timeout_ms), after which
|
|
7
|
+
* it stops waiting and warns - like production, abandoned tasks keep running.
|
|
8
|
+
* Lite backend close() does not wait for in-flight background tasks; tasks
|
|
9
|
+
* still drifting at shutdown are dropped with the process.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runWithBackgroundTasks<T>(options: {
|
|
12
|
+
allowed: boolean;
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
}, fn: () => Promise<T>): Promise<T>;
|
|
15
|
+
//# sourceMappingURL=edge-runtime-shim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-runtime-shim.d.ts","sourceRoot":"","sources":["../../../src/runtime/functions/edge-runtime-shim.ts"],"names":[],"mappings":"AA2CA,8EAA8E;AAC9E,wBAAgB,sBAAsB,IAAI,IAAI,CAiB7C;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EACjD,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAWZ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run `fn` with fetch restricted to `allowedHosts` (plus loopback). The
|
|
3
|
+
* binding lives in an async-context store, so it stays correct across awaits
|
|
4
|
+
* and never leaks into other invocations - there is nothing to restore.
|
|
5
|
+
*/
|
|
6
|
+
export declare function runWithFetchPolicy<T>(allowedHosts: string[], fn: () => Promise<T>): Promise<T>;
|
|
7
|
+
//# sourceMappingURL=fetch-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-policy.d.ts","sourceRoot":"","sources":["../../../src/runtime/functions/fetch-policy.ts"],"names":[],"mappings":"AAsCA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAG9F"}
|
|
@@ -31,14 +31,53 @@ export interface FrameworkObjectHandler {
|
|
|
31
31
|
}
|
|
32
32
|
/** Anything registerable as a function: plain fetch handler or router object. */
|
|
33
33
|
export type FunctionHandler = EdgeFunction | FrameworkObjectHandler;
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Per-invocation resource limits, aligned with the Edge Runtime Manifest v2
|
|
36
|
+
* `limits` block (timeout_ms / max_request_body_bytes /
|
|
37
|
+
* max_response_body_bytes / wait_until_timeout_ms). Lite defaults to no
|
|
38
|
+
* limit when undeclared; production caps at 900s / 30MB.
|
|
39
|
+
*/
|
|
40
|
+
export interface FunctionLimits {
|
|
41
|
+
/** limits.timeout_ms: max wall time per invocation; on expiry the request is aborted and a 504 returned. */
|
|
42
|
+
timeoutMs?: number;
|
|
43
|
+
/** limits.max_request_body_bytes: max inbound body size; oversized bodies get a 413. */
|
|
44
|
+
maxRequestBodyBytes?: number;
|
|
45
|
+
/** limits.max_response_body_bytes: max outbound body size; oversized responses get a 502 / cut stream. */
|
|
46
|
+
maxResponseBodyBytes?: number;
|
|
47
|
+
/** limits.wait_until_timeout_ms: max time to wait for EdgeRuntime.waitUntil tasks after the response. */
|
|
48
|
+
waitUntilTimeoutMs?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Declared capabilities, aligned with the Edge Runtime Manifest v2
|
|
52
|
+
* `capabilities` block (secrets / outbound_hosts / background). Undeclared
|
|
53
|
+
* means unrestricted (back-compat).
|
|
54
|
+
*/
|
|
55
|
+
export interface FunctionCapabilities {
|
|
56
|
+
/** capabilities.secrets: env keys (beyond the SUPABASE_* base trio) visible to the function. */
|
|
57
|
+
secrets?: string[];
|
|
58
|
+
/** capabilities.outbound_hosts: exact fetch host allowlist (no port); loopback is always allowed. */
|
|
59
|
+
outboundHosts?: string[];
|
|
60
|
+
/**
|
|
61
|
+
* capabilities.background: whether EdgeRuntime.waitUntil is enabled. Lite
|
|
62
|
+
* defaults to allowed (local back-compat); only an explicit `false` takes
|
|
63
|
+
* the production error path.
|
|
64
|
+
*/
|
|
65
|
+
background?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** A loaded function plus its declared framework profile, limits, and capabilities. */
|
|
35
68
|
export interface LoadedFunction {
|
|
36
69
|
handler: FunctionHandler;
|
|
37
70
|
/** config.toml [functions.<name>].framework; `fetch` keeps legacy routing. */
|
|
38
71
|
framework?: FunctionFramework;
|
|
72
|
+
/** config.toml [functions.<name>] timeout_ms / max_request_body_bytes / max_response_body_bytes / wait_until_timeout_ms. */
|
|
73
|
+
limits?: FunctionLimits;
|
|
74
|
+
/** config.toml [functions.<name>] secrets / outbound_hosts / background. */
|
|
75
|
+
capabilities?: FunctionCapabilities;
|
|
39
76
|
}
|
|
40
77
|
/** Registry value: a bare handler or a {@link LoadedFunction} entry. */
|
|
41
78
|
export type FunctionRegistryValue = FunctionHandler | LoadedFunction;
|
|
79
|
+
/** Header written only after Lite has verified the request JWT. */
|
|
80
|
+
export declare const VERIFIED_JWT_SUBJECT_HEADER = "x-supacloud-jwt-sub";
|
|
42
81
|
/** Second argument passed to every {@link EdgeFunction} invocation. */
|
|
43
82
|
export interface FunctionContext {
|
|
44
83
|
/** verified request context (role + JWT claims) resolved by the router */
|
|
@@ -69,8 +108,16 @@ export declare class FunctionsHandler {
|
|
|
69
108
|
register(name: string, fn: FunctionRegistryValue): void;
|
|
70
109
|
/** Names of all registered functions. */
|
|
71
110
|
list(): string[];
|
|
72
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Dispatch a /functions/v1/<name> request to its handler, returning a 404 when
|
|
113
|
+
* unknown and a 500 when the handler throws or returns a non-Response.
|
|
114
|
+
* Declared limits/capabilities are enforced in order: request body size (413),
|
|
115
|
+
* invocation timeout (504), outbound host allowlist, secrets allowlist,
|
|
116
|
+
* EdgeRuntime.waitUntil background scope, response body size (502).
|
|
117
|
+
*/
|
|
73
118
|
handle(req: Request, ctx: RequestContext, url: URL): Promise<Response>;
|
|
119
|
+
/** Race the invocation against `timeoutMs`; on timeout abort the request and answer 504. */
|
|
120
|
+
private withTimeout;
|
|
74
121
|
private invoke;
|
|
75
122
|
}
|
|
76
123
|
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/runtime/functions/handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/runtime/functions/handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,cAAc,CAAA;AAErE,mFAAmF;AACnF,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAE/F,+EAA+E;AAC/E,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAE3D;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ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AAE,cAAc,CAAA;IACpB,4HAA4H;IAC5H,GAAG,EAAE;QACH,YAAY,EAAE,MAAM,CAAA;QACpB,iBAAiB,EAAE,MAAM,CAAA;QACzB,yBAAyB,EAAE,MAAM,CAAA;QACjC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAA;CACF;AAUD,kFAAkF;AAClF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAQlE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAY7D;AAED,uFAAuF;AACvF,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,OAAO;IAHjB,YACU,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,EAC7C,GAAG,EAAE,eAAe,CAAC,KAAK,CAAC,EAC3B,OAAO,EAAE,YAAY,EAC3B;IAEJ,qFAAqF;IACrF,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,qBAAqB,GAAG,IAAI,CAEtD;IAED,yCAAyC;IACzC,IAAI,IAAI,MAAM,EAAE,CAEf;IAED;;;;;;OAMG;IACG,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CA2E3E;IAED,4FAA4F;YAC9E,WAAW;IA4BzB,OAAO,CAAC,MAAM;CAiBf"}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -18,10 +18,11 @@ export { SmsInbox, type SmsInboxEntry } from './auth/sms-inbox.js';
|
|
|
18
18
|
export { LogBuffer, type LogEntry, type LogLevel } from './log-buffer.js';
|
|
19
19
|
export { RealtimeEngine, type RealtimeSocketLike } from './realtime/engine.js';
|
|
20
20
|
export { signJwt, verifyJwt, decodeJwt } from './jwt.js';
|
|
21
|
-
export { FunctionsHandler, isFrameworkRouterHandler, toFunctionLocalUrl, type EdgeFunction, type FrameworkObjectHandler, type FunctionContext, type FunctionFramework, type FunctionHandler, type FunctionRegistryValue, type LoadedFunction, } from './functions/handler.js';
|
|
21
|
+
export { FunctionsHandler, VERIFIED_JWT_SUBJECT_HEADER, isFrameworkRouterHandler, toFunctionLocalUrl, type EdgeFunction, type FrameworkObjectHandler, type FunctionCapabilities, type FunctionContext, type FunctionFramework, type FunctionHandler, type FunctionLimits, type FunctionRegistryValue, type LoadedFunction, } from './functions/handler.js';
|
|
22
22
|
export { type PgredisCacheBinding } from './functions/pgredis.js';
|
|
23
23
|
export { generateTypes } from './gen-types.js';
|
|
24
24
|
export { installDenoShim } from './functions/deno-shim.js';
|
|
25
|
+
export { installEdgeRuntimeShim } from './functions/edge-runtime-shim.js';
|
|
25
26
|
export { WebhooksService, type WebhookConfig, type WebhookDelivery } from './webhooks/service.js';
|
|
26
27
|
export { CronService, cronMatches } from './cron/service.js';
|
|
27
28
|
export { NetService, type NetDelivery } from './net/service.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAA8B,MAAM,wBAAwB,CAAA;AAGrF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAIrD,OAAO,EAAE,eAAe,EAAwB,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAA;AAC/D,OAA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IAC3B,qEAAqE;IACrE,QAAQ,EAAE,eAAe,CAAA;IACzB,mCAAmC;IACnC,IAAI,EAAE,WAAW,CAAA;IACjB,wDAAwD;IACxD,GAAG,EAAE,UAAU,CAAA;IACf,6EAA6E;IAC7E,SAAS,EAAE,gBAAgB,CAAA;IAC3B,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAA;IACf,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAA;IACtB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAA;IACjB,kEAAkE;IAClE,IAAI,EAAE,SAAS,CAAA;IACf,4FAA4F;IAC5F,KAAK,EAAE,WAAW,GAAG,IAAI,CAAA;IACzB,gHAAgH;IAChH,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAA;IACzB,8CAA8C;IAC9C,OAAO,EAAE,CAAC,UAAU,EAAE,aAAa,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAC7E,gGAAgG;IAChG,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3B;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CAAC,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA+W7F"}
|
|
@@ -78,6 +78,20 @@ export interface FunctionOptions {
|
|
|
78
78
|
entrypoint?: string;
|
|
79
79
|
/** [functions.<name>].framework: fetch (default), elysia, or hono */
|
|
80
80
|
framework?: import('../functions/handler.js').FunctionFramework;
|
|
81
|
+
/** [functions.<name>].timeout_ms: invocation timeout (Edge Runtime limits.timeout_ms) */
|
|
82
|
+
timeoutMs?: number;
|
|
83
|
+
/** [functions.<name>].max_request_body_bytes (Edge Runtime limits.max_request_body_bytes) */
|
|
84
|
+
maxRequestBodyBytes?: number;
|
|
85
|
+
/** [functions.<name>].max_response_body_bytes (Edge Runtime limits.max_response_body_bytes) */
|
|
86
|
+
maxResponseBodyBytes?: number;
|
|
87
|
+
/** [functions.<name>].wait_until_timeout_ms (Edge Runtime limits.wait_until_timeout_ms) */
|
|
88
|
+
waitUntilTimeoutMs?: number;
|
|
89
|
+
/** [functions.<name>].outbound_hosts: fetch host allowlist (Edge Runtime capabilities.outbound_hosts) */
|
|
90
|
+
outboundHosts?: string[];
|
|
91
|
+
/** [functions.<name>].secrets: env keys exposed to the function (Edge Runtime capabilities.secrets) */
|
|
92
|
+
secrets?: string[];
|
|
93
|
+
/** [functions.<name>].background: EdgeRuntime.waitUntil gate (Edge Runtime capabilities.background); lite defaults to true */
|
|
94
|
+
background?: boolean;
|
|
81
95
|
}
|
|
82
96
|
/** Parse supabase/config.toml once and project it into a {@link ProjectConfig}. */
|
|
83
97
|
export declare function loadProjectConfig(projectDir: string, env?: Environment): ProjectConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../../src/runtime/node/load-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAUL,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAA;AAEzB,oFAAoF;AACpF,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,IAAI,EAAE,UAAU,CAAA;IAChB,mDAAmD;IACnD,GAAG,EAAE,SAAS,CAAA;IACd,kEAAkE;IAClE,OAAO,EAAE,aAAa,CAAA;IACtB,gDAAgD;IAChD,IAAI,EAAE,UAAU,CAAA;IAChB,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAC3C;AAED,yFAAyF;A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wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,GAAE,WAAyB,GAAG,aAAa,CASnG"}
|
|
@@ -13,6 +13,20 @@ export interface LoadFunctionOptions {
|
|
|
13
13
|
entrypoint?: string;
|
|
14
14
|
/** Framework profile: fetch (default, legacy routing), elysia, or hono. */
|
|
15
15
|
framework?: FunctionFramework;
|
|
16
|
+
/** Invocation timeout in ms (Edge Runtime limits.timeout_ms). */
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
/** Max inbound request body bytes (Edge Runtime limits.max_request_body_bytes). */
|
|
19
|
+
maxRequestBodyBytes?: number;
|
|
20
|
+
/** Max outbound response body bytes (Edge Runtime limits.max_response_body_bytes). */
|
|
21
|
+
maxResponseBodyBytes?: number;
|
|
22
|
+
/** Max wait for EdgeRuntime.waitUntil tasks after the response (Edge Runtime limits.wait_until_timeout_ms). */
|
|
23
|
+
waitUntilTimeoutMs?: number;
|
|
24
|
+
/** Outbound fetch host allowlist (Edge Runtime capabilities.outbound_hosts). */
|
|
25
|
+
outboundHosts?: string[];
|
|
26
|
+
/** Env keys exposed to the function beyond the SUPABASE_* base trio (Edge Runtime capabilities.secrets). */
|
|
27
|
+
secrets?: string[];
|
|
28
|
+
/** EdgeRuntime.waitUntil gate (Edge Runtime capabilities.background); lite defaults to allowed. */
|
|
29
|
+
background?: boolean;
|
|
16
30
|
}
|
|
17
31
|
/**
|
|
18
32
|
* Discover and load every edge function under supabase/functions/, keyed by
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-functions.d.ts","sourceRoot":"","sources":["../../../src/runtime/node/load-functions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAwC,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAItH;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAqBzF;AAED,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c,CAAC,CAAC,CAYtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/lite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Bun-native, single-project Supabase-compatible backend powered by PGlite or native PostgreSQL",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@electric-sql/pglite": "0.5.8",
|
|
53
|
+
"@supacloud/db": "^0.1.0",
|
|
53
54
|
"tar": "^7.5.22"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|