weifuwu 0.25.2 → 0.27.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/README.md +291 -2489
- package/ai/provider.ts +129 -0
- package/ai/stream.ts +63 -0
- package/cli.ts +55 -257
- package/core/cookie.ts +114 -0
- package/core/env.ts +142 -0
- package/core/logger.ts +72 -0
- package/core/router.ts +795 -0
- package/core/serve.ts +294 -0
- package/core/sse.ts +85 -0
- package/core/trace.ts +146 -0
- package/graphql.ts +267 -0
- package/hub.ts +133 -0
- package/index.ts +71 -0
- package/mailer.ts +81 -0
- package/middleware/compress.ts +103 -0
- package/middleware/cors.ts +81 -0
- package/middleware/csrf.ts +112 -0
- package/middleware/flash.ts +144 -0
- package/middleware/health.ts +44 -0
- package/middleware/helmet.ts +98 -0
- package/middleware/i18n.ts +175 -0
- package/middleware/rate-limit.ts +167 -0
- package/middleware/request-id.ts +60 -0
- package/middleware/static.ts +149 -0
- package/middleware/theme.ts +84 -0
- package/middleware/upload.ts +168 -0
- package/middleware/validate.ts +186 -0
- package/package.json +14 -36
- package/postgres/client.ts +132 -0
- package/postgres/index.ts +4 -0
- package/postgres/module.ts +37 -0
- package/postgres/schema/columns.ts +186 -0
- package/postgres/schema/index.ts +36 -0
- package/postgres/schema/sql.ts +39 -0
- package/postgres/schema/table.ts +548 -0
- package/postgres/schema/where.ts +99 -0
- package/postgres/types.ts +48 -0
- package/queue/cron.ts +90 -0
- package/queue/index.ts +654 -0
- package/queue/types.ts +60 -0
- package/redis/client.ts +24 -0
- package/{dist/redis/index.d.ts → redis/index.ts} +2 -2
- package/redis/types.ts +28 -0
- package/types.ts +78 -0
- package/cli/template/app.ts +0 -22
- package/cli/template/index.ts +0 -10
- package/cli/template/locales/en.json +0 -13
- package/cli/template/locales/zh-CN.json +0 -13
- package/cli/template/locales/zh-TW.json +0 -13
- package/cli/template/locales/zh.json +0 -13
- package/cli/template/ui/app/globals.css +0 -2
- package/cli/template/ui/app/layout.tsx +0 -15
- package/cli/template/ui/app/page.tsx +0 -124
- package/cli/template/ui/components/Greeting.tsx +0 -3
- package/dist/agent/client.d.ts +0 -2
- package/dist/agent/index.d.ts +0 -2
- package/dist/agent/rest.d.ts +0 -14
- package/dist/agent/run.d.ts +0 -19
- package/dist/agent/types.d.ts +0 -55
- package/dist/ai/provider.d.ts +0 -45
- package/dist/ai/utils.d.ts +0 -5
- package/dist/ai/workflow.d.ts +0 -17
- package/dist/ai-sdk.d.ts +0 -2
- package/dist/ai.d.ts +0 -13
- package/dist/analytics.d.ts +0 -45
- package/dist/auth.d.ts +0 -22
- package/dist/cache.d.ts +0 -74
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -302
- package/dist/client-locale.d.ts +0 -25
- package/dist/client-pref.d.ts +0 -3
- package/dist/client-router.d.ts +0 -300
- package/dist/client-state.d.ts +0 -22
- package/dist/client-theme.d.ts +0 -36
- package/dist/compile.d.ts +0 -15
- package/dist/compress.d.ts +0 -20
- package/dist/cookie.d.ts +0 -36
- package/dist/cors.d.ts +0 -25
- package/dist/cron-utils.d.ts +0 -73
- package/dist/csrf.d.ts +0 -47
- package/dist/deploy/config.d.ts +0 -2
- package/dist/deploy/gateway.d.ts +0 -2
- package/dist/deploy/index.d.ts +0 -4
- package/dist/deploy/manager.d.ts +0 -16
- package/dist/deploy/process.d.ts +0 -14
- package/dist/deploy/types.d.ts +0 -53
- package/dist/env.d.ts +0 -69
- package/dist/error-boundary.d.ts +0 -2
- package/dist/flash.d.ts +0 -90
- package/dist/fts.d.ts +0 -36
- package/dist/graphql.d.ts +0 -16
- package/dist/head.d.ts +0 -6
- package/dist/health.d.ts +0 -24
- package/dist/helmet.d.ts +0 -33
- package/dist/html-shell.d.ts +0 -1
- package/dist/hub.d.ts +0 -37
- package/dist/i18n.d.ts +0 -39
- package/dist/iii/client.d.ts +0 -2
- package/dist/iii/index.d.ts +0 -4
- package/dist/iii/register-worker.d.ts +0 -9
- package/dist/iii/rest.d.ts +0 -3
- package/dist/iii/stream.d.ts +0 -82
- package/dist/iii/types.d.ts +0 -121
- package/dist/iii/worker.d.ts +0 -2
- package/dist/iii/ws.d.ts +0 -22
- package/dist/index.d.ts +0 -101
- package/dist/index.js +0 -12752
- package/dist/kb/index.d.ts +0 -3
- package/dist/kb/types.d.ts +0 -72
- package/dist/layout.d.ts +0 -2
- package/dist/live.d.ts +0 -7
- package/dist/logdb/client.d.ts +0 -2
- package/dist/logdb/index.d.ts +0 -2
- package/dist/logdb/rest.d.ts +0 -5
- package/dist/logdb/types.d.ts +0 -27
- package/dist/logger.d.ts +0 -16
- package/dist/mailer.d.ts +0 -51
- package/dist/mcp.d.ts +0 -34
- package/dist/messager/agent.d.ts +0 -11
- package/dist/messager/client.d.ts +0 -2
- package/dist/messager/index.d.ts +0 -2
- package/dist/messager/rest.d.ts +0 -15
- package/dist/messager/types.d.ts +0 -57
- package/dist/messager/ws.d.ts +0 -14
- package/dist/module-server.d.ts +0 -9
- package/dist/not-found.d.ts +0 -2
- package/dist/notifier/client.d.ts +0 -2
- package/dist/notifier/index.d.ts +0 -2
- package/dist/notifier/types.d.ts +0 -105
- package/dist/opencode/client.d.ts +0 -2
- package/dist/opencode/index.d.ts +0 -2
- package/dist/opencode/permissions.d.ts +0 -5
- package/dist/opencode/prompt.d.ts +0 -8
- package/dist/opencode/rest.d.ts +0 -16
- package/dist/opencode/run.d.ts +0 -13
- package/dist/opencode/session.d.ts +0 -26
- package/dist/opencode/skills.d.ts +0 -4
- package/dist/opencode/tools/bash.d.ts +0 -6
- package/dist/opencode/tools/edit.d.ts +0 -19
- package/dist/opencode/tools/glob.d.ts +0 -9
- package/dist/opencode/tools/grep.d.ts +0 -17
- package/dist/opencode/tools/index.d.ts +0 -12
- package/dist/opencode/tools/question.d.ts +0 -5
- package/dist/opencode/tools/read.d.ts +0 -16
- package/dist/opencode/tools/skill.d.ts +0 -18
- package/dist/opencode/tools/web.d.ts +0 -18
- package/dist/opencode/tools/write.d.ts +0 -13
- package/dist/opencode/types.d.ts +0 -90
- package/dist/opencode/ws.d.ts +0 -21
- package/dist/permissions.d.ts +0 -51
- package/dist/postgres/client.d.ts +0 -4
- package/dist/postgres/index.d.ts +0 -4
- package/dist/postgres/module.d.ts +0 -17
- package/dist/postgres/schema/columns.d.ts +0 -99
- package/dist/postgres/schema/index.d.ts +0 -6
- package/dist/postgres/schema/sql.d.ts +0 -22
- package/dist/postgres/schema/table.d.ts +0 -141
- package/dist/postgres/schema/where.d.ts +0 -29
- package/dist/postgres/types.d.ts +0 -50
- package/dist/queue/index.d.ts +0 -2
- package/dist/queue/types.d.ts +0 -62
- package/dist/rate-limit.d.ts +0 -45
- package/dist/react.d.ts +0 -14
- package/dist/react.js +0 -751
- package/dist/redis/client.d.ts +0 -2
- package/dist/redis/types.d.ts +0 -18
- package/dist/request-id.d.ts +0 -40
- package/dist/router.d.ts +0 -73
- package/dist/s3.d.ts +0 -68
- package/dist/seo.d.ts +0 -104
- package/dist/serve.d.ts +0 -38
- package/dist/server-registry.d.ts +0 -10
- package/dist/session.d.ts +0 -117
- package/dist/sse.d.ts +0 -47
- package/dist/ssr-entries.d.ts +0 -4
- package/dist/ssr.d.ts +0 -11
- package/dist/static.d.ts +0 -23
- package/dist/stream.d.ts +0 -24
- package/dist/tailwind.d.ts +0 -15
- package/dist/tenant/client.d.ts +0 -2
- package/dist/tenant/graphql.d.ts +0 -3
- package/dist/tenant/index.d.ts +0 -2
- package/dist/tenant/rest.d.ts +0 -3
- package/dist/tenant/schema.d.ts +0 -5
- package/dist/tenant/types.d.ts +0 -48
- package/dist/tenant/utils.d.ts +0 -9
- package/dist/test-utils.d.ts +0 -194
- package/dist/theme.d.ts +0 -31
- package/dist/trace.d.ts +0 -95
- package/dist/tsx-context.d.ts +0 -32
- package/dist/types.d.ts +0 -47
- package/dist/upload.d.ts +0 -55
- package/dist/use-action.d.ts +0 -42
- package/dist/use-agent-stream.d.ts +0 -49
- package/dist/use-flash-message.d.ts +0 -17
- package/dist/use-websocket.d.ts +0 -42
- package/dist/user/client.d.ts +0 -30
- package/dist/user/index.d.ts +0 -2
- package/dist/user/oauth-login.d.ts +0 -21
- package/dist/user/oauth2.d.ts +0 -31
- package/dist/user/types.d.ts +0 -178
- package/dist/validate.d.ts +0 -32
- package/dist/vendor.d.ts +0 -7
- package/dist/webhook.d.ts +0 -79
- package/opencode/ui/app/globals.css +0 -1
- package/opencode/ui/app/layout.tsx +0 -13
- package/opencode/ui/app/page.tsx +0 -523
package/dist/redis/client.d.ts
DELETED
package/dist/redis/types.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Redis, RedisOptions as IORedisOptions } from '../vendor.ts';
|
|
2
|
-
import type { Context, Middleware, Closeable } from '../types.ts';
|
|
3
|
-
declare module '../types.ts' {
|
|
4
|
-
interface Context {
|
|
5
|
-
redis: Redis;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export type { Redis };
|
|
9
|
-
export type RedisOptions = IORedisOptions & {
|
|
10
|
-
url?: string;
|
|
11
|
-
};
|
|
12
|
-
export interface RedisInjected {
|
|
13
|
-
redis: Redis;
|
|
14
|
-
}
|
|
15
|
-
export interface RedisClient extends Middleware<Context, Context & RedisInjected>, Closeable {
|
|
16
|
-
redis: Redis;
|
|
17
|
-
close: () => Promise<void>;
|
|
18
|
-
}
|
package/dist/request-id.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { Context, Middleware } from './types.ts';
|
|
2
|
-
declare module './types.ts' {
|
|
3
|
-
interface Context {
|
|
4
|
-
requestId: string;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
/** Options for {@link requestId}. */
|
|
8
|
-
/** Request ID module — a {@link Middleware} that injects `ctx.requestId`. */
|
|
9
|
-
export type RequestIdModule = Middleware<Context, Context & {
|
|
10
|
-
requestId: string;
|
|
11
|
-
}>;
|
|
12
|
-
export interface RequestIdOptions {
|
|
13
|
-
/** Header name for request ID (default: `'X-Request-ID'`). */
|
|
14
|
-
header?: string;
|
|
15
|
-
/** Custom ID generator (default: `crypto.randomUUID`). */
|
|
16
|
-
generator?: () => string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Request ID middleware.
|
|
20
|
-
*
|
|
21
|
-
* @deprecated Use `trace()` from 'weifuwu' instead — it injects `ctx.trace.requestId`
|
|
22
|
-
* along with `traceId` and `elapsed()` in a single middleware.
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* // Old:
|
|
26
|
-
* app.use(requestId())
|
|
27
|
-
* ctx.requestId
|
|
28
|
-
*
|
|
29
|
-
* // New:
|
|
30
|
-
* app.use(trace())
|
|
31
|
-
* ctx.trace.requestId
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* Reads an incoming `X-Request-ID` header (or custom header name) from the
|
|
35
|
-
* request. If absent, generates a new UUID. Sets the response header and
|
|
36
|
-
* injects `ctx.requestId`.
|
|
37
|
-
*/
|
|
38
|
-
export declare function requestId(options?: RequestIdOptions): Middleware<Context, Context & {
|
|
39
|
-
requestId: string;
|
|
40
|
-
}>;
|
package/dist/router.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { WebSocket } from './vendor.ts';
|
|
2
|
-
import { type IncomingMessage } from 'node:http';
|
|
3
|
-
import type { Duplex } from 'node:stream';
|
|
4
|
-
import type { Context, Handler, Middleware, ErrorHandler } from './types.ts';
|
|
5
|
-
import { type Hub } from './hub.ts';
|
|
6
|
-
export type WebSocketHandler = {
|
|
7
|
-
open?: (ws: WebSocket, ctx: Context) => void | Promise<void>;
|
|
8
|
-
message?: (ws: WebSocket, ctx: Context, data: string | Buffer) => void | Promise<void>;
|
|
9
|
-
close?: (ws: WebSocket, ctx: Context) => void | Promise<void>;
|
|
10
|
-
error?: (ws: WebSocket, ctx: Context, error: Error) => void | Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
type WsUpgradeHandler = (req: IncomingMessage, socket: Duplex, head: Buffer) => void;
|
|
13
|
-
export declare class Router<T extends Context = Context> {
|
|
14
|
-
private root;
|
|
15
|
-
private wsRoot;
|
|
16
|
-
private globalMws;
|
|
17
|
-
private errorHandler?;
|
|
18
|
-
private _hasWildcard;
|
|
19
|
-
private _hub?;
|
|
20
|
-
private _wss?;
|
|
21
|
-
/** Track which ctx fields have been injected so far (for dependency checking). */
|
|
22
|
-
private _ctxFields;
|
|
23
|
-
private get wss();
|
|
24
|
-
private get hub();
|
|
25
|
-
/** Inject a custom hub (e.g. with Redis for cross-process broadcast). */
|
|
26
|
-
wsHub(hub: Hub): this;
|
|
27
|
-
use<Out extends Context>(mw: Middleware<Context, Out>): Router<T & Out>;
|
|
28
|
-
use(path: string, mw: Middleware<T, T>): Router<T>;
|
|
29
|
-
use(path: string, router: Router<Context>): Router<T>;
|
|
30
|
-
use(mod: Router & {
|
|
31
|
-
middleware: () => Middleware;
|
|
32
|
-
}): Router<T>;
|
|
33
|
-
/**
|
|
34
|
-
* Check a middleware's dependency metadata and emit warnings if
|
|
35
|
-
* required fields haven't been injected yet.
|
|
36
|
-
* Attach __meta to a middleware function:
|
|
37
|
-
*
|
|
38
|
-
* ```ts
|
|
39
|
-
* mw.__meta = { injects: ['sql'], depends: ['session'] }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
private _checkMiddlewareMeta;
|
|
43
|
-
get(path: string, ...args: [...Middleware<T, T>[], Handler<T> | Router<Context>]): Router<T>;
|
|
44
|
-
post(path: string, ...args: [...Middleware<T, T>[], Handler<T> | Router<Context>]): Router<T>;
|
|
45
|
-
put(path: string, ...args: [...Middleware<T, T>[], Handler<T> | Router<Context>]): Router<T>;
|
|
46
|
-
delete(path: string, ...args: [...Middleware<T, T>[], Handler<T> | Router<Context>]): Router<T>;
|
|
47
|
-
patch(path: string, ...args: [...Middleware<T, T>[], Handler<T> | Router<Context>]): Router<T>;
|
|
48
|
-
head(path: string, ...args: [...Middleware<T, T>[], Handler<T> | Router<Context>]): Router<T>;
|
|
49
|
-
options(path: string, ...args: [...Middleware<T, T>[], Handler<T> | Router<Context>]): Router<T>;
|
|
50
|
-
all(path: string, ...args: [...Middleware<T, T>[], Handler<T> | Router<Context>]): Router<T>;
|
|
51
|
-
onError(handler: ErrorHandler<T>): Router<T>;
|
|
52
|
-
private _route;
|
|
53
|
-
/** Internal route registration — no type constraints (used by _mountRouter). */
|
|
54
|
-
private _routeImpl;
|
|
55
|
-
ws(path: string, ...args: [...Middleware<T, T>[], WebSocketHandler]): Router<T>;
|
|
56
|
-
handler(): Handler<T>;
|
|
57
|
-
/** Returns a human-readable list of all registered routes. Useful for debugging. */
|
|
58
|
-
routes(): string[];
|
|
59
|
-
private _collectRoutes;
|
|
60
|
-
private _collectWsRoutes;
|
|
61
|
-
websocketHandler(): WsUpgradeHandler;
|
|
62
|
-
private _mountRouter;
|
|
63
|
-
private mergeMws;
|
|
64
|
-
private _collect;
|
|
65
|
-
private _collectWs;
|
|
66
|
-
private splitPath;
|
|
67
|
-
private matchTrie;
|
|
68
|
-
private matchWsTrie;
|
|
69
|
-
private handleError;
|
|
70
|
-
private handle;
|
|
71
|
-
private runChain;
|
|
72
|
-
}
|
|
73
|
-
export {};
|
package/dist/s3.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
-
import type { Middleware } from './types.ts';
|
|
3
|
-
import type { Readable } from 'node:stream';
|
|
4
|
-
declare module './types.ts' {
|
|
5
|
-
interface Context {
|
|
6
|
-
s3: S3Module;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export interface S3Options {
|
|
10
|
-
/** S3 bucket name. Required. */
|
|
11
|
-
bucket: string;
|
|
12
|
-
/** AWS region. Default: 'us-east-1'. */
|
|
13
|
-
region?: string;
|
|
14
|
-
/** Custom endpoint (MinIO, Cloudflare R2, Backblaze B2, etc.). */
|
|
15
|
-
endpoint?: string;
|
|
16
|
-
/** Force path-style addressing (required for MinIO, some private clouds). */
|
|
17
|
-
forcePathStyle?: boolean;
|
|
18
|
-
/** AWS credentials. Falls back to AWS env vars / IAM role if omitted. */
|
|
19
|
-
credentials?: {
|
|
20
|
-
accessKeyId: string;
|
|
21
|
-
secretAccessKey: string;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Base public URL for unsigned URLs.
|
|
25
|
-
* When set, `s3.url(key, { expiresIn: 0 })` returns a public URL.
|
|
26
|
-
* Example: 'https://cdn.example.com' or 'https://pub-xxx.r2.dev'
|
|
27
|
-
*/
|
|
28
|
-
publicUrl?: string;
|
|
29
|
-
}
|
|
30
|
-
export interface S3PutOptions {
|
|
31
|
-
/** Content-Type of the object. */
|
|
32
|
-
contentType?: string;
|
|
33
|
-
/** Cache-Control header value. */
|
|
34
|
-
cacheControl?: string;
|
|
35
|
-
/** User-defined metadata (prefix x-amz-meta-). */
|
|
36
|
-
metadata?: Record<string, string>;
|
|
37
|
-
}
|
|
38
|
-
export interface S3UrlOptions {
|
|
39
|
-
/**
|
|
40
|
-
* Signed URL expiry in seconds.
|
|
41
|
-
* Default: 3600 (1 hour).
|
|
42
|
-
* Set to 0 to return an unsigned public URL (requires `publicUrl` option).
|
|
43
|
-
*/
|
|
44
|
-
expiresIn?: number;
|
|
45
|
-
}
|
|
46
|
-
export interface S3Module {
|
|
47
|
-
/** Upload a file. Returns the key. */
|
|
48
|
-
put(key: string, body: S3Body, options?: S3PutOptions): Promise<string>;
|
|
49
|
-
/** Download a file. Returns the body as Buffer, or null if not found. */
|
|
50
|
-
get(key: string): Promise<Buffer | null>;
|
|
51
|
-
/** Delete a file. */
|
|
52
|
-
delete(key: string): Promise<void>;
|
|
53
|
-
/** Check if a file exists. */
|
|
54
|
-
exists(key: string): Promise<boolean>;
|
|
55
|
-
/**
|
|
56
|
-
* Generate a URL for an object.
|
|
57
|
-
* - If `expiresIn` > 0 (default): returns a signed URL with that expiry.
|
|
58
|
-
* - If `expiresIn` === 0 and `publicUrl` is configured: returns an unsigned
|
|
59
|
-
* public URL. Throws if `publicUrl` is not set.
|
|
60
|
-
*/
|
|
61
|
-
url(key: string, options?: S3UrlOptions): Promise<string>;
|
|
62
|
-
/** List object keys under a prefix. */
|
|
63
|
-
list(prefix?: string): Promise<string[]>;
|
|
64
|
-
/** The underlying S3Client (for advanced usage). */
|
|
65
|
-
client: S3Client;
|
|
66
|
-
}
|
|
67
|
-
export type S3Body = Buffer | Uint8Array | string | ReadableStream | Readable;
|
|
68
|
-
export declare function s3(options: S3Options): S3Module & Middleware;
|
package/dist/seo.d.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { Middleware, Context } from './types.ts';
|
|
2
|
-
import { Router } from './router.ts';
|
|
3
|
-
/** A rule in `robots.txt`. */
|
|
4
|
-
export interface RobotsRule {
|
|
5
|
-
/** User-agent this rule applies to (default: `'*'`). */
|
|
6
|
-
userAgent?: string;
|
|
7
|
-
/** Path(s) to allow. */
|
|
8
|
-
allow?: string | string[];
|
|
9
|
-
/** Path(s) to disallow. */
|
|
10
|
-
disallow?: string | string[];
|
|
11
|
-
}
|
|
12
|
-
/** A URL entry in `sitemap.xml`. */
|
|
13
|
-
export interface SitemapUrl {
|
|
14
|
-
/** Absolute URL of the page. */
|
|
15
|
-
loc: string;
|
|
16
|
-
/** Last modification date (ISO 8601). */
|
|
17
|
-
lastmod?: string;
|
|
18
|
-
/** Expected change frequency. */
|
|
19
|
-
changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
20
|
-
/** Priority (0.0 to 1.0). */
|
|
21
|
-
priority?: number;
|
|
22
|
-
}
|
|
23
|
-
/** Configuration for sitemap generation. */
|
|
24
|
-
export interface SitemapConfig {
|
|
25
|
-
/** Static list of URLs to include. */
|
|
26
|
-
urls?: SitemapUrl[];
|
|
27
|
-
/** Dynamic URL resolver (called on each sitemap request, or cached per `cacheTTL`). */
|
|
28
|
-
resolve?: () => SitemapUrl[] | Promise<SitemapUrl[]>;
|
|
29
|
-
/** Cache TTL in ms (default: 3600000 = 1 hour). Set 0 to disable cache. */
|
|
30
|
-
cacheTTL?: number;
|
|
31
|
-
}
|
|
32
|
-
/** Configuration for per-path response headers. */
|
|
33
|
-
export interface SeoHeadersConfig {
|
|
34
|
-
/** `X-Robots-Tag` header value. Use a function for path-dependent values. */
|
|
35
|
-
'X-Robots-Tag'?: string | ((path: string) => string | undefined);
|
|
36
|
-
}
|
|
37
|
-
/** Options for {@link seo}. */
|
|
38
|
-
export interface SeoOptions {
|
|
39
|
-
/** Rules for `robots.txt`. */
|
|
40
|
-
robots?: RobotsRule[];
|
|
41
|
-
/** Configuration for `sitemap.xml`. */
|
|
42
|
-
sitemap?: SitemapConfig;
|
|
43
|
-
/** Per-path response headers. */
|
|
44
|
-
headers?: SeoHeadersConfig;
|
|
45
|
-
baseUrl?: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* SEO middleware — sets `X-Robots-Tag` headers per path.
|
|
49
|
-
* Used standalone or included automatically by {@link seo}.
|
|
50
|
-
*
|
|
51
|
-
* ```ts
|
|
52
|
-
* app.use(seoMiddleware({
|
|
53
|
-
* headers: { 'X-Robots-Tag': (path) => path.startsWith('/admin') ? 'noindex' : undefined },
|
|
54
|
-
* }))
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export declare function seoMiddleware(options?: SeoOptions): Middleware<Context, Context>;
|
|
58
|
-
/**
|
|
59
|
-
* SEO module — serves `robots.txt` and `sitemap.xml`.
|
|
60
|
-
*
|
|
61
|
-
* ```ts
|
|
62
|
-
* import { seo } from 'weifuwu'
|
|
63
|
-
*
|
|
64
|
-
* app.use(seo({
|
|
65
|
-
* robots: [{ userAgent: '*', allow: '/', disallow: '/admin' }],
|
|
66
|
-
* sitemap: {
|
|
67
|
-
* resolve: async () => [
|
|
68
|
-
* { loc: 'https://example.com/', changefreq: 'daily', priority: 1.0 },
|
|
69
|
-
* ],
|
|
70
|
-
* },
|
|
71
|
-
* }))
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export declare function seo(options?: SeoOptions): Router;
|
|
75
|
-
/** Options for {@link seoTags}. */
|
|
76
|
-
export interface SeoTagsConfig {
|
|
77
|
-
/** Page title (`<title>` + `og:title`). */
|
|
78
|
-
title?: string;
|
|
79
|
-
/** Meta description. */
|
|
80
|
-
description?: string;
|
|
81
|
-
/** Open Graph image URL. */
|
|
82
|
-
ogImage?: string;
|
|
83
|
-
/** Override `og:title` (defaults to `title`). */
|
|
84
|
-
ogTitle?: string;
|
|
85
|
-
/** Override `og:description` (defaults to `description`). */
|
|
86
|
-
ogDescription?: string;
|
|
87
|
-
/** Twitter card type. */
|
|
88
|
-
twitterCard?: 'summary' | 'summary_large_image';
|
|
89
|
-
/** Canonical URL (`<link rel="canonical">`). */
|
|
90
|
-
canonical?: string;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Generate `<meta>` and `<link>` tag HTML string for SEO.
|
|
94
|
-
*
|
|
95
|
-
* ```ts
|
|
96
|
-
* const tags = seoTags({
|
|
97
|
-
* title: 'My App',
|
|
98
|
-
* description: 'A description',
|
|
99
|
-
* ogImage: 'https://example.com/og.png',
|
|
100
|
-
* })
|
|
101
|
-
* // <meta name="description" content="A description" />...
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
export declare function seoTags(config: SeoTagsConfig): string;
|
package/dist/serve.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type IncomingMessage, type ServerResponse } from 'node:http';
|
|
2
|
-
import type { Duplex } from 'node:stream';
|
|
3
|
-
import { type Handler } from './types.ts';
|
|
4
|
-
export interface ServeOptions {
|
|
5
|
-
port?: number;
|
|
6
|
-
hostname?: string;
|
|
7
|
-
signal?: AbortSignal;
|
|
8
|
-
websocket?: (req: IncomingMessage, socket: Duplex, head: Buffer) => void;
|
|
9
|
-
/** Max request body size in bytes. Default: 10MB. Set to 0 for unlimited. */
|
|
10
|
-
maxBodySize?: number;
|
|
11
|
-
/** Socket timeout in ms (inactivity). Default: 30_000. */
|
|
12
|
-
timeout?: number;
|
|
13
|
-
/** Keep-Alive idle timeout in ms. Default: 5_000. */
|
|
14
|
-
keepAliveTimeout?: number;
|
|
15
|
-
/** Headers timeout in ms (must be > keepAliveTimeout). Default: 6_000. */
|
|
16
|
-
headersTimeout?: number;
|
|
17
|
-
shutdown?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface Server {
|
|
20
|
-
stop: (timeoutMs?: number) => Promise<void>;
|
|
21
|
-
/** Alias for `stop()`. Prefer this for consistency with other modules. */
|
|
22
|
-
close: (timeoutMs?: number) => Promise<void>;
|
|
23
|
-
readonly port: number;
|
|
24
|
-
readonly hostname: string;
|
|
25
|
-
ready: Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
/** Default max body size: 10MB. Set maxBodySize: 0 for unlimited. */
|
|
28
|
-
export declare const DEFAULT_MAX_BODY: number;
|
|
29
|
-
export declare function readBody(req: IncomingMessage, maxSize?: number): Promise<Buffer>;
|
|
30
|
-
export declare function createRequest(req: IncomingMessage, body: Buffer): [Request, Record<string, string>];
|
|
31
|
-
export declare function sendResponse(res: ServerResponse, response: Response, opts?: {
|
|
32
|
-
traceId?: string | null;
|
|
33
|
-
}): Promise<void>;
|
|
34
|
-
export declare function createTestServer(handler: Handler, options?: ServeOptions): Promise<{
|
|
35
|
-
server: Server;
|
|
36
|
-
url: string;
|
|
37
|
-
}>;
|
|
38
|
-
export declare function serve(handler: Handler, options?: ServeOptions): Server;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get (or load) a server-side module. Cached in registry after first load.
|
|
3
|
-
* Synchronous — uses transformSync and vm.Script.
|
|
4
|
-
*/
|
|
5
|
-
export declare function getServerModule(absPath: string): any;
|
|
6
|
-
/**
|
|
7
|
-
* Clear cached modules. If `absPath` given, clear only that module (for HMR).
|
|
8
|
-
* Otherwise clear all modules.
|
|
9
|
-
*/
|
|
10
|
-
export declare function clearServerModule(absPath?: string): void;
|
package/dist/session.d.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { Context, Middleware, Closeable } from './types.ts';
|
|
2
|
-
import type { Redis } from './vendor.ts';
|
|
3
|
-
declare module './types.ts' {
|
|
4
|
-
interface Context {
|
|
5
|
-
session: Session;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
declare const kSaved: unique symbol;
|
|
9
|
-
declare const kDestroyed: unique symbol;
|
|
10
|
-
declare const kId: unique symbol;
|
|
11
|
-
declare const kStore: unique symbol;
|
|
12
|
-
declare const kTtl: unique symbol;
|
|
13
|
-
export interface SessionData {
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
}
|
|
16
|
-
/** The session object injected into ctx.session. Plain data + control methods. */
|
|
17
|
-
export interface Session extends SessionData {
|
|
18
|
-
/** Mark session as modified. Auto-detected on mutation, but call explicitly for deep mutations. */
|
|
19
|
-
save(): void;
|
|
20
|
-
/** Destroy session. Clears data and removes from store on response. */
|
|
21
|
-
destroy(): void;
|
|
22
|
-
/** Session ID (readonly). */
|
|
23
|
-
readonly id: string;
|
|
24
|
-
[kSaved]: boolean;
|
|
25
|
-
[kDestroyed]: boolean;
|
|
26
|
-
[kId]: string;
|
|
27
|
-
[kStore]: SessionStore;
|
|
28
|
-
[kTtl]: number;
|
|
29
|
-
}
|
|
30
|
-
export interface SessionStore extends Closeable {
|
|
31
|
-
get(sid: string): Promise<Record<string, unknown> | null>;
|
|
32
|
-
set(sid: string, data: Record<string, unknown>, ttl: number): Promise<void>;
|
|
33
|
-
destroy(sid: string): Promise<void>;
|
|
34
|
-
/** Release resources. Default no-op. */
|
|
35
|
-
close(): Promise<void>;
|
|
36
|
-
}
|
|
37
|
-
export interface SessionOptions {
|
|
38
|
-
/** Session store. 'memory' (default) or 'redis'. */
|
|
39
|
-
store?: 'memory' | 'redis' | SessionStore;
|
|
40
|
-
/** Redis client (required when store: 'redis'). */
|
|
41
|
-
redis?: Redis;
|
|
42
|
-
/** Session TTL in milliseconds. Default: 24 hours. */
|
|
43
|
-
ttl?: number;
|
|
44
|
-
/** Cookie name. Default: '__session'. */
|
|
45
|
-
cookieName?: string;
|
|
46
|
-
/** Cookie options. */
|
|
47
|
-
cookie?: {
|
|
48
|
-
path?: string;
|
|
49
|
-
domain?: string;
|
|
50
|
-
httpOnly?: boolean;
|
|
51
|
-
secure?: boolean;
|
|
52
|
-
sameSite?: 'strict' | 'lax' | 'none';
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Secret for signing the session cookie with HMAC-SHA256.
|
|
56
|
-
* When set, the cookie value becomes `sid.signature` — tampering is detected
|
|
57
|
-
* and rejected. Strongly recommended in production.
|
|
58
|
-
*/
|
|
59
|
-
secret?: string;
|
|
60
|
-
/**
|
|
61
|
-
* Interval (ms) for automatic session ID rotation.
|
|
62
|
-
* Rotating the ID mitigates session fixation attacks.
|
|
63
|
-
* Default: 900_000 (15 min). Set to 0 to disable.
|
|
64
|
-
*/
|
|
65
|
-
rotateInterval?: number;
|
|
66
|
-
}
|
|
67
|
-
export interface SessionInjected {
|
|
68
|
-
session: Session;
|
|
69
|
-
sessionId: string;
|
|
70
|
-
}
|
|
71
|
-
export declare class MemoryStore implements SessionStore {
|
|
72
|
-
private store;
|
|
73
|
-
private interval;
|
|
74
|
-
constructor(cleanupMs?: number);
|
|
75
|
-
get(sid: string): Promise<Record<string, unknown> | null>;
|
|
76
|
-
set(sid: string, data: Record<string, unknown>, ttl: number): Promise<void>;
|
|
77
|
-
destroy(sid: string): Promise<void>;
|
|
78
|
-
private cleanup;
|
|
79
|
-
close(): Promise<void>;
|
|
80
|
-
/** Testing only: return approximate count. */
|
|
81
|
-
get size(): number;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Redis-backed session store.
|
|
85
|
-
* Pass to `session({ store: new RedisStore({ redis }) })`.
|
|
86
|
-
*/
|
|
87
|
-
export declare class RedisStore implements SessionStore {
|
|
88
|
-
private redis;
|
|
89
|
-
private prefix;
|
|
90
|
-
constructor(redis: Redis, prefix?: string);
|
|
91
|
-
private key;
|
|
92
|
-
get(sid: string): Promise<Record<string, unknown> | null>;
|
|
93
|
-
set(sid: string, data: Record<string, unknown>, ttl: number): Promise<void>;
|
|
94
|
-
destroy(sid: string): Promise<void>;
|
|
95
|
-
close(): Promise<void>;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Session middleware. Injects `ctx.session` with a persistent key-value store
|
|
99
|
-
* scoped to the request. Data is automatically saved to the store on response.
|
|
100
|
-
*
|
|
101
|
-
* Defaults to memory store. Use `{ store: 'redis', redis }` for multi-process setups.
|
|
102
|
-
*
|
|
103
|
-
* ```ts
|
|
104
|
-
* import { session } from 'weifuwu'
|
|
105
|
-
* app.use(session())
|
|
106
|
-
*
|
|
107
|
-
* app.get('/visit', (req, ctx) => {
|
|
108
|
-
* ctx.session.count = (ctx.session.count ?? 0) + 1
|
|
109
|
-
* return Response.json({ visits: ctx.session.count })
|
|
110
|
-
* })
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
export declare function session(options?: SessionOptions): Middleware<Context, Context & SessionInjected> & {
|
|
114
|
-
close: () => Promise<void>;
|
|
115
|
-
store: SessionStore;
|
|
116
|
-
};
|
|
117
|
-
export {};
|
package/dist/sse.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format an SSE message string with a named event type.
|
|
3
|
-
*
|
|
4
|
-
* ```ts
|
|
5
|
-
* formatSSE('ping', { ts: Date.now() })
|
|
6
|
-
* // "event: ping\ndata: {"ts":...}\n\n"
|
|
7
|
-
* ```
|
|
8
|
-
*/
|
|
9
|
-
export declare function formatSSE(event: string, data: unknown): string;
|
|
10
|
-
/**
|
|
11
|
-
* Format an SSE message string with only a data line (no event type).
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* formatSSEData({ message: 'hello' })
|
|
15
|
-
* // "data: {"message":"hello"}\n\n"
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function formatSSEData(data: unknown): string;
|
|
19
|
-
/** An SSE event to be sent via {@link createSSEStream}. */
|
|
20
|
-
export interface SSEEvent {
|
|
21
|
-
/** Event type (maps to `event:` field). */
|
|
22
|
-
event: string;
|
|
23
|
-
/** Event payload (serialized as JSON in `data:` field). */
|
|
24
|
-
data: unknown;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Create a Server-Sent Events (SSE) `Response` from an async iterable.
|
|
28
|
-
*
|
|
29
|
-
* Each item in the iterable is serialized as an SSE message:
|
|
30
|
-
* - If the item has a `.type` property → `event: {type}` + `data: {item}`
|
|
31
|
-
* - Otherwise → `data: {item}`
|
|
32
|
-
*
|
|
33
|
-
* Errors are sent as `event: error` messages. `AbortError` is silently ignored.
|
|
34
|
-
*
|
|
35
|
-
* ```ts
|
|
36
|
-
* app.get('/events', () => {
|
|
37
|
-
* async function* generate() {
|
|
38
|
-
* yield { type: 'ping', data: { ts: Date.now() } }
|
|
39
|
-
* }
|
|
40
|
-
* return createSSEStream(generate())
|
|
41
|
-
* })
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export declare function createSSEStream(iterable: AsyncIterable<any>, opts?: {
|
|
45
|
-
headers?: Record<string, string>;
|
|
46
|
-
status?: number;
|
|
47
|
-
}): Response;
|
package/dist/ssr-entries.d.ts
DELETED
package/dist/ssr.d.ts
DELETED
package/dist/static.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Handler } from './types.ts';
|
|
2
|
-
/** Options for {@link serveStatic}. */
|
|
3
|
-
export interface ServeStaticOptions {
|
|
4
|
-
/** Directory index filename (default: `'index.html'`). */
|
|
5
|
-
index?: string;
|
|
6
|
-
/** `Cache-Control max-age` in seconds. */
|
|
7
|
-
maxAge?: number;
|
|
8
|
-
/** Add `immutable` to `Cache-Control` (requires `maxAge`). */
|
|
9
|
-
immutable?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Static file serving handler.
|
|
13
|
-
*
|
|
14
|
-
* Serves files from a root directory. Supports ETag/304, directory index,
|
|
15
|
-
* Content-Type detection by extension, and directory traversal protection.
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* import { serveStatic, Router } from 'weifuwu'
|
|
19
|
-
* const app = new Router()
|
|
20
|
-
* app.get('/static/*', serveStatic('./public'))
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function serveStatic(root: string, options?: ServeStaticOptions): Handler;
|
package/dist/stream.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Context } from './types.ts';
|
|
2
|
-
/** Options for {@link streamResponse}. */
|
|
3
|
-
export interface StreamOpts {
|
|
4
|
-
/** Request context (for injecting hydration data). */
|
|
5
|
-
ctx: Context;
|
|
6
|
-
/** Base path for SSR asset URLs. */
|
|
7
|
-
base: string;
|
|
8
|
-
/** Tailwind CSS context. */
|
|
9
|
-
tailwind?: {
|
|
10
|
-
css: string;
|
|
11
|
-
url: string;
|
|
12
|
-
};
|
|
13
|
-
/** Whether in development mode (injects livereload script). */
|
|
14
|
-
isDev: boolean;
|
|
15
|
-
/** HTTP status code (default: 200). */
|
|
16
|
-
status?: number;
|
|
17
|
-
/** Serialized loader data injected into the HTML shell. */
|
|
18
|
-
loaderData?: Record<string, unknown>;
|
|
19
|
-
}
|
|
20
|
-
export declare function readStream(stream: ReadableStream): Promise<string>;
|
|
21
|
-
/**
|
|
22
|
-
* Create an HTML response from a React SSR stream.
|
|
23
|
-
*/
|
|
24
|
-
export declare function streamResponse(reactStream: ReadableStream, opts: StreamOpts, hydrationScript?: string): Response;
|
package/dist/tailwind.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Router } from './router.ts';
|
|
2
|
-
import type { Middleware } from './types.ts';
|
|
3
|
-
export interface TailwindInjected {
|
|
4
|
-
css: string;
|
|
5
|
-
url: string;
|
|
6
|
-
}
|
|
7
|
-
declare module './types.ts' {
|
|
8
|
-
interface Context {
|
|
9
|
-
tailwind?: TailwindInjected;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export declare function addTailwindSource(dir: string): void;
|
|
13
|
-
export declare function tailwindContext(dir: string): Middleware;
|
|
14
|
-
export declare function tailwindRouter(dir: string): Router;
|
|
15
|
-
export declare function compileTailwindCss(cssPath: string, cssDir: string): Promise<string>;
|
package/dist/tenant/client.d.ts
DELETED
package/dist/tenant/graphql.d.ts
DELETED
package/dist/tenant/index.d.ts
DELETED
package/dist/tenant/rest.d.ts
DELETED
package/dist/tenant/schema.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { FieldDef } from './types.ts';
|
|
2
|
-
export declare function createTableSQL(tenantId: string, slug: string, fields: FieldDef[]): string;
|
|
3
|
-
export declare function addColumnSQL(tenantId: string, slug: string, field: FieldDef): string;
|
|
4
|
-
export declare function dropTableSQL(tenantId: string, slug: string): string;
|
|
5
|
-
export declare function createIndexesSQL(tenantId: string, slug: string, fields: FieldDef[]): string[];
|