@pyreon/zero 0.12.2 → 0.12.3
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/lib/actions.js +97 -0
- package/lib/actions.js.map +1 -0
- package/lib/ai.js +503 -0
- package/lib/ai.js.map +1 -0
- package/lib/api-routes.js +137 -0
- package/lib/api-routes.js.map +1 -0
- package/lib/compression.js +80 -0
- package/lib/compression.js.map +1 -0
- package/lib/cors.js +57 -0
- package/lib/cors.js.map +1 -0
- package/lib/csp.js +119 -0
- package/lib/csp.js.map +1 -0
- package/lib/env.js +217 -0
- package/lib/env.js.map +1 -0
- package/lib/favicon.js +424 -0
- package/lib/favicon.js.map +1 -0
- package/lib/i18n-routing.js +167 -0
- package/lib/i18n-routing.js.map +1 -0
- package/lib/index.js +80 -22
- package/lib/index.js.map +1 -1
- package/lib/link.js +5 -0
- package/lib/link.js.map +1 -1
- package/lib/logger.js +78 -0
- package/lib/logger.js.map +1 -0
- package/lib/meta.js +336 -0
- package/lib/meta.js.map +1 -0
- package/lib/middleware.js +53 -0
- package/lib/middleware.js.map +1 -0
- package/lib/og-image.js +233 -0
- package/lib/og-image.js.map +1 -0
- package/lib/rate-limit.js +76 -0
- package/lib/rate-limit.js.map +1 -0
- package/lib/testing.js +179 -0
- package/lib/testing.js.map +1 -0
- package/lib/theme.js +11 -2
- package/lib/theme.js.map +1 -1
- package/lib/types/actions.d.ts +27 -24
- package/lib/types/actions.d.ts.map +1 -1
- package/lib/types/ai.d.ts +76 -95
- package/lib/types/ai.d.ts.map +1 -1
- package/lib/types/api-routes.d.ts +37 -33
- package/lib/types/api-routes.d.ts.map +1 -1
- package/lib/types/cache.d.ts +26 -22
- package/lib/types/cache.d.ts.map +1 -1
- package/lib/types/client.d.ts +13 -9
- package/lib/types/client.d.ts.map +1 -1
- package/lib/types/compression.d.ts +14 -10
- package/lib/types/compression.d.ts.map +1 -1
- package/lib/types/config.d.ts +39 -4
- package/lib/types/config.d.ts.map +1 -1
- package/lib/types/cors.d.ts +20 -16
- package/lib/types/cors.d.ts.map +1 -1
- package/lib/types/csp.d.ts +42 -61
- package/lib/types/csp.d.ts.map +1 -1
- package/lib/types/env.d.ts +26 -26
- package/lib/types/env.d.ts.map +1 -1
- package/lib/types/favicon.d.ts +58 -54
- package/lib/types/favicon.d.ts.map +1 -1
- package/lib/types/font.d.ts +68 -65
- package/lib/types/font.d.ts.map +1 -1
- package/lib/types/i18n-routing.d.ts +43 -37
- package/lib/types/i18n-routing.d.ts.map +1 -1
- package/lib/types/image-plugin.d.ts +49 -45
- package/lib/types/image-plugin.d.ts.map +1 -1
- package/lib/types/image.d.ts +47 -36
- package/lib/types/image.d.ts.map +1 -1
- package/lib/types/index.d.ts +1961 -56
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/link.d.ts +61 -56
- package/lib/types/link.d.ts.map +1 -1
- package/lib/types/logger.d.ts +37 -48
- package/lib/types/logger.d.ts.map +1 -1
- package/lib/types/meta.d.ts +180 -105
- package/lib/types/meta.d.ts.map +1 -1
- package/lib/types/middleware.d.ts +8 -4
- package/lib/types/middleware.d.ts.map +1 -1
- package/lib/types/og-image.d.ts +63 -59
- package/lib/types/og-image.d.ts.map +1 -1
- package/lib/types/rate-limit.d.ts +20 -16
- package/lib/types/rate-limit.d.ts.map +1 -1
- package/lib/types/script.d.ts +23 -19
- package/lib/types/script.d.ts.map +1 -1
- package/lib/types/seo.d.ts +47 -43
- package/lib/types/seo.d.ts.map +1 -1
- package/lib/types/testing.d.ts +64 -27
- package/lib/types/testing.d.ts.map +1 -1
- package/lib/types/theme.d.ts +22 -12
- package/lib/types/theme.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/actions.ts +1 -3
- package/src/adapters/bun.ts +2 -0
- package/src/adapters/cloudflare.ts +2 -0
- package/src/adapters/netlify.ts +2 -0
- package/src/adapters/node.ts +2 -0
- package/src/adapters/validate.ts +16 -0
- package/src/adapters/vercel.ts +2 -0
- package/src/compression.ts +19 -3
- package/src/entry-server.ts +28 -5
- package/src/index.ts +1 -0
- package/src/link.tsx +6 -0
- package/src/meta.tsx +41 -13
- package/src/rate-limit.ts +11 -9
- package/src/theme.tsx +12 -1
- package/src/vite-plugin.ts +5 -1
- package/lib/types/adapters/bun.d.ts +0 -6
- package/lib/types/adapters/bun.d.ts.map +0 -1
- package/lib/types/adapters/cloudflare.d.ts +0 -26
- package/lib/types/adapters/cloudflare.d.ts.map +0 -1
- package/lib/types/adapters/index.d.ts +0 -13
- package/lib/types/adapters/index.d.ts.map +0 -1
- package/lib/types/adapters/netlify.d.ts +0 -21
- package/lib/types/adapters/netlify.d.ts.map +0 -1
- package/lib/types/adapters/node.d.ts +0 -6
- package/lib/types/adapters/node.d.ts.map +0 -1
- package/lib/types/adapters/static.d.ts +0 -7
- package/lib/types/adapters/static.d.ts.map +0 -1
- package/lib/types/adapters/vercel.d.ts +0 -21
- package/lib/types/adapters/vercel.d.ts.map +0 -1
- package/lib/types/app.d.ts +0 -24
- package/lib/types/app.d.ts.map +0 -1
- package/lib/types/entry-server.d.ts +0 -37
- package/lib/types/entry-server.d.ts.map +0 -1
- package/lib/types/error-overlay.d.ts +0 -6
- package/lib/types/error-overlay.d.ts.map +0 -1
- package/lib/types/fs-router.d.ts +0 -47
- package/lib/types/fs-router.d.ts.map +0 -1
- package/lib/types/isr.d.ts +0 -9
- package/lib/types/isr.d.ts.map +0 -1
- package/lib/types/not-found.d.ts +0 -7
- package/lib/types/not-found.d.ts.map +0 -1
- package/lib/types/types.d.ts +0 -111
- package/lib/types/types.d.ts.map +0 -1
- package/lib/types/utils/use-intersection-observer.d.ts +0 -10
- package/lib/types/utils/use-intersection-observer.d.ts.map +0 -1
- package/lib/types/utils/with-headers.d.ts +0 -6
- package/lib/types/utils/with-headers.d.ts.map +0 -1
- package/lib/types/vite-plugin.d.ts +0 -17
- package/lib/types/vite-plugin.d.ts.map +0 -1
|
@@ -1,53 +1,55 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/api-routes.d.ts
|
|
2
4
|
/** HTTP methods supported by API routes. */
|
|
3
|
-
|
|
5
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
4
6
|
/** Context passed to API route handlers. */
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
interface ApiContext {
|
|
8
|
+
/** The incoming request. */
|
|
9
|
+
request: Request;
|
|
10
|
+
/** Parsed URL. */
|
|
11
|
+
url: URL;
|
|
12
|
+
/** URL path. */
|
|
13
|
+
path: string;
|
|
14
|
+
/** Dynamic route parameters (e.g., { id: "123" }). */
|
|
15
|
+
params: Record<string, string>;
|
|
16
|
+
/** Request headers. */
|
|
17
|
+
headers: Headers;
|
|
16
18
|
}
|
|
17
19
|
/** An API route handler function. */
|
|
18
|
-
|
|
20
|
+
type ApiHandler = (ctx: ApiContext) => Response | Promise<Response>;
|
|
19
21
|
/** An API route module — exports named HTTP method handlers. */
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
interface ApiRouteModule {
|
|
23
|
+
GET?: ApiHandler;
|
|
24
|
+
POST?: ApiHandler;
|
|
25
|
+
PUT?: ApiHandler;
|
|
26
|
+
PATCH?: ApiHandler;
|
|
27
|
+
DELETE?: ApiHandler;
|
|
28
|
+
HEAD?: ApiHandler;
|
|
29
|
+
OPTIONS?: ApiHandler;
|
|
28
30
|
}
|
|
29
31
|
/** A registered API route entry. */
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
interface ApiRouteEntry {
|
|
33
|
+
/** URL pattern (e.g., "/api/posts/:id"). */
|
|
34
|
+
pattern: string;
|
|
35
|
+
/** The route module with method handlers. */
|
|
36
|
+
module: ApiRouteModule;
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
39
|
* Match a URL path against an API route pattern.
|
|
38
40
|
* Returns extracted params or null if no match.
|
|
39
41
|
*/
|
|
40
|
-
|
|
42
|
+
declare function matchApiRoute(pattern: string, path: string): Record<string, string> | null;
|
|
41
43
|
/**
|
|
42
44
|
* Create a middleware that dispatches API route requests.
|
|
43
45
|
* API routes are matched by URL pattern and HTTP method.
|
|
44
46
|
*/
|
|
45
|
-
|
|
47
|
+
declare function createApiMiddleware(routes: ApiRouteEntry[]): Middleware;
|
|
46
48
|
/**
|
|
47
49
|
* Detect whether a route file is an API route.
|
|
48
50
|
* API routes are `.ts` or `.js` files inside an `api/` directory.
|
|
49
51
|
*/
|
|
50
|
-
|
|
52
|
+
declare function isApiRoute(filePath: string): boolean;
|
|
51
53
|
/**
|
|
52
54
|
* Convert an API route file path to a URL pattern.
|
|
53
55
|
*
|
|
@@ -57,10 +59,12 @@ export declare function isApiRoute(filePath: string): boolean;
|
|
|
57
59
|
* "api/posts/[id].ts" → "/api/posts/:id"
|
|
58
60
|
* "api/[...path].ts" → "/api/:path*"
|
|
59
61
|
*/
|
|
60
|
-
|
|
62
|
+
declare function apiFilePathToPattern(filePath: string): string;
|
|
61
63
|
/**
|
|
62
64
|
* Generate a virtual module that exports API route entries.
|
|
63
65
|
* Each entry maps a URL pattern to a module with HTTP method handlers.
|
|
64
66
|
*/
|
|
65
|
-
|
|
66
|
-
//#
|
|
67
|
+
declare function generateApiRouteModule(files: string[], routesDir: string): string;
|
|
68
|
+
//#endregion
|
|
69
|
+
export { ApiContext, ApiHandler, ApiRouteEntry, ApiRouteModule, HttpMethod, apiFilePathToPattern, createApiMiddleware, generateApiRouteModule, isApiRoute, matchApiRoute };
|
|
70
|
+
//# sourceMappingURL=api-routes2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-
|
|
1
|
+
{"version":3,"file":"api-routes2.d.ts","names":[],"sources":["../../../src/api-routes.ts"],"mappings":";;;;KAKY,UAAA;AAAZ;AAAA,UAGiB,UAAA;;EAEf,OAAA,EAAS,OAAA;EALW;EAOpB,GAAA,EAAK,GAAA;EAJoB;EAMzB,IAAA;EAJS;EAMT,MAAA,EAAQ,MAAA;EAAA;EAER,OAAA,EAAS,OAAA;AAAA;;KAIC,UAAA,IAAc,GAAA,EAAK,UAAA,KAAe,QAAA,GAAW,OAAA,CAAQ,QAAA;;UAGhD,cAAA;EACf,GAAA,GAAM,UAAA;EACN,IAAA,GAAO,UAAA;EACP,GAAA,GAAM,UAAA;EACN,KAAA,GAAQ,UAAA;EACR,MAAA,GAAS,UAAA;EACT,IAAA,GAAO,UAAA;EACP,OAAA,GAAU,UAAA;AAAA;AAVZ;AAAA,UAciB,aAAA;;EAEf,OAAA;EAhB4C;EAkB5C,MAAA,EAAQ,cAAA;AAAA;;;;;iBASM,aAAA,CAAc,OAAA,UAAiB,IAAA,WAAe,MAAA;;;;;iBAwC9C,mBAAA,CAAoB,MAAA,EAAQ,aAAA,KAAkB,UAAA;;;;;iBAsC9C,UAAA,CAAW,QAAA;;;;;;;;;;iBAmBX,oBAAA,CAAqB,QAAA;;;;;iBAwCrB,sBAAA,CAAuB,KAAA,YAAiB,SAAA"}
|
package/lib/types/cache.d.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/cache.d.ts
|
|
4
|
+
interface CacheConfig {
|
|
5
|
+
/** Cache duration for immutable hashed assets (seconds). Default: 31536000 (1 year) */
|
|
6
|
+
immutable?: number;
|
|
7
|
+
/** Cache duration for static assets like images/fonts (seconds). Default: 86400 (1 day) */
|
|
8
|
+
static?: number;
|
|
9
|
+
/** Cache duration for pages (seconds). Default: 0 (no cache) */
|
|
10
|
+
pages?: number;
|
|
11
|
+
/** Stale-while-revalidate window for pages (seconds). Default: 60 */
|
|
12
|
+
staleWhileRevalidate?: number;
|
|
13
|
+
/** Custom rules by URL pattern. */
|
|
14
|
+
rules?: CacheRule[];
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
interface CacheRule {
|
|
17
|
+
/** URL pattern to match (glob-style). e.g. "/api/*" */
|
|
18
|
+
match: string;
|
|
19
|
+
/** Cache-Control header value. */
|
|
20
|
+
control: string;
|
|
19
21
|
}
|
|
20
22
|
/** @internal Exported for testing */
|
|
21
|
-
|
|
23
|
+
declare function matchGlob(pattern: string, path: string): boolean;
|
|
22
24
|
/**
|
|
23
25
|
* Cache control middleware for Zero.
|
|
24
26
|
* Sets Cache-Control headers on the response based on asset type.
|
|
@@ -39,16 +41,18 @@ export declare function matchGlob(pattern: string, path: string): boolean;
|
|
|
39
41
|
* ],
|
|
40
42
|
* })
|
|
41
43
|
*/
|
|
42
|
-
|
|
44
|
+
declare function cacheMiddleware(config?: CacheConfig): Middleware;
|
|
43
45
|
/**
|
|
44
46
|
* Security headers middleware.
|
|
45
47
|
* Adds common security headers to all responses.
|
|
46
48
|
*/
|
|
47
|
-
|
|
49
|
+
declare function securityHeaders(): Middleware;
|
|
48
50
|
/**
|
|
49
51
|
* Compression detection middleware.
|
|
50
52
|
* Sets Vary: Accept-Encoding header so caches can serve compressed variants.
|
|
51
53
|
* Actual compression is handled by the runtime (Bun/Node) or reverse proxy.
|
|
52
54
|
*/
|
|
53
|
-
|
|
54
|
-
//#
|
|
55
|
+
declare function varyEncoding(): Middleware;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { CacheConfig, CacheRule, cacheMiddleware, matchGlob, securityHeaders, varyEncoding };
|
|
58
|
+
//# sourceMappingURL=cache2.d.ts.map
|
package/lib/types/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"cache2.d.ts","names":[],"sources":["../../../src/cache.ts"],"mappings":";;;UAaiB,WAAA;;EAEf,SAAA;EAF0B;EAI1B,MAAA;EAMiB;EAJjB,KAAA;EAFA;EAIA,oBAAA;EAAA;EAEA,KAAA,GAAQ,SAAA;AAAA;AAAA,UAGO,SAAA;EAHE;EAKjB,KAAA;EAFwB;EAIxB,OAAA;AAAA;;iBAQc,SAAA,CAAU,OAAA,UAAiB,IAAA;;;;;AAiD3C;;;;;;;;;AA0BA;;;;;AAeA;;iBAzCgB,eAAA,CAAgB,MAAA,GAAQ,WAAA,GAAmB,UAAA;;;;;iBA0B3C,eAAA,CAAA,GAAmB,UAAA;;;;;;iBAenB,YAAA,CAAA,GAAgB,UAAA"}
|
package/lib/types/client.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { ComponentFn } from "@pyreon/core";
|
|
2
|
+
import { RouteRecord } from "@pyreon/router";
|
|
3
|
+
|
|
4
|
+
//#region src/client.d.ts
|
|
5
|
+
interface StartClientOptions {
|
|
6
|
+
/** Route definitions. */
|
|
7
|
+
routes: RouteRecord[];
|
|
8
|
+
/** Root layout component. */
|
|
9
|
+
layout?: ComponentFn;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Start the client-side app — hydrates SSR content or mounts fresh for SPA.
|
|
@@ -15,5 +17,7 @@ export interface StartClientOptions {
|
|
|
15
17
|
*
|
|
16
18
|
* startClient({ routes })
|
|
17
19
|
*/
|
|
18
|
-
|
|
19
|
-
//#
|
|
20
|
+
declare function startClient(options: StartClientOptions): () => void;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { StartClientOptions, startClient };
|
|
23
|
+
//# sourceMappingURL=client2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"client2.d.ts","names":[],"sources":["../../../src/client.ts"],"mappings":";;;;UAQiB,kBAAA;;EAEf,MAAA,EAAQ,WAAA;EAFyB;EAIjC,MAAA,GAAS,WAAA;AAAA;;;;;;;AAYX;;;iBAAgB,WAAA,CAAY,OAAA,EAAS,kBAAA"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/compression.d.ts
|
|
4
|
+
interface CompressionConfig {
|
|
5
|
+
/** Minimum response size in bytes to compress. Default: `1024` (1KB) */
|
|
6
|
+
threshold?: number;
|
|
7
|
+
/** Encoding preference order. Default: `["gzip", "deflate"]` */
|
|
8
|
+
encodings?: ('gzip' | 'deflate')[];
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* Compression middleware — compresses responses using gzip or deflate
|
|
@@ -18,7 +20,7 @@ export interface CompressionConfig {
|
|
|
18
20
|
* compressionMiddleware() // gzip with 1KB threshold
|
|
19
21
|
* compressionMiddleware({ threshold: 512, encodings: ["gzip"] })
|
|
20
22
|
*/
|
|
21
|
-
|
|
23
|
+
declare function compressionMiddleware(config?: CompressionConfig): Middleware;
|
|
22
24
|
/**
|
|
23
25
|
* Compress a Response body if it meets the criteria.
|
|
24
26
|
* Use this to post-process responses after the handler runs.
|
|
@@ -27,7 +29,9 @@ export declare function compressionMiddleware(config?: CompressionConfig): Middl
|
|
|
27
29
|
* const response = await handler(request)
|
|
28
30
|
* const compressed = await compressResponse(response, 'gzip', 1024)
|
|
29
31
|
*/
|
|
30
|
-
|
|
32
|
+
declare function compressResponse(response: Response, encoding: 'gzip' | 'deflate', threshold: number): Promise<Response>;
|
|
31
33
|
/** Check if a content type is compressible. Exported for testing. */
|
|
32
|
-
|
|
33
|
-
//#
|
|
34
|
+
declare function isCompressible(contentType: string): boolean;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { CompressionConfig, compressResponse, compressionMiddleware, isCompressible };
|
|
37
|
+
//# sourceMappingURL=compression2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"compression2.d.ts","names":[],"sources":["../../../src/compression.ts"],"mappings":";;;UAIiB,iBAAA;;EAEf,SAAA;EAFgC;EAIhC,SAAA;AAAA;;AAgBF;;;;;;;;;AAyBA;;;iBAzBgB,qBAAA,CAAsB,MAAA,GAAQ,iBAAA,GAAyB,UAAA;;;;;;;;;iBAyBjD,gBAAA,CACpB,QAAA,EAAU,QAAA,EACV,QAAA,sBACA,SAAA,WACC,OAAA,CAAQ,QAAA;;iBAsCK,cAAA,CAAe,WAAA"}
|
package/lib/types/config.d.ts
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type RenderMode = 'ssr' | 'ssg' | 'spa' | 'isr';
|
|
5
|
+
interface ISRConfig {
|
|
6
|
+
/** Revalidation interval in seconds. */
|
|
7
|
+
revalidate: number;
|
|
8
|
+
}
|
|
9
|
+
interface ZeroConfig {
|
|
10
|
+
/** Default rendering mode. Default: "ssr" */
|
|
11
|
+
mode?: RenderMode;
|
|
12
|
+
/** Vite config overrides. */
|
|
13
|
+
vite?: Record<string, unknown>;
|
|
14
|
+
/** SSR options. */
|
|
15
|
+
ssr?: {
|
|
16
|
+
/** Streaming mode. Default: "string" */mode?: 'string' | 'stream';
|
|
17
|
+
};
|
|
18
|
+
/** SSG options — only used when mode is "ssg". */
|
|
19
|
+
ssg?: {
|
|
20
|
+
/** Paths to prerender (or function returning paths). */paths?: string[] | (() => string[] | Promise<string[]>);
|
|
21
|
+
};
|
|
22
|
+
/** ISR config — only used when mode is "isr". */
|
|
23
|
+
isr?: ISRConfig;
|
|
24
|
+
/** Deploy adapter. Default: "node" */
|
|
25
|
+
adapter?: 'node' | 'bun' | 'static' | 'vercel' | 'cloudflare' | 'netlify';
|
|
26
|
+
/** Base URL path. Default: "/" */
|
|
27
|
+
base?: string;
|
|
28
|
+
/** App-level middleware applied to all routes. */
|
|
29
|
+
middleware?: Middleware[];
|
|
30
|
+
/** Server port for dev/preview. Default: 3000 */
|
|
31
|
+
port?: number;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/config.d.ts
|
|
2
35
|
/**
|
|
3
36
|
* Define a Zero configuration.
|
|
4
37
|
* Used in `zero.config.ts` at the project root.
|
|
@@ -12,7 +45,9 @@ import type { ZeroConfig } from './types';
|
|
|
12
45
|
* port: 3000,
|
|
13
46
|
* })
|
|
14
47
|
*/
|
|
15
|
-
|
|
48
|
+
declare function defineConfig(config: ZeroConfig): ZeroConfig;
|
|
16
49
|
/** Merge user config with defaults. */
|
|
17
|
-
|
|
18
|
-
//#
|
|
50
|
+
declare function resolveConfig(userConfig?: ZeroConfig): Required<Pick<ZeroConfig, 'mode' | 'base' | 'port' | 'adapter'>> & ZeroConfig;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { defineConfig, resolveConfig };
|
|
53
|
+
//# sourceMappingURL=config2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"config2.d.ts","names":[],"sources":["../../../src/types.ts","../../../src/config.ts"],"mappings":";;;KA6CY,UAAA;AAAA,UAEK,SAAA;EAoCF;EAlCb,UAAA;AAAA;AAAA,UAKe,UAAA;;EAEf,IAAA,GAAO,UAAA;;EAGP,IAAA,GAAO,MAAA;EC5CmB;ED+C1B,GAAA;IC/C0D,wCDiDxD,IAAA;EAAA;ECjD8C;EDqDhD,GAAA;ICrD0D,wDDuDxD,KAAA,gCAAqC,OAAA;EAAA;;EAIvC,GAAA,GAAM,SAAA;ECpDS;EDuDf,OAAA;ECvDC;ED0DD,IAAA;EC1D8E;ED6D9E,UAAA,GAAa,UAAA;EC9DD;EDiEZ,IAAA;AAAA;;;;;;;AAzCF;;;;;AAEA;;;;iBChCgB,YAAA,CAAa,MAAA,EAAQ,UAAA,GAAa,UAAA;ADuClD;AAAA,iBClCgB,aAAA,CACd,UAAA,GAAY,UAAA,GACX,QAAA,CAAS,IAAA,CAAK,UAAA,2CAAqD,UAAA"}
|
package/lib/types/cors.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/cors.d.ts
|
|
4
|
+
interface CorsConfig {
|
|
5
|
+
/** Allowed origins. Use `"*"` for any origin. Default: `"*"` */
|
|
6
|
+
origin?: string | string[] | ((origin: string) => boolean);
|
|
7
|
+
/** Allowed HTTP methods. Default: `["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]` */
|
|
8
|
+
methods?: string[];
|
|
9
|
+
/** Allowed request headers. Default: `["Content-Type", "Authorization"]` */
|
|
10
|
+
allowedHeaders?: string[];
|
|
11
|
+
/** Headers exposed to the client. Default: `[]` */
|
|
12
|
+
exposedHeaders?: string[];
|
|
13
|
+
/** Allow credentials (cookies, auth headers). Default: `false` */
|
|
14
|
+
credentials?: boolean;
|
|
15
|
+
/** Preflight cache duration in seconds. Default: `86400` (24 hours) */
|
|
16
|
+
maxAge?: number;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* CORS middleware — handles preflight requests and sets appropriate
|
|
@@ -28,5 +30,7 @@ export interface CorsConfig {
|
|
|
28
30
|
* // Multiple origins
|
|
29
31
|
* corsMiddleware({ origin: ["https://app.com", "https://admin.com"] })
|
|
30
32
|
*/
|
|
31
|
-
|
|
32
|
-
//#
|
|
33
|
+
declare function corsMiddleware(config?: CorsConfig): Middleware;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { CorsConfig, corsMiddleware };
|
|
36
|
+
//# sourceMappingURL=cors2.d.ts.map
|
package/lib/types/cors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"cors2.d.ts","names":[],"sources":["../../../src/cors.ts"],"mappings":";;;UAIiB,UAAA;;EAEf,MAAA,yBAA+B,MAAA;EAFN;EAIzB,OAAA;EAJyB;EAMzB,cAAA;EAJ+B;EAM/B,cAAA;EAFA;EAIA,WAAA;EAAA;EAEA,MAAA;AAAA;;AAqBF;;;;;;;;;;;;;;iBAAgB,cAAA,CAAe,MAAA,GAAQ,UAAA,GAAkB,UAAA"}
|
package/lib/types/csp.d.ts
CHANGED
|
@@ -1,27 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Generates a CSP header from a typed configuration object.
|
|
5
|
-
* Supports all CSP directives, nonces for inline scripts,
|
|
6
|
-
* and report-only mode for testing.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { cspMiddleware } from "@pyreon/zero"
|
|
11
|
-
*
|
|
12
|
-
* const csp = cspMiddleware({
|
|
13
|
-
* directives: {
|
|
14
|
-
* defaultSrc: ["'self'"],
|
|
15
|
-
* scriptSrc: ["'self'", "'nonce'"],
|
|
16
|
-
* styleSrc: ["'self'", "'unsafe-inline'"],
|
|
17
|
-
* imgSrc: ["'self'", "data:", "https:"],
|
|
18
|
-
* connectSrc: ["'self'", "https://api.example.com"],
|
|
19
|
-
* },
|
|
20
|
-
* reportOnly: false,
|
|
21
|
-
* })
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
import type { Middleware } from '@pyreon/server';
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/csp.d.ts
|
|
25
4
|
/**
|
|
26
5
|
* Read the current CSP nonce in a component.
|
|
27
6
|
*
|
|
@@ -39,47 +18,47 @@ import type { Middleware } from '@pyreon/server';
|
|
|
39
18
|
* }
|
|
40
19
|
* ```
|
|
41
20
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
21
|
+
declare function useNonce(): string;
|
|
22
|
+
interface CspDirectives {
|
|
23
|
+
defaultSrc?: string[];
|
|
24
|
+
scriptSrc?: string[];
|
|
25
|
+
styleSrc?: string[];
|
|
26
|
+
imgSrc?: string[];
|
|
27
|
+
fontSrc?: string[];
|
|
28
|
+
connectSrc?: string[];
|
|
29
|
+
mediaSrc?: string[];
|
|
30
|
+
objectSrc?: string[];
|
|
31
|
+
frameSrc?: string[];
|
|
32
|
+
childSrc?: string[];
|
|
33
|
+
workerSrc?: string[];
|
|
34
|
+
frameAncestors?: string[];
|
|
35
|
+
formAction?: string[];
|
|
36
|
+
baseUri?: string[];
|
|
37
|
+
manifestSrc?: string[];
|
|
38
|
+
/** Reporting endpoint URL. */
|
|
39
|
+
reportUri?: string;
|
|
40
|
+
/** Reporting endpoint name (CSP Level 3). */
|
|
41
|
+
reportTo?: string;
|
|
42
|
+
/** Upgrade insecure requests. */
|
|
43
|
+
upgradeInsecureRequests?: boolean;
|
|
44
|
+
/** Block all mixed content. */
|
|
45
|
+
blockAllMixedContent?: boolean;
|
|
67
46
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
47
|
+
interface CspConfig {
|
|
48
|
+
/** CSP directives. */
|
|
49
|
+
directives: CspDirectives;
|
|
50
|
+
/**
|
|
51
|
+
* Report-only mode — logs violations without blocking.
|
|
52
|
+
* Uses Content-Security-Policy-Report-Only header instead.
|
|
53
|
+
* Default: false
|
|
54
|
+
*/
|
|
55
|
+
reportOnly?: boolean;
|
|
77
56
|
}
|
|
78
57
|
/**
|
|
79
58
|
* Build a CSP header string from directives.
|
|
80
59
|
* Exported for testing.
|
|
81
60
|
*/
|
|
82
|
-
|
|
61
|
+
declare function buildCspHeader(directives: CspDirectives, nonce?: string): string;
|
|
83
62
|
/**
|
|
84
63
|
* CSP middleware — sets Content-Security-Policy header.
|
|
85
64
|
*
|
|
@@ -103,5 +82,7 @@ export declare function buildCspHeader(directives: CspDirectives, nonce?: string
|
|
|
103
82
|
* })
|
|
104
83
|
* ```
|
|
105
84
|
*/
|
|
106
|
-
|
|
107
|
-
//#
|
|
85
|
+
declare function cspMiddleware(config: CspConfig): Middleware;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { CspConfig, CspDirectives, buildCspHeader, cspMiddleware, useNonce };
|
|
88
|
+
//# sourceMappingURL=csp2.d.ts.map
|
package/lib/types/csp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"csp2.d.ts","names":[],"sources":["../../../src/csp.ts"],"mappings":";;;;;;;;;;;;AA8EA;;;;;;;;iBAhCgB,QAAA,CAAA;AAAA,UAMC,aAAA;EACf,UAAA;EACA,SAAA;EACA,QAAA;EACA,MAAA;EACA,OAAA;EACA,UAAA;EACA,QAAA;EACA,SAAA;EACA,QAAA;EACA,QAAA;EACA,SAAA;EACA,cAAA;EACA,UAAA;EACA,OAAA;EACA,WAAA;EAmH0D;EAjH1D,SAAA;;EAEA,QAAA;;EAEA,uBAAA;;EAEA,oBAAA;AAAA;AAAA,UAGe,SAAA;;EAEf,UAAA,EAAY,aAAA;;;;;;EAMZ,UAAA;AAAA;;;;;iBA2Bc,cAAA,CAAe,UAAA,EAAY,aAAA,EAAe,KAAA;;;;;;;;;;;;;;;;;;;;;;;;iBAqE1C,aAAA,CAAc,MAAA,EAAQ,SAAA,GAAY,UAAA"}
|
package/lib/types/env.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/env.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Environment variable validation.
|
|
3
4
|
*
|
|
@@ -19,47 +20,45 @@
|
|
|
19
20
|
* })
|
|
20
21
|
* ```
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
interface EnvValidatorOptions<T = string> {
|
|
24
|
+
/** Whether this variable is required. Default: true */
|
|
25
|
+
required?: boolean;
|
|
26
|
+
/** Default value when not set. Makes the variable optional. */
|
|
27
|
+
default?: T;
|
|
28
|
+
/** Human-readable description for error messages. */
|
|
29
|
+
description?: string;
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
interface EnvValidator<T> {
|
|
32
|
+
__type: 'env-validator';
|
|
33
|
+
parse: (raw: string | undefined, key: string) => T;
|
|
34
|
+
required: boolean;
|
|
35
|
+
defaultValue?: T | undefined;
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* String validator — accepts any non-empty string.
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
declare function str(options?: EnvValidatorOptions<string>): EnvValidator<string>;
|
|
40
41
|
/**
|
|
41
42
|
* Number validator — parses to a number, rejects NaN.
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
+
declare function num(options?: EnvValidatorOptions<number>): EnvValidator<number>;
|
|
44
45
|
/**
|
|
45
46
|
* Boolean validator — accepts "true"/"1" as true, "false"/"0" as false.
|
|
46
47
|
*/
|
|
47
|
-
|
|
48
|
+
declare function bool(options?: EnvValidatorOptions<boolean>): EnvValidator<boolean>;
|
|
48
49
|
/**
|
|
49
50
|
* URL validator — validates that the value is a valid URL.
|
|
50
51
|
*/
|
|
51
|
-
|
|
52
|
+
declare function url(options?: EnvValidatorOptions<string>): EnvValidator<string>;
|
|
52
53
|
/**
|
|
53
54
|
* Enum validator — value must be one of the allowed values.
|
|
54
55
|
*/
|
|
55
|
-
|
|
56
|
+
declare function oneOf<T extends string>(values: readonly T[], options?: EnvValidatorOptions<T>): EnvValidator<T>;
|
|
56
57
|
/** Schema entry: plain value, constructor, or explicit validator. */
|
|
57
58
|
type SchemaEntry = string | number | boolean | StringConstructor | NumberConstructor | BooleanConstructor | EnvValidator<any>;
|
|
58
59
|
/** Infer the output type from a schema entry. */
|
|
59
60
|
type InferEntry<T> = T extends EnvValidator<infer V> ? V : T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends string ? string : T extends number ? number : T extends boolean ? boolean : never;
|
|
60
|
-
type InferEnvSchema<T> = {
|
|
61
|
-
[K in keyof T]: InferEntry<T[K]>;
|
|
62
|
-
};
|
|
61
|
+
type InferEnvSchema<T> = { [K in keyof T]: InferEntry<T[K]> };
|
|
63
62
|
/**
|
|
64
63
|
* Validate environment variables.
|
|
65
64
|
*
|
|
@@ -82,7 +81,7 @@ type InferEnvSchema<T> = {
|
|
|
82
81
|
* })
|
|
83
82
|
* ```
|
|
84
83
|
*/
|
|
85
|
-
|
|
84
|
+
declare function validateEnv<T extends Record<string, SchemaEntry>>(schema: T, source?: Record<string, string | undefined>): InferEnvSchema<T>;
|
|
86
85
|
/**
|
|
87
86
|
* Extract public environment variables (prefixed with `ZERO_PUBLIC_`).
|
|
88
87
|
*
|
|
@@ -95,8 +94,8 @@ export declare function validateEnv<T extends Record<string, SchemaEntry>>(schem
|
|
|
95
94
|
* // → validated against ZERO_PUBLIC_API_URL, ZERO_PUBLIC_APP_NAME
|
|
96
95
|
* ```
|
|
97
96
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
declare function publicEnv(): Record<string, string>;
|
|
98
|
+
declare function publicEnv<T extends Record<string, SchemaEntry>>(schema: T): InferEnvSchema<T>;
|
|
100
99
|
/**
|
|
101
100
|
* Create an env validator from a custom parse function.
|
|
102
101
|
* Use this to integrate any schema library (Zod, Valibot, ArkType, etc.).
|
|
@@ -113,6 +112,7 @@ export declare function publicEnv<T extends Record<string, SchemaEntry>>(schema:
|
|
|
113
112
|
* })
|
|
114
113
|
* ```
|
|
115
114
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
declare function schema<T>(parse: (raw: string) => T): EnvValidator<T>;
|
|
116
|
+
//#endregion
|
|
117
|
+
export { EnvValidator, EnvValidatorOptions, bool, num, oneOf, publicEnv, schema, str, url, validateEnv };
|
|
118
|
+
//# sourceMappingURL=env2.d.ts.map
|