weifuwu 0.22.2 → 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/README.md +521 -76
- package/cli/template/.weifuwu/ssr/2e3a7e60.js +112 -0
- package/cli/template/app.ts +3 -2
- package/cli/template/index.ts +2 -1
- package/dist/agent/run.d.ts +4 -3
- package/dist/agent/types.d.ts +3 -0
- package/dist/ai/provider.d.ts +36 -0
- package/dist/ai/utils.d.ts +5 -0
- package/dist/ai/workflow.d.ts +3 -0
- package/dist/ai.d.ts +9 -1
- package/dist/auth.d.ts +14 -0
- package/dist/client-locale.d.ts +1 -1
- package/dist/client-router.d.ts +3 -3
- package/dist/client-theme.d.ts +1 -1
- package/dist/compile.d.ts +6 -0
- package/dist/cron-utils.d.ts +8 -0
- package/dist/flash.d.ts +24 -0
- package/dist/i18n.d.ts +14 -0
- package/dist/index.d.ts +15 -3
- package/dist/index.js +1597 -495
- package/dist/kb/index.d.ts +3 -0
- package/dist/kb/types.d.ts +64 -0
- package/dist/kb.d.ts +70 -0
- package/dist/oauth-client.d.ts +41 -0
- package/dist/permissions.d.ts +49 -0
- package/dist/queue/types.d.ts +12 -6
- package/dist/react.d.ts +1 -1
- package/dist/react.js +91 -86
- package/dist/s3.d.ts +68 -0
- package/dist/serve.d.ts +1 -1
- package/dist/session.d.ts +12 -1
- package/dist/ssr.d.ts +0 -1
- package/dist/stream.d.ts +5 -5
- package/dist/theme.d.ts +8 -0
- package/dist/tsx-context.d.ts +7 -1
- package/dist/types.d.ts +5 -3
- package/dist/user/index.d.ts +1 -1
- package/dist/user/oauth-login.d.ts +21 -0
- package/dist/user/types.d.ts +31 -0
- package/package.json +3 -1
package/dist/stream.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import type { Context } from './types.ts';
|
|
|
2
2
|
export interface StreamOpts {
|
|
3
3
|
ctx: Context;
|
|
4
4
|
base: string;
|
|
5
|
-
|
|
5
|
+
tailwind?: {
|
|
6
|
+
css: string;
|
|
7
|
+
url: string;
|
|
8
|
+
};
|
|
6
9
|
isDev: boolean;
|
|
7
10
|
status?: number;
|
|
8
|
-
bundle?: {
|
|
9
|
-
url: string;
|
|
10
|
-
} | null;
|
|
11
11
|
loaderData?: Record<string, unknown>;
|
|
12
12
|
}
|
|
13
13
|
export declare function readStream(stream: ReadableStream): Promise<string>;
|
|
14
|
-
export declare function streamResponse(reactStream: ReadableStream, opts: StreamOpts): Response;
|
|
14
|
+
export declare function streamResponse(reactStream: ReadableStream, opts: StreamOpts, hydrationScript?: string): Response;
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Middleware } from './types.ts';
|
|
2
|
+
export interface ThemeOptions {
|
|
3
|
+
/** Default theme value (default: 'system'). */
|
|
4
|
+
default?: string;
|
|
5
|
+
/** Cookie name (default: 'theme'). Set to empty string to disable cookie. */
|
|
6
|
+
cookie?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function theme(options?: ThemeOptions): Middleware;
|
package/dist/tsx-context.d.ts
CHANGED
|
@@ -5,10 +5,16 @@ export interface PageContext {
|
|
|
5
5
|
id?: string;
|
|
6
6
|
};
|
|
7
7
|
parsed: Record<string, unknown>;
|
|
8
|
-
|
|
8
|
+
theme?: string;
|
|
9
|
+
i18n?: {
|
|
10
|
+
locale: string;
|
|
11
|
+
t: (key: string, params?: Record<string, string>, fallback?: string) => string;
|
|
12
|
+
};
|
|
9
13
|
loaderData: Record<string, unknown>;
|
|
10
14
|
env: Record<string, string>;
|
|
11
15
|
}
|
|
16
|
+
type Rebuilder = (value: Partial<PageContext>) => Partial<PageContext> | null;
|
|
17
|
+
export declare function addCtxRebuilder(fn: Rebuilder): void;
|
|
12
18
|
/** @internal Injected by tsx-instance.ts for async-safe context isolation */
|
|
13
19
|
export declare function __registerAls(getStore: () => PageContext | undefined): void;
|
|
14
20
|
declare function setCtx(value: Partial<PageContext>): void;
|
package/dist/types.d.ts
CHANGED
|
@@ -4,9 +4,11 @@ export interface Context {
|
|
|
4
4
|
user?: unknown;
|
|
5
5
|
parsed?: Record<string, unknown>;
|
|
6
6
|
mountPath?: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
theme?: string;
|
|
8
|
+
i18n?: {
|
|
9
|
+
locale: string;
|
|
10
|
+
t: (key: string, params?: Record<string, string>, fallback?: string) => string;
|
|
11
|
+
};
|
|
10
12
|
env?: Record<string, string>;
|
|
11
13
|
layoutStack?: {
|
|
12
14
|
path: string;
|
package/dist/user/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { user } from './client.ts';
|
|
2
|
-
export type { UserOptions, UserData, UserModule, AuthResult, OAuth2Client, UserInjected } from './types.ts';
|
|
2
|
+
export type { UserOptions, UserData, UserModule, AuthResult, OAuth2Client, OAuthProviderConfig, UserInjected } from './types.ts';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Sql } from '../vendor.ts';
|
|
2
|
+
import type { Router } from '../router.ts';
|
|
3
|
+
import type { OAuthProviderConfig } from './types.ts';
|
|
4
|
+
interface OAuthLoginDeps {
|
|
5
|
+
sql: Sql<{}>;
|
|
6
|
+
jwtSecret: string;
|
|
7
|
+
expiresIn: string | number;
|
|
8
|
+
usersTable: string;
|
|
9
|
+
/** Table for provider-user link, derived from usersTable. */
|
|
10
|
+
providerTable: string;
|
|
11
|
+
redirectUrl: string;
|
|
12
|
+
signToken: (user: any) => string;
|
|
13
|
+
/** Create a placeholder user for OAuth login (no password). */
|
|
14
|
+
createPlaceholderUser: (email: string, name: string) => Promise<any>;
|
|
15
|
+
/** Find user by internal ID. */
|
|
16
|
+
findUserById: (id: number) => Promise<any | undefined>;
|
|
17
|
+
/** Find user by email. */
|
|
18
|
+
findUserByEmail: (email: string) => Promise<any | undefined>;
|
|
19
|
+
}
|
|
20
|
+
export declare function registerOAuthLoginRoutes(router: Router, deps: OAuthLoginDeps, providers: Record<string, OAuthProviderConfig>): void;
|
|
21
|
+
export {};
|
package/dist/user/types.d.ts
CHANGED
|
@@ -24,12 +24,43 @@ export interface OAuth2Client {
|
|
|
24
24
|
export interface OAuth2ServerOptions {
|
|
25
25
|
server: true;
|
|
26
26
|
}
|
|
27
|
+
export interface OAuthProviderConfig {
|
|
28
|
+
clientId: string;
|
|
29
|
+
clientSecret: string;
|
|
30
|
+
scope?: string;
|
|
31
|
+
/** Custom auth URL (overrides built-in provider default). */
|
|
32
|
+
authUrl?: string;
|
|
33
|
+
/** Custom token URL (overrides built-in provider default). */
|
|
34
|
+
tokenUrl?: string;
|
|
35
|
+
/** Custom user info URL (overrides built-in provider default). */
|
|
36
|
+
userUrl?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Custom user parser.
|
|
39
|
+
* Required when any of authUrl/tokenUrl/userUrl is custom.
|
|
40
|
+
* Receives the raw response from userUrl + the access token.
|
|
41
|
+
*/
|
|
42
|
+
parseUser?: (data: any, accessToken: string) => {
|
|
43
|
+
id: string;
|
|
44
|
+
email: string;
|
|
45
|
+
name: string;
|
|
46
|
+
avatarUrl?: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
27
49
|
export interface UserOptions {
|
|
28
50
|
pg: PostgresClient;
|
|
29
51
|
jwtSecret: string;
|
|
30
52
|
table?: string;
|
|
31
53
|
expiresIn?: string | number;
|
|
32
54
|
oauth2?: OAuth2ServerOptions;
|
|
55
|
+
/**
|
|
56
|
+
* OAuth login providers (login with GitHub/Google).
|
|
57
|
+
* Registers GET /auth/:provider and GET /auth/:provider/callback routes.
|
|
58
|
+
*/
|
|
59
|
+
oauthLogin?: {
|
|
60
|
+
providers: Record<string, OAuthProviderConfig>;
|
|
61
|
+
/** Where to redirect after successful login (default: '/'). */
|
|
62
|
+
redirectUrl?: string;
|
|
63
|
+
};
|
|
33
64
|
}
|
|
34
65
|
export interface UserInjected {
|
|
35
66
|
user: UserData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weifuwu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Web-standard HTTP framework for Node.js — (req, ctx) => Response",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@ai-sdk/openai": "^3.0.66",
|
|
31
|
+
"@aws-sdk/client-s3": "^3.1068.0",
|
|
32
|
+
"@aws-sdk/s3-request-presigner": "^3.1068.0",
|
|
31
33
|
"@graphql-tools/schema": "^10",
|
|
32
34
|
"@tailwindcss/postcss": "^4",
|
|
33
35
|
"ai": "^6",
|