@seip/bluebird-js 0.1.6 → 0.2.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/.vscode/extensions.json +7 -7
- package/.vscode/settings.json +10 -10
- package/AGENTS.md +266 -116
- package/README.md +258 -245
- package/app/models/user.js +19 -0
- package/app/resources/html/home.html +137 -0
- package/app/resources/html/layouts/main.html +54 -0
- package/app/resources/html/notFound.html +14 -0
- package/app/resources/html/terms.html +46 -0
- package/app/resources/index.html +27 -0
- package/app/resources/layouts/AppLayout.jsx +89 -0
- package/app/resources/main.jsx +18 -0
- package/app/resources/pages/Dashboard.jsx +98 -0
- package/app/resources/pages/Home.jsx +140 -0
- package/app/resources/pages/Login.jsx +35 -0
- package/app/resources/pages/NotFound.jsx +16 -0
- package/app/resources/pages/Register.jsx +55 -0
- package/app/resources/routes.jsx +54 -0
- package/app/resources/spa.js +67 -0
- package/app/resources/styles.css +9 -0
- package/app/routes/api.js +85 -50
- package/app/routes/auth.js +209 -0
- package/app/routes/web.js +49 -37
- package/core/ai.d.ts +151 -151
- package/core/ai.js +1071 -1051
- package/core/app.d.ts +2 -18
- package/core/app.js +978 -792
- package/core/auth.d.ts +2 -13
- package/core/auth.js +444 -326
- package/core/cli/backup.js +167 -167
- package/core/cli/build.js +37 -0
- package/core/cli/dev.js +155 -0
- package/core/cli/doctor.js +37 -2
- package/core/cli/export.js +191 -0
- package/core/cli/init.js +101 -332
- package/core/cli/nginx.js +1 -1
- package/core/cli/templates.js +139 -0
- package/core/cli/view.js +73 -136
- package/core/config.js +44 -2
- package/core/csrf.js +156 -24
- package/core/database.js +737 -684
- package/core/debug.js +1 -1
- package/core/html.js +8 -1
- package/core/index.d.ts +1286 -1431
- package/core/paths.js +55 -0
- package/core/ratelimit.js +10 -1
- package/core/react/client/api.js +237 -0
- package/core/react/client/auth.js +236 -0
- package/core/react/client/components.js +1321 -0
- package/core/react/client/i18n.js +338 -0
- package/core/react/client/index.d.ts +249 -0
- package/core/react/client/index.js +49 -0
- package/core/react/client/router.js +26 -0
- package/core/react/client/theme.css +512 -0
- package/core/render-cache.js +250 -212
- package/core/render.d.ts +25 -21
- package/core/render.js +613 -603
- package/core/router.d.ts +2 -3
- package/core/router.js +171 -171
- package/core/seo.js +10 -0
- package/core/spa.js +599 -0
- package/core/view-loader.js +81 -455
- package/core/vite-plugin.d.ts +18 -0
- package/core/vite-plugin.js +162 -0
- package/core/vite.js +250 -145
- package/index.js +22 -18
- package/jsconfig.json +5 -3
- package/package.json +114 -92
- package/production.md +8 -3
- package/public/js/bluebird.js +1160 -0
- package/templates/_auth/app/database.js +19 -0
- package/templates/_auth/app/models/user.js +22 -0
- package/templates/_auth/app/routes/auth-router.js +304 -0
- package/templates/_base/app/resources/html/layouts/main.html +55 -0
- package/templates/_base/app/resources/html/notFound.html +14 -0
- package/templates/_base/app/resources/index.html +27 -0
- package/templates/_base/app/resources/styles.css +9 -0
- package/templates/api/app/models/note.js +18 -0
- package/templates/api/app/routes/api.js +82 -0
- package/templates/api/app/routes/auth.js +11 -0
- package/templates/api/index.js +19 -0
- package/templates/api/template.json +13 -0
- package/templates/auth/app/mail.js +11 -0
- package/templates/auth/app/models/password_reset.js +18 -0
- package/templates/auth/app/resources/html/home.html +21 -0
- package/templates/auth/app/resources/html/partials/nav.html +2 -0
- package/templates/auth/app/resources/layouts/AppLayout.jsx +60 -0
- package/templates/auth/app/resources/main.jsx +18 -0
- package/templates/auth/app/resources/pages/Dashboard.jsx +51 -0
- package/templates/auth/app/resources/pages/ForgotPassword.jsx +34 -0
- package/templates/auth/app/resources/pages/Login.jsx +36 -0
- package/templates/auth/app/resources/pages/NotFound.jsx +16 -0
- package/templates/auth/app/resources/pages/Profile.jsx +99 -0
- package/templates/auth/app/resources/pages/Register.jsx +50 -0
- package/templates/auth/app/resources/pages/ResetPassword.jsx +50 -0
- package/templates/auth/app/resources/routes.jsx +54 -0
- package/templates/auth/app/resources/spa.js +29 -0
- package/templates/auth/app/routes/api.js +17 -0
- package/templates/auth/app/routes/auth.js +13 -0
- package/templates/auth/app/routes/web.js +21 -0
- package/templates/auth/index.js +19 -0
- package/templates/auth/template.json +15 -0
- package/templates/blank/app/models/.gitkeep +0 -0
- package/templates/blank/app/resources/html/home.html +27 -0
- package/templates/blank/app/resources/html/partials/nav.html +1 -0
- package/templates/blank/app/resources/main.jsx +16 -0
- package/templates/blank/app/resources/pages/Home.jsx +42 -0
- package/templates/blank/app/resources/pages/NotFound.jsx +27 -0
- package/templates/blank/app/resources/routes.jsx +15 -0
- package/templates/blank/app/resources/spa.js +24 -0
- package/templates/blank/app/routes/api.js +11 -0
- package/templates/blank/app/routes/web.js +21 -0
- package/templates/blank/index.js +13 -0
- package/templates/blank/template.json +12 -0
- package/templates/blog/app/lib/blog.js +149 -0
- package/templates/blog/app/models/post.js +22 -0
- package/templates/blog/app/resources/html/home.html +28 -0
- package/templates/blog/app/resources/html/not-found.html +5 -0
- package/templates/blog/app/resources/html/partials/nav.html +2 -0
- package/templates/blog/app/resources/html/partials/post-card.html +9 -0
- package/templates/blog/app/resources/html/post.html +8 -0
- package/templates/blog/app/resources/layouts/AdminLayout.jsx +54 -0
- package/templates/blog/app/resources/main.jsx +18 -0
- package/templates/blog/app/resources/pages/Login.jsx +31 -0
- package/templates/blog/app/resources/pages/NotFound.jsx +16 -0
- package/templates/blog/app/resources/pages/PostEditor.jsx +51 -0
- package/templates/blog/app/resources/pages/Posts.jsx +83 -0
- package/templates/blog/app/resources/pages/Register.jsx +43 -0
- package/templates/blog/app/resources/routes.jsx +51 -0
- package/templates/blog/app/resources/spa.js +25 -0
- package/templates/blog/app/resources/styles.css +40 -0
- package/templates/blog/app/routes/api.js +77 -0
- package/templates/blog/app/routes/auth.js +10 -0
- package/templates/blog/app/routes/web.js +114 -0
- package/templates/blog/index.js +21 -0
- package/templates/blog/template.json +14 -0
- package/vite.config.js +11 -0
- package/app/views/about.jsx +0 -98
- package/app/views/components/Header.jsx +0 -42
- package/app/views/components/LiveCounter.jsx +0 -66
- package/app/views/dashboard.jsx +0 -300
- package/app/views/index.jsx +0 -123
- package/app/views/layouts/main/view.jsx +0 -201
- package/app/views/legal/terms.html +0 -29
- package/app/views/login.jsx +0 -141
- package/core/actions.d.ts +0 -4
- package/core/actions.js +0 -329
- package/core/jsx.d.ts +0 -38
- package/core/jsx.js +0 -1432
- package/core/vite.d.ts +0 -3
- package/public/js/bluebird-client.js +0 -3161
- package/public/js/tailwind.js +0 -8
package/app/routes/web.js
CHANGED
|
@@ -1,47 +1,59 @@
|
|
|
1
1
|
import Router from "@seip/bluebird-js/core/router.js";
|
|
2
2
|
import Render from "@seip/bluebird-js/core/render.js";
|
|
3
|
-
import
|
|
3
|
+
import { escapeHtml } from "@seip/bluebird-js/core/html.js";
|
|
4
|
+
import spa from "../resources/spa.js";
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* Web Router for custom actions and static HTML files.
|
|
7
|
-
* Page GET routes (`/`, `/about`, `/login`, `/dashboard`) are automatically
|
|
8
|
-
* generated from `app/views/*.jsx` via declarative exports (`route`, `cache`, `middlewares`, `layout`, `seo`).
|
|
9
|
-
*/
|
|
10
6
|
const routerWeb = new Router("/", { seo: true });
|
|
11
7
|
|
|
12
|
-
routerWeb.get("/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
8
|
+
routerWeb.get("/", (req, res) => {
|
|
9
|
+
const slides = [
|
|
10
|
+
{
|
|
11
|
+
badge: "HTML SSR",
|
|
12
|
+
title: "Fast HTML {{ }} Templates",
|
|
13
|
+
description: "Serve SEO-ready landings and storefronts directly from app/resources/html/ with layouts, partials, and {{if}} / {{each}}.",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
badge: "React SPA",
|
|
17
|
+
title: "React Router + Vite on /app",
|
|
18
|
+
description: "Client-side React workspace with zero SSR friction, per-URL SEO metadata, and a full-width skeleton in #root.",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
badge: "Auth & UI",
|
|
22
|
+
title: "Tailwind v4 Dark & Light Ready",
|
|
23
|
+
description: "Built-in AuthProvider with optional roles, vanilla data-* helpers, and reusable React UI components.",
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const features = [
|
|
28
|
+
{ name: "HTML SSR Engine", detail: "{{var}}, {{{raw}}}, {{if}}/{{else}}, {{each}}, {{> partial}}" },
|
|
29
|
+
{ name: "Router.spa()", detail: "Per-URL title, meta, keywords, JSON-LD, canonical, and skeleton" },
|
|
30
|
+
{ name: "Auth + Roles", detail: "AuthProvider synced with /api/auth/me and Auth.protect({ roles })" },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const badges = ["Express 5", "HTML {{ }}", "Vite 7", "React 19", "React Router", "Tailwind v4"];
|
|
34
|
+
const highlightsHtml = badges
|
|
35
|
+
.map(
|
|
36
|
+
(label) =>
|
|
37
|
+
`<span class="badge bg-card/80 text-foreground backdrop-blur-sm">${escapeHtml(label)}</span>`
|
|
38
|
+
)
|
|
39
|
+
.join("");
|
|
40
|
+
|
|
41
|
+
return Render.html(
|
|
42
|
+
res,
|
|
43
|
+
"home",
|
|
44
|
+
{
|
|
45
|
+
title: "Bluebird.js — HTML SSR + React SPA",
|
|
46
|
+
description: "Express + HTML {{ }} SSR templates + React Router SPA with Vite and Tailwind CSS v4.",
|
|
47
|
+
slides,
|
|
48
|
+
features,
|
|
49
|
+
highlightsHtml,
|
|
50
|
+
},
|
|
51
|
+
{ layout: "main", cache: 300 }
|
|
52
|
+
);
|
|
28
53
|
});
|
|
29
54
|
|
|
30
|
-
routerWeb.get("/
|
|
31
|
-
if (
|
|
32
|
-
req.headers["x-bluebird-prefetch"] ||
|
|
33
|
-
req.headers.purpose === "prefetch" ||
|
|
34
|
-
req.headers["sec-purpose"] === "prefetch"
|
|
35
|
-
) {
|
|
36
|
-
return res.status(204).end();
|
|
37
|
-
}
|
|
38
|
-
await Auth.logout(res);
|
|
39
|
-
return res.redirect("/login");
|
|
40
|
-
});
|
|
55
|
+
routerWeb.get("/terms", Render.view("terms", { title: "Terms of Service" }, { cache: 86400, ttl: 86400 }));
|
|
41
56
|
|
|
42
|
-
routerWeb.
|
|
43
|
-
await Auth.logout(res);
|
|
44
|
-
return res.redirect("/login");
|
|
45
|
-
});
|
|
57
|
+
routerWeb.spa(spa.mount, spa);
|
|
46
58
|
|
|
47
59
|
export default routerWeb;
|
package/core/ai.d.ts
CHANGED
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
import type { Request, Response, NextFunction, RequestHandler } from "express";
|
|
2
|
-
|
|
3
|
-
export interface AIOptions {
|
|
4
|
-
provider?: "deepseek" | "gemini" | "openai" | "custom";
|
|
5
|
-
model?: string;
|
|
6
|
-
apiKey?: string;
|
|
7
|
-
baseURL?: string;
|
|
8
|
-
temperature?: number;
|
|
9
|
-
thinking?: boolean | { type: string };
|
|
10
|
-
reasoningEffort?: "low" | "medium" | "high";
|
|
11
|
-
rateLimit?: number | { minute?: number; day?: number } | { max: number; windowMs: number };
|
|
12
|
-
rateWindow?: number;
|
|
13
|
-
cacheTtl?: number | boolean;
|
|
14
|
-
system?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface AIAskOptions {
|
|
18
|
-
data?: Record<string, any>;
|
|
19
|
-
sensitiveKeys?: string[];
|
|
20
|
-
request?: Request | any;
|
|
21
|
-
req?: Request | any;
|
|
22
|
-
user?: string;
|
|
23
|
-
system?: string;
|
|
24
|
-
json?: boolean;
|
|
25
|
-
schema?: Record<string, any>;
|
|
26
|
-
temperature?: number;
|
|
27
|
-
model?: string;
|
|
28
|
-
provider?: "deepseek" | "gemini" | "openai" | "custom";
|
|
29
|
-
apiKey?: string;
|
|
30
|
-
baseURL?: string;
|
|
31
|
-
cache?: number | boolean;
|
|
32
|
-
thinking?: boolean | { type: string };
|
|
33
|
-
reasoningEffort?: "low" | "medium" | "high";
|
|
34
|
-
maxTokens?: number;
|
|
35
|
-
rateLimit?: number | { minute?: number; day?: number } | { max: number; windowMs: number };
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface AIUsage {
|
|
39
|
-
prompt_tokens?: number;
|
|
40
|
-
completion_tokens?: number;
|
|
41
|
-
total_tokens?: number;
|
|
42
|
-
[key: string]: any;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface AIResult<T = any> {
|
|
46
|
-
success: boolean;
|
|
47
|
-
text?: string;
|
|
48
|
-
rawText?: string;
|
|
49
|
-
parsed?: T;
|
|
50
|
-
valid?: boolean;
|
|
51
|
-
errors?: any;
|
|
52
|
-
reasoning?: string | null;
|
|
53
|
-
cached?: boolean;
|
|
54
|
-
latency?: number;
|
|
55
|
-
provider?: string;
|
|
56
|
-
model?: string;
|
|
57
|
-
usage?: AIUsage;
|
|
58
|
-
maskedKeys?: string[];
|
|
59
|
-
error?: string;
|
|
60
|
-
message?: string;
|
|
61
|
-
retryAfter?: number;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface AIStreamChunk {
|
|
65
|
-
text: string;
|
|
66
|
-
done: boolean;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface MaskResult {
|
|
70
|
-
maskedPrompt: string;
|
|
71
|
-
maskedData: Record<string, any> | null;
|
|
72
|
-
tokenMap: Record<string, string>;
|
|
73
|
-
reverseTokenMap: Record<string, string>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export declare function getClientIp(req: Request | any): string;
|
|
77
|
-
|
|
78
|
-
export declare function maskSensitiveData(
|
|
79
|
-
prompt?: string,
|
|
80
|
-
data?: Record<string, any> | null,
|
|
81
|
-
sensitiveKeys?: string[]
|
|
82
|
-
): MaskResult;
|
|
83
|
-
|
|
84
|
-
export declare function unmaskSensitiveData(
|
|
85
|
-
text?: string,
|
|
86
|
-
reverseTokenMap?: Record<string, string>
|
|
87
|
-
): string;
|
|
88
|
-
|
|
89
|
-
export declare function extractJsonString(text?: string): string;
|
|
90
|
-
|
|
91
|
-
export declare class AI {
|
|
92
|
-
provider: string;
|
|
93
|
-
model: string;
|
|
94
|
-
apiKey: string;
|
|
95
|
-
baseURL: string;
|
|
96
|
-
temperature: number;
|
|
97
|
-
thinking: boolean | Object;
|
|
98
|
-
reasoningEffort?: "low" | "medium" | "high";
|
|
99
|
-
rateLimit?: any;
|
|
100
|
-
rateWindow: number;
|
|
101
|
-
cacheTtl: number | boolean;
|
|
102
|
-
system: string;
|
|
103
|
-
|
|
104
|
-
constructor(options?: AIOptions);
|
|
105
|
-
|
|
106
|
-
checkRateLimit(
|
|
107
|
-
clientKey: string,
|
|
108
|
-
limitConfig?: any
|
|
109
|
-
): { allowed: boolean; retryAfter: number };
|
|
110
|
-
|
|
111
|
-
ask<T = any>(prompt: string | any[], options?: AIAskOptions): Promise<AIResult<T>>;
|
|
112
|
-
|
|
113
|
-
askStream(
|
|
114
|
-
prompt: string | any[],
|
|
115
|
-
options?: AIAskOptions
|
|
116
|
-
): AsyncGenerator<AIStreamChunk, void, unknown>;
|
|
117
|
-
|
|
118
|
-
pipe(
|
|
119
|
-
res: Response | any,
|
|
120
|
-
prompt: string | any[],
|
|
121
|
-
options?: AIAskOptions & { sse?: boolean }
|
|
122
|
-
): Promise<void>;
|
|
123
|
-
|
|
124
|
-
stream(
|
|
125
|
-
res: Response | any,
|
|
126
|
-
prompt: string | any[],
|
|
127
|
-
options?: AIAskOptions & { sse?: boolean }
|
|
128
|
-
): Promise<void>;
|
|
129
|
-
|
|
130
|
-
middleware(options?: { rateLimit?: any; message?: string }): RequestHandler;
|
|
131
|
-
|
|
132
|
-
protect(options?: { rateLimit?: any; message?: string }): RequestHandler;
|
|
133
|
-
|
|
134
|
-
static getClientIp(req: Request | any): string;
|
|
135
|
-
|
|
136
|
-
static mask(
|
|
137
|
-
prompt: string,
|
|
138
|
-
data?: Record<string, any> | null,
|
|
139
|
-
sensitiveKeys?: string[]
|
|
140
|
-
): MaskResult;
|
|
141
|
-
|
|
142
|
-
static unmask(text: string, reverseTokenMap: Record<string, string>): string;
|
|
143
|
-
|
|
144
|
-
static protect(options?: AIOptions & { message?: string }): RequestHandler;
|
|
145
|
-
|
|
146
|
-
static resetRateLimits(): void;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export declare const ai: AI;
|
|
150
|
-
export default AI;
|
|
151
|
-
|
|
1
|
+
import type { Request, Response, NextFunction, RequestHandler } from "express";
|
|
2
|
+
|
|
3
|
+
export interface AIOptions {
|
|
4
|
+
provider?: "deepseek" | "gemini" | "openai" | "custom";
|
|
5
|
+
model?: string;
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
baseURL?: string;
|
|
8
|
+
temperature?: number;
|
|
9
|
+
thinking?: boolean | { type: string };
|
|
10
|
+
reasoningEffort?: "low" | "medium" | "high";
|
|
11
|
+
rateLimit?: number | { minute?: number; day?: number } | { max: number; windowMs: number };
|
|
12
|
+
rateWindow?: number;
|
|
13
|
+
cacheTtl?: number | boolean;
|
|
14
|
+
system?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AIAskOptions {
|
|
18
|
+
data?: Record<string, any>;
|
|
19
|
+
sensitiveKeys?: string[];
|
|
20
|
+
request?: Request | any;
|
|
21
|
+
req?: Request | any;
|
|
22
|
+
user?: string;
|
|
23
|
+
system?: string;
|
|
24
|
+
json?: boolean;
|
|
25
|
+
schema?: Record<string, any>;
|
|
26
|
+
temperature?: number;
|
|
27
|
+
model?: string;
|
|
28
|
+
provider?: "deepseek" | "gemini" | "openai" | "custom";
|
|
29
|
+
apiKey?: string;
|
|
30
|
+
baseURL?: string;
|
|
31
|
+
cache?: number | boolean;
|
|
32
|
+
thinking?: boolean | { type: string };
|
|
33
|
+
reasoningEffort?: "low" | "medium" | "high";
|
|
34
|
+
maxTokens?: number;
|
|
35
|
+
rateLimit?: number | { minute?: number; day?: number } | { max: number; windowMs: number };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface AIUsage {
|
|
39
|
+
prompt_tokens?: number;
|
|
40
|
+
completion_tokens?: number;
|
|
41
|
+
total_tokens?: number;
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface AIResult<T = any> {
|
|
46
|
+
success: boolean;
|
|
47
|
+
text?: string;
|
|
48
|
+
rawText?: string;
|
|
49
|
+
parsed?: T;
|
|
50
|
+
valid?: boolean;
|
|
51
|
+
errors?: any;
|
|
52
|
+
reasoning?: string | null;
|
|
53
|
+
cached?: boolean;
|
|
54
|
+
latency?: number;
|
|
55
|
+
provider?: string;
|
|
56
|
+
model?: string;
|
|
57
|
+
usage?: AIUsage;
|
|
58
|
+
maskedKeys?: string[];
|
|
59
|
+
error?: string;
|
|
60
|
+
message?: string;
|
|
61
|
+
retryAfter?: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface AIStreamChunk {
|
|
65
|
+
text: string;
|
|
66
|
+
done: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface MaskResult {
|
|
70
|
+
maskedPrompt: string;
|
|
71
|
+
maskedData: Record<string, any> | null;
|
|
72
|
+
tokenMap: Record<string, string>;
|
|
73
|
+
reverseTokenMap: Record<string, string>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export declare function getClientIp(req: Request | any): string;
|
|
77
|
+
|
|
78
|
+
export declare function maskSensitiveData(
|
|
79
|
+
prompt?: string,
|
|
80
|
+
data?: Record<string, any> | null,
|
|
81
|
+
sensitiveKeys?: string[]
|
|
82
|
+
): MaskResult;
|
|
83
|
+
|
|
84
|
+
export declare function unmaskSensitiveData(
|
|
85
|
+
text?: string,
|
|
86
|
+
reverseTokenMap?: Record<string, string>
|
|
87
|
+
): string;
|
|
88
|
+
|
|
89
|
+
export declare function extractJsonString(text?: string): string;
|
|
90
|
+
|
|
91
|
+
export declare class AI {
|
|
92
|
+
provider: string;
|
|
93
|
+
model: string;
|
|
94
|
+
apiKey: string;
|
|
95
|
+
baseURL: string;
|
|
96
|
+
temperature: number;
|
|
97
|
+
thinking: boolean | Object;
|
|
98
|
+
reasoningEffort?: "low" | "medium" | "high";
|
|
99
|
+
rateLimit?: any;
|
|
100
|
+
rateWindow: number;
|
|
101
|
+
cacheTtl: number | boolean;
|
|
102
|
+
system: string;
|
|
103
|
+
|
|
104
|
+
constructor(options?: AIOptions);
|
|
105
|
+
|
|
106
|
+
checkRateLimit(
|
|
107
|
+
clientKey: string,
|
|
108
|
+
limitConfig?: any
|
|
109
|
+
): { allowed: boolean; retryAfter: number };
|
|
110
|
+
|
|
111
|
+
ask<T = any>(prompt: string | any[], options?: AIAskOptions): Promise<AIResult<T>>;
|
|
112
|
+
|
|
113
|
+
askStream(
|
|
114
|
+
prompt: string | any[],
|
|
115
|
+
options?: AIAskOptions
|
|
116
|
+
): AsyncGenerator<AIStreamChunk, void, unknown>;
|
|
117
|
+
|
|
118
|
+
pipe(
|
|
119
|
+
res: Response | any,
|
|
120
|
+
prompt: string | any[],
|
|
121
|
+
options?: AIAskOptions & { sse?: boolean }
|
|
122
|
+
): Promise<void>;
|
|
123
|
+
|
|
124
|
+
stream(
|
|
125
|
+
res: Response | any,
|
|
126
|
+
prompt: string | any[],
|
|
127
|
+
options?: AIAskOptions & { sse?: boolean }
|
|
128
|
+
): Promise<void>;
|
|
129
|
+
|
|
130
|
+
middleware(options?: { rateLimit?: any; message?: string }): RequestHandler;
|
|
131
|
+
|
|
132
|
+
protect(options?: { rateLimit?: any; message?: string }): RequestHandler;
|
|
133
|
+
|
|
134
|
+
static getClientIp(req: Request | any): string;
|
|
135
|
+
|
|
136
|
+
static mask(
|
|
137
|
+
prompt: string,
|
|
138
|
+
data?: Record<string, any> | null,
|
|
139
|
+
sensitiveKeys?: string[]
|
|
140
|
+
): MaskResult;
|
|
141
|
+
|
|
142
|
+
static unmask(text: string, reverseTokenMap: Record<string, string>): string;
|
|
143
|
+
|
|
144
|
+
static protect(options?: AIOptions & { message?: string }): RequestHandler;
|
|
145
|
+
|
|
146
|
+
static resetRateLimits(): void;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export declare const ai: AI;
|
|
150
|
+
export default AI;
|
|
151
|
+
|