weifuwu 0.22.3 → 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 +292 -87
- 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/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 +13 -7
- package/dist/index.js +1336 -821
- package/dist/kb/index.d.ts +3 -0
- package/dist/kb/types.d.ts +64 -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/session.d.ts +0 -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 +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// cli/template/ui/app/page.tsx
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useWebsocket, useLoaderData, useLocale, useTheme } from "weifuwu/react";
|
|
4
|
+
|
|
5
|
+
// cli/template/ui/components/Greeting.tsx
|
|
6
|
+
import { jsxs } from "react/jsx-runtime";
|
|
7
|
+
function Greeting({ name }) {
|
|
8
|
+
return /* @__PURE__ */ jsxs("span", { className: "text-red-500 font-bold", children: [
|
|
9
|
+
name,
|
|
10
|
+
"!"
|
|
11
|
+
] });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// cli/template/ui/app/page.tsx
|
|
15
|
+
import { jsx, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
16
|
+
function Home() {
|
|
17
|
+
const [input, setInput] = useState("");
|
|
18
|
+
const { send, lastMessage, readyState } = useWebsocket("/ws/echo");
|
|
19
|
+
const { locale, t, setLocale } = useLocale();
|
|
20
|
+
const { theme, resolvedTheme, setTheme } = useTheme();
|
|
21
|
+
const ld = useLoaderData();
|
|
22
|
+
return /* @__PURE__ */ jsxs2("div", { className: "min-h-screen bg-white dark:bg-gray-950 text-gray-900 dark:text-gray-100", children: [
|
|
23
|
+
/* @__PURE__ */ jsx("header", { className: "border-b dark:border-gray-800", children: /* @__PURE__ */ jsxs2("div", { className: "max-w-5xl mx-auto flex items-center justify-between h-14 px-4", children: [
|
|
24
|
+
/* @__PURE__ */ jsx("span", { className: "font-bold text-lg", children: "weifuwu" }),
|
|
25
|
+
/* @__PURE__ */ jsxs2("nav", { className: "hidden sm:flex gap-6 text-sm", children: [
|
|
26
|
+
/* @__PURE__ */ jsx("span", { className: "hover:text-blue-600 transition cursor-pointer", children: t("nav.home") }),
|
|
27
|
+
/* @__PURE__ */ jsx("span", { className: "hover:text-blue-600 transition cursor-pointer", children: t("nav.docs") }),
|
|
28
|
+
/* @__PURE__ */ jsx("span", { className: "hover:text-blue-600 transition cursor-pointer", children: t("nav.api") })
|
|
29
|
+
] }),
|
|
30
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 text-sm", children: [
|
|
31
|
+
/* @__PURE__ */ jsx(
|
|
32
|
+
"button",
|
|
33
|
+
{
|
|
34
|
+
onClick: () => setLocale(locale === "en" ? "zh-CN" : "en"),
|
|
35
|
+
className: "px-2 py-1 rounded border dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 transition",
|
|
36
|
+
children: locale === "en" ? "\u4E2D\u6587" : "EN"
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
"button",
|
|
41
|
+
{
|
|
42
|
+
onClick: () => setTheme(resolvedTheme === "light" ? "dark" : "light"),
|
|
43
|
+
className: "px-2 py-1 rounded border dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 transition",
|
|
44
|
+
children: resolvedTheme === "light" ? "\u{1F319}" : "\u2600\uFE0F"
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
] })
|
|
48
|
+
] }) }),
|
|
49
|
+
/* @__PURE__ */ jsxs2("section", { className: "text-center py-20 px-4", children: [
|
|
50
|
+
/* @__PURE__ */ jsx("h1", { className: "text-5xl font-bold mb-4", children: t("hero.title") }),
|
|
51
|
+
/* @__PURE__ */ jsx("p", { className: "text-xl text-gray-500 dark:text-gray-400 mb-8", children: t("hero.subtitle") }),
|
|
52
|
+
/* @__PURE__ */ jsx(Greeting, { name: "Weifuwu" }),
|
|
53
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex justify-center gap-4 mt-8", children: [
|
|
54
|
+
/* @__PURE__ */ jsx("a", { href: "#", className: "px-6 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition font-medium", children: t("cta.start") }),
|
|
55
|
+
/* @__PURE__ */ jsx("a", { href: "#", className: "px-6 py-2.5 border dark:border-gray-700 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition font-medium", children: t("cta.learn") })
|
|
56
|
+
] })
|
|
57
|
+
] }),
|
|
58
|
+
ld.features && /* @__PURE__ */ jsx("section", { className: "max-w-4xl mx-auto grid grid-cols-1 md:grid-cols-3 gap-6 px-4 pb-20", children: ld.features.map((f, i) => /* @__PURE__ */ jsxs2("div", { className: "p-6 rounded-xl border dark:border-gray-800 bg-gray-50 dark:bg-gray-900", children: [
|
|
59
|
+
/* @__PURE__ */ jsx("h3", { className: "font-semibold mb-2", children: f.title }),
|
|
60
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: f.desc })
|
|
61
|
+
] }, i)) }),
|
|
62
|
+
/* @__PURE__ */ jsx("section", { className: "max-w-xl mx-auto px-4 pb-20", children: /* @__PURE__ */ jsxs2("div", { className: "border dark:border-gray-800 rounded-xl p-6 bg-gray-50 dark:bg-gray-900 space-y-4", children: [
|
|
63
|
+
/* @__PURE__ */ jsx("h2", { className: "font-semibold", children: t("demo.title") }),
|
|
64
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: readyState === 1 ? t("ws.connected") : readyState === 0 ? t("ws.connecting") : t("ws.disconnected") }),
|
|
65
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex gap-2", children: [
|
|
66
|
+
/* @__PURE__ */ jsx(
|
|
67
|
+
"input",
|
|
68
|
+
{
|
|
69
|
+
value: input,
|
|
70
|
+
onChange: (e) => setInput(e.target.value),
|
|
71
|
+
onKeyDown: (e) => {
|
|
72
|
+
if (e.key === "Enter") {
|
|
73
|
+
send(input);
|
|
74
|
+
setInput("");
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
placeholder: t("demo.placeholder"),
|
|
78
|
+
className: "flex-1 border dark:border-gray-700 rounded px-3 py-2 text-sm bg-white dark:bg-gray-950 outline-none focus:border-blue-500 transition"
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
/* @__PURE__ */ jsx(
|
|
82
|
+
"button",
|
|
83
|
+
{
|
|
84
|
+
onClick: () => {
|
|
85
|
+
send(input);
|
|
86
|
+
setInput("");
|
|
87
|
+
},
|
|
88
|
+
className: "px-4 py-2 bg-blue-600 text-white rounded text-sm hover:bg-blue-700 transition font-medium",
|
|
89
|
+
children: t("demo.send")
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
] }),
|
|
93
|
+
lastMessage && /* @__PURE__ */ jsxs2("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: [
|
|
94
|
+
/* @__PURE__ */ jsxs2("span", { className: "font-medium", children: [
|
|
95
|
+
t("demo.echo"),
|
|
96
|
+
":"
|
|
97
|
+
] }),
|
|
98
|
+
" ",
|
|
99
|
+
lastMessage
|
|
100
|
+
] })
|
|
101
|
+
] }) }),
|
|
102
|
+
/* @__PURE__ */ jsxs2("footer", { className: "border-t dark:border-gray-800 py-8 text-center text-sm text-gray-500", children: [
|
|
103
|
+
"\xA9 2026 MyApp \xB7 ",
|
|
104
|
+
t("footer.privacy"),
|
|
105
|
+
" \xB7 ",
|
|
106
|
+
t("footer.terms")
|
|
107
|
+
] })
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
Home as default
|
|
112
|
+
};
|
package/cli/template/app.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Router, ssr,
|
|
1
|
+
import { Router, ssr, theme, i18n } from '../../index.ts'
|
|
2
2
|
|
|
3
3
|
export const app = new Router()
|
|
4
|
+
app.use(theme())
|
|
5
|
+
app.use(i18n({ dir: './locales' }))
|
|
4
6
|
app.use('/', ssr({ dir: './ui' }))
|
|
5
|
-
app.use(preferences({ dir: './locales', locale: { default: 'en' }, theme: { default: 'system' } }))
|
|
6
7
|
app.use(async (req, ctx, next) => {
|
|
7
8
|
ctx.loaderData = {
|
|
8
9
|
features: [
|
package/cli/template/index.ts
CHANGED
|
@@ -3,4 +3,5 @@ import { app } from './app.ts'
|
|
|
3
3
|
|
|
4
4
|
loadEnv()
|
|
5
5
|
const port = Number(process.env.PORT) || 3000
|
|
6
|
-
serve(app.handler(), { port, websocket: app.websocketHandler() })
|
|
6
|
+
const srv = serve(app.handler(), { port, websocket: app.websocketHandler(), shutdown: false })
|
|
7
|
+
process.on('SIGINT', () => { srv.stop(); process.exit(0) })
|
package/dist/agent/run.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Tool } from 'ai';
|
|
2
2
|
import type { Sql } from '../vendor.ts';
|
|
3
3
|
import type { BoundTable } from '../postgres/schema/index.ts';
|
|
4
|
+
import type { AIProvider } from '../ai/provider.ts';
|
|
4
5
|
import type { RunParams, RunResult, KnowledgeDoc } from './types.ts';
|
|
5
6
|
interface RunnerDeps {
|
|
6
7
|
sql: Sql<{}>;
|
|
7
8
|
agents: BoundTable<any>;
|
|
8
9
|
runs: BoundTable<any>;
|
|
9
10
|
knowledge: BoundTable<any>;
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
provider: AIProvider;
|
|
12
|
+
modelName?: string;
|
|
12
13
|
userTools?: Record<string, Tool>;
|
|
13
14
|
}
|
|
14
15
|
export declare function createRunner(deps: RunnerDeps): {
|
package/dist/agent/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Router } from '../router.ts';
|
|
2
2
|
import type { LanguageModel, EmbeddingModel, Tool } from 'ai';
|
|
3
|
+
import type { AIProvider } from '../ai/provider.ts';
|
|
3
4
|
export interface AgentConfig {
|
|
4
5
|
id: number;
|
|
5
6
|
tenant_id: string | null;
|
|
@@ -38,6 +39,8 @@ export type RunResult = {
|
|
|
38
39
|
};
|
|
39
40
|
export interface AgentOptions {
|
|
40
41
|
pg: import('../postgres/types.ts').PostgresClient;
|
|
42
|
+
/** AI provider for model and embedding resolution. Overridden by explicit model/embeddingModel. */
|
|
43
|
+
provider?: AIProvider;
|
|
41
44
|
model?: LanguageModel;
|
|
42
45
|
embeddingModel?: EmbeddingModel;
|
|
43
46
|
embeddingDimension?: number;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { generateText as aiGenerateText, streamText as aiStreamText, type LanguageModel, type EmbeddingModel } from 'ai';
|
|
2
|
+
export interface AIProviderOptions {
|
|
3
|
+
/** API base URL (default: OPENAI_BASE_URL env or http://localhost:11434/v1). */
|
|
4
|
+
baseURL?: string;
|
|
5
|
+
/** API key (default: OPENAI_API_KEY env or 'ollama'). */
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
/** Chat model name (default: OPENAI_MODEL env or 'qwen3:0.6b'). */
|
|
8
|
+
model?: string;
|
|
9
|
+
/** Embedding model name (default: OPENAI_EMBEDDING_MODEL env or 'qwen3-embedding:0.6b'). */
|
|
10
|
+
embeddingModel?: string;
|
|
11
|
+
/** Vector dimension (default: EMBEDDING_DIMENSION env or 1024). */
|
|
12
|
+
embeddingDimension?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface AIProvider {
|
|
15
|
+
/** Get the language model. Caches by default; pass a name to override. */
|
|
16
|
+
model(name?: string): LanguageModel;
|
|
17
|
+
/** Get the embedding model. Caches by default; pass a name to override. */
|
|
18
|
+
embeddingModel(name?: string): EmbeddingModel;
|
|
19
|
+
/** Embed a single text string into a vector. */
|
|
20
|
+
embed(text: string): Promise<number[]>;
|
|
21
|
+
/** Embed multiple text strings in batch. */
|
|
22
|
+
embedMany(texts: string[]): Promise<number[][]>;
|
|
23
|
+
/** The configured vector dimension. */
|
|
24
|
+
readonly dimension: number;
|
|
25
|
+
/**
|
|
26
|
+
* Generate text using the configured model.
|
|
27
|
+
* All options are passed through to the AI SDK's `generateText`, with `model` auto-injected.
|
|
28
|
+
*/
|
|
29
|
+
generateText(params: Omit<Parameters<typeof aiGenerateText>[0], 'model'>): ReturnType<typeof aiGenerateText>;
|
|
30
|
+
/**
|
|
31
|
+
* Stream text using the configured model.
|
|
32
|
+
* All options are passed through to the AI SDK's `streamText`, with `model` auto-injected.
|
|
33
|
+
*/
|
|
34
|
+
streamText(params: Omit<Parameters<typeof aiStreamText>[0], 'model'>): ReturnType<typeof aiStreamText>;
|
|
35
|
+
}
|
|
36
|
+
export declare function aiProvider(options?: AIProviderOptions): AIProvider;
|
package/dist/ai/workflow.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { LanguageModel } from 'ai';
|
|
2
|
+
import type { AIProvider } from './provider.ts';
|
|
2
3
|
export declare function runWorkflow(opts?: {
|
|
3
4
|
tools?: Record<string, any>;
|
|
4
5
|
model?: LanguageModel;
|
|
6
|
+
/** AI provider — `provider.model()` is used as fallback if no explicit `model` is set. */
|
|
7
|
+
provider?: AIProvider;
|
|
5
8
|
maxSteps?: number;
|
|
6
9
|
}): import("ai").Tool<{
|
|
7
10
|
goal: string;
|
package/dist/ai.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { Context } from './types.ts';
|
|
2
2
|
import { Router } from './router.ts';
|
|
3
|
+
import type { AIProvider } from './ai/provider.ts';
|
|
3
4
|
export type AIHandler = (req: Request, ctx: Context) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
4
5
|
export declare const _ai: Record<string, any>;
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Create a streaming AI endpoint.
|
|
8
|
+
*
|
|
9
|
+
* @param handler - Returns options for `streamText` or `streamObject` (if `schema` is present).
|
|
10
|
+
* @param provider - Optional AI provider. If provided and the handler does not return a `model`,
|
|
11
|
+
* `provider.model()` is used as the default.
|
|
12
|
+
*/
|
|
13
|
+
export declare function aiStream(handler: AIHandler, provider?: AIProvider): Promise<Router>;
|
package/dist/client-locale.d.ts
CHANGED
package/dist/client-router.d.ts
CHANGED
|
@@ -11,10 +11,12 @@ interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
|
11
11
|
}
|
|
12
12
|
export declare function Link({ href, children, onClick, prefetch, ...props }: LinkProps): import("react").DetailedReactHTMLElement<{
|
|
13
13
|
type?: string | undefined | undefined;
|
|
14
|
+
title?: string | undefined | undefined;
|
|
14
15
|
id?: string | undefined | undefined;
|
|
16
|
+
onError?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
17
|
+
onAbort?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
15
18
|
slot?: string | undefined | undefined;
|
|
16
19
|
style?: import("react").CSSProperties | undefined;
|
|
17
|
-
title?: string | undefined | undefined;
|
|
18
20
|
dir?: string | undefined | undefined;
|
|
19
21
|
property?: string | undefined | undefined;
|
|
20
22
|
download?: any;
|
|
@@ -158,7 +160,6 @@ export declare function Link({ href, children, onClick, prefetch, ...props }: Li
|
|
|
158
160
|
onInvalidCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
159
161
|
onLoad?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
160
162
|
onLoadCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
161
|
-
onError?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
162
163
|
onErrorCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
163
164
|
onKeyDown?: import("react").KeyboardEventHandler<HTMLAnchorElement> | undefined;
|
|
164
165
|
onKeyDownCapture?: import("react").KeyboardEventHandler<HTMLAnchorElement> | undefined;
|
|
@@ -166,7 +167,6 @@ export declare function Link({ href, children, onClick, prefetch, ...props }: Li
|
|
|
166
167
|
onKeyPressCapture?: import("react").KeyboardEventHandler<HTMLAnchorElement> | undefined;
|
|
167
168
|
onKeyUp?: import("react").KeyboardEventHandler<HTMLAnchorElement> | undefined;
|
|
168
169
|
onKeyUpCapture?: import("react").KeyboardEventHandler<HTMLAnchorElement> | undefined;
|
|
169
|
-
onAbort?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
170
170
|
onAbortCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
171
171
|
onCanPlay?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
172
172
|
onCanPlayCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
package/dist/client-theme.d.ts
CHANGED
package/dist/compile.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const OUT_DIR = ".weifuwu/ssr";
|
|
1
2
|
export declare function id(s: string): string;
|
|
2
3
|
export declare function clearCompileCache(): void;
|
|
3
4
|
export declare function compileTsx(path: string): Promise<any>;
|
|
@@ -5,8 +6,13 @@ export declare function compileTsx(path: string): Promise<any>;
|
|
|
5
6
|
export declare function compileTsxDev(path: string): Promise<any>;
|
|
6
7
|
/** Auto-select dev (vm) or prod (ESM + import) compilation */
|
|
7
8
|
export declare function compile(path: string): Promise<any>;
|
|
9
|
+
export declare let vendorHash: string;
|
|
8
10
|
/** Build a single vendor bundle containing all needed vendor modules */
|
|
9
11
|
export declare function compileVendorBundle(): Promise<string>;
|
|
12
|
+
/** Compile page component for browser (served at /__ssr/[hash].js).
|
|
13
|
+
* The weifuwu source modules are externalized — they come from the vendor
|
|
14
|
+
* bundle at runtime via importmap, ensuring store is shared. */
|
|
15
|
+
export declare function compileBrowser(path: string, outDir?: string): Promise<string>;
|
|
10
16
|
/** Hot-reload: ESM bundle, calls __WFW_REFRESH on import */
|
|
11
17
|
export declare function compileHotComponent(path: string): Promise<{
|
|
12
18
|
hash: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared cron expression parsing utilities.
|
|
3
|
+
* Used by both queue (Redis-backed) and in-memory scheduler.
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseField(field: string, min: number, max: number): Set<number>;
|
|
6
|
+
export declare function parsePattern(pattern: string): Set<number>[];
|
|
7
|
+
export declare function matches(fields: Set<number>[], date: Date): boolean;
|
|
8
|
+
export declare function cronNext(expr: string, from?: Date): number;
|
package/dist/flash.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Middleware } from './types.ts';
|
|
2
|
+
export interface FlashOptions {
|
|
3
|
+
/** Cookie name (default: 'flash'). */
|
|
4
|
+
name?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Flash message middleware.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* app.use(flash())
|
|
11
|
+
*
|
|
12
|
+
* // Read flash
|
|
13
|
+
* app.get('/', (req, ctx) => {
|
|
14
|
+
* const msg = ctx.flash.value // { type: 'success', text: 'Saved!' }
|
|
15
|
+
* })
|
|
16
|
+
*
|
|
17
|
+
* // Set flash + redirect
|
|
18
|
+
* app.post('/save', async (req, ctx) => {
|
|
19
|
+
* await save()
|
|
20
|
+
* return ctx.flash.set({ type: 'success', text: 'Saved!' }, '/articles')
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function flash(options?: FlashOptions): Middleware;
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Middleware } from './types.ts';
|
|
2
|
+
export interface I18nOptions {
|
|
3
|
+
/** Default locale (default: 'en'). */
|
|
4
|
+
default?: string;
|
|
5
|
+
/** Directory containing `{locale}.json` translation files. */
|
|
6
|
+
dir?: string;
|
|
7
|
+
/** Inline translation messages keyed by locale. */
|
|
8
|
+
messages?: Record<string, Record<string, unknown>>;
|
|
9
|
+
/** Cookie name for locale (default: 'locale'). Set empty to disable. */
|
|
10
|
+
cookie?: string;
|
|
11
|
+
/** Whether to detect locale from Accept-Language header (default: true). */
|
|
12
|
+
fromAcceptLanguage?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function i18n(options?: I18nOptions): Middleware;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,8 +13,6 @@ export { cors } from './cors.ts';
|
|
|
13
13
|
export type { CORSOptions } from './cors.ts';
|
|
14
14
|
export { auth } from './auth.ts';
|
|
15
15
|
export type { AuthOptions } from './auth.ts';
|
|
16
|
-
export { oauthClient } from './oauth-client.ts';
|
|
17
|
-
export type { OAuthClientOptions, OAuthProviderConfig } from './oauth-client.ts';
|
|
18
16
|
export { serveStatic } from './static.ts';
|
|
19
17
|
export type { ServeStaticOptions } from './static.ts';
|
|
20
18
|
export { validate } from './validate.ts';
|
|
@@ -40,11 +38,13 @@ export type { GraphQLOptions, GraphQLHandler } from './graphql.ts';
|
|
|
40
38
|
export { aiStream } from './ai.ts';
|
|
41
39
|
export type { AIHandler } from './ai.ts';
|
|
42
40
|
export { runWorkflow } from './ai/workflow.ts';
|
|
41
|
+
export { aiProvider } from './ai/provider.ts';
|
|
42
|
+
export type { AIProvider, AIProviderOptions } from './ai/provider.ts';
|
|
43
43
|
export { streamText, generateText, generateObject, streamObject, tool, embed, embedMany, smoothStream, openai, createOpenAI, } from './ai-sdk.ts';
|
|
44
44
|
export { postgres, MIGRATIONS_TABLE } from './postgres/index.ts';
|
|
45
45
|
export type { PostgresOptions, PostgresClient, PostgresInjected } from './postgres/types.ts';
|
|
46
46
|
export { user } from './user/index.ts';
|
|
47
|
-
export type { UserOptions, UserData, UserModule, OAuth2Client, } from './user/types.ts';
|
|
47
|
+
export type { UserOptions, UserData, UserModule, OAuth2Client, OAuthProviderConfig, } from './user/types.ts';
|
|
48
48
|
export type { UserInjected } from './user/types.ts';
|
|
49
49
|
export { redis } from './redis/index.ts';
|
|
50
50
|
export type { RedisOptions, RedisClient, RedisInjected } from './redis/types.ts';
|
|
@@ -66,8 +66,12 @@ export { health } from './health.ts';
|
|
|
66
66
|
export type { HealthOptions } from './health.ts';
|
|
67
67
|
export { analytics } from './analytics.ts';
|
|
68
68
|
export type { AnalyticsOptions, AnalyticsModule } from './analytics.ts';
|
|
69
|
-
export {
|
|
70
|
-
export type {
|
|
69
|
+
export { theme } from './theme.ts';
|
|
70
|
+
export type { ThemeOptions } from './theme.ts';
|
|
71
|
+
export { i18n } from './i18n.ts';
|
|
72
|
+
export type { I18nOptions } from './i18n.ts';
|
|
73
|
+
export { flash } from './flash.ts';
|
|
74
|
+
export type { FlashOptions } from './flash.ts';
|
|
71
75
|
export { seo, seoMiddleware, seoTags } from './seo.ts';
|
|
72
76
|
export type { SeoOptions, RobotsRule, SitemapUrl, SitemapConfig, SeoHeadersConfig, SeoTagsConfig, } from './seo.ts';
|
|
73
77
|
export { mailer } from './mailer.ts';
|
|
@@ -88,5 +92,7 @@ export type { WebhookOptions, WebhookModule, WebhookEvent, WebhookHandler, Platf
|
|
|
88
92
|
export * as fts from './fts.ts';
|
|
89
93
|
export { s3 } from './s3.ts';
|
|
90
94
|
export type { S3Options, S3PutOptions, S3UrlOptions, S3Module, S3Body } from './s3.ts';
|
|
91
|
-
export { knowledgeBase } from './kb.ts';
|
|
92
|
-
export type { KBOptions, KBIngestOptions, KBSearchResult, KBSearchOptions, KBListEntry, KBModule } from './kb.ts';
|
|
95
|
+
export { knowledgeBase } from './kb/index.ts';
|
|
96
|
+
export type { KBOptions, KBIngestOptions, KBSearchResult, KBSearchOptions, KBListEntry, KBModule } from './kb/types.ts';
|
|
97
|
+
export { permissions } from './permissions.ts';
|
|
98
|
+
export type { PermissionsOptions, PermissionsModule } from './permissions.ts';
|