@void/edge 0.21.9 → 0.23.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/dist/index.d.mts +24 -1
- package/dist/index.mjs +42 -2
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { AssetConfig, AssetConfig as AssetConfig$1, HeaderRule, HeaderRule as HeaderRule$1, RedirectRule, RedirectRule as RedirectRule$1 } from "@void/deploy-core";
|
|
2
|
+
//#region src/access.d.ts
|
|
3
|
+
type ProjectZeroTrustRouting = Readonly<{
|
|
4
|
+
teamDomain: string;
|
|
5
|
+
audiences: ReadonlyArray<Readonly<{
|
|
6
|
+
hostname: string;
|
|
7
|
+
audience: string;
|
|
8
|
+
}>>;
|
|
9
|
+
}>;
|
|
10
|
+
//#endregion
|
|
2
11
|
//#region src/headers.d.ts
|
|
3
12
|
type HeaderRulePolicy = Readonly<{
|
|
4
13
|
/**
|
|
@@ -170,6 +179,8 @@ type StaticEdgeEnv = Readonly<{
|
|
|
170
179
|
ASSETS: EdgeAssetFetcher;
|
|
171
180
|
}>;
|
|
172
181
|
type StaticEdgeConfig = Readonly<{
|
|
182
|
+
/** Optional native Worker self-metadata used to identify the served version. */
|
|
183
|
+
versionMetadataBinding?: string;
|
|
173
184
|
assetConfig?: AssetConfig$1;
|
|
174
185
|
headerRules?: ReadonlyArray<HeaderRule$1>;
|
|
175
186
|
redirectRules?: ReadonlyArray<RedirectRule$1>;
|
|
@@ -250,4 +261,16 @@ export declare function getContentType(path: string): string;
|
|
|
250
261
|
*/
|
|
251
262
|
export declare function resolveAssetContentType(stored: string | null | undefined, path: string): string | undefined;
|
|
252
263
|
//#endregion
|
|
253
|
-
|
|
264
|
+
//#region src/limits.d.ts
|
|
265
|
+
/** Shared between the SDK, edge admission and Pages clients. */
|
|
266
|
+
type UsageLimitData = {
|
|
267
|
+
code: "usage_limit";
|
|
268
|
+
resource: "ai" | "sandbox" | "requests" | "execution";
|
|
269
|
+
reason: "monthly_quota" | "rate_limit" | "concurrency" | "runtime_budget" | "cpu";
|
|
270
|
+
message: string;
|
|
271
|
+
retryAt?: string;
|
|
272
|
+
};
|
|
273
|
+
export declare function readUsageLimit(value: unknown): UsageLimitData | null;
|
|
274
|
+
export declare function usageLimitResponse(limit: UsageLimitData): Response;
|
|
275
|
+
//#endregion
|
|
276
|
+
export type { AssetConfig, ClearSiteDataMember, CompiledPattern, EdgeAssetFetcher, HeaderRule, HeaderRulePolicy, ProjectZeroTrustRouting, RedirectRule, ResolvedAsset, RoutingRuleResult, StaticEdgeConfig, StaticEdgeEnv, StaticEdgeHandler, UsageLimitData };
|
package/dist/index.mjs
CHANGED
|
@@ -410,7 +410,14 @@ function mergeQueryIntoLocation(destination, requestSearch) {
|
|
|
410
410
|
function createStaticEdgeHandler(config) {
|
|
411
411
|
return { async fetch(request, env) {
|
|
412
412
|
const originalUrl = new URL(request.url);
|
|
413
|
-
if (request.method === "GET" && originalUrl.pathname === "/__void/ready")
|
|
413
|
+
if (request.method === "GET" && originalUrl.pathname === "/__void/ready") {
|
|
414
|
+
if (!config.versionMetadataBinding) return Response.json({ ready: true });
|
|
415
|
+
const metadata = config.versionMetadataBinding ? env[config.versionMetadataBinding] : void 0;
|
|
416
|
+
return Response.json({
|
|
417
|
+
ready: true,
|
|
418
|
+
...config.versionMetadataBinding ? { versionId: metadata?.id } : {}
|
|
419
|
+
}, { headers: { "cache-control": "no-store" } });
|
|
420
|
+
}
|
|
414
421
|
let effectiveUrl = new URL(originalUrl);
|
|
415
422
|
let effectiveRequest = request;
|
|
416
423
|
const route = applyRoutingRules(effectiveUrl.pathname, config.redirectRules, effectiveUrl.hostname);
|
|
@@ -678,4 +685,37 @@ function resolveAssetContentType(stored, path) {
|
|
|
678
685
|
return stored;
|
|
679
686
|
}
|
|
680
687
|
//#endregion
|
|
681
|
-
|
|
688
|
+
//#region src/limits.ts
|
|
689
|
+
function readUsageLimit(value) {
|
|
690
|
+
if (!value || typeof value !== "object") return null;
|
|
691
|
+
const v = value;
|
|
692
|
+
if (v.code !== "usage_limit" || typeof v.message !== "string" || ![
|
|
693
|
+
"ai",
|
|
694
|
+
"sandbox",
|
|
695
|
+
"requests",
|
|
696
|
+
"execution"
|
|
697
|
+
].includes(String(v.resource)) || ![
|
|
698
|
+
"monthly_quota",
|
|
699
|
+
"rate_limit",
|
|
700
|
+
"concurrency",
|
|
701
|
+
"runtime_budget",
|
|
702
|
+
"cpu"
|
|
703
|
+
].includes(String(v.reason))) return null;
|
|
704
|
+
return {
|
|
705
|
+
code: "usage_limit",
|
|
706
|
+
resource: v.resource,
|
|
707
|
+
reason: v.reason,
|
|
708
|
+
message: v.message,
|
|
709
|
+
...typeof v.retryAt === "string" && Number.isFinite(Date.parse(v.retryAt)) ? { retryAt: v.retryAt } : {}
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
function usageLimitResponse(limit) {
|
|
713
|
+
const headers = new Headers({ "Cache-Control": "no-store" });
|
|
714
|
+
if (limit.retryAt && Number.isFinite(Date.parse(limit.retryAt))) headers.set("Retry-After", String(Math.max(0, Math.ceil((Date.parse(limit.retryAt) - Date.now()) / 1e3))));
|
|
715
|
+
return Response.json(limit, {
|
|
716
|
+
status: 429,
|
|
717
|
+
headers
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
//#endregion
|
|
721
|
+
export { applyHeaderRules, applyRoutingRules, compilePattern, createStaticEdgeHandler, getContentType, matchLiteralPattern, matchPattern, matchPatternCaptures, matchSegmentPattern, mergeQueryIntoLocation, parseClearSiteData, readUsageLimit, resolveAssetContentType, resolveStaticPath, safeDecodePathname, sanitizeClearSiteData, substituteParams, usageLimitResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/edge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/voidzero-dev/void.git",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@void/deploy-core": "0.
|
|
23
|
+
"@void/deploy-core": "0.23.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@cloudflare/workers-types": "^4.20260702.1",
|
|
27
27
|
"typescript": "7.0.2",
|
|
28
|
-
"vite-plus": "0.
|
|
28
|
+
"vite-plus": "1.0.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "vp pack",
|