@timmy_hu/plugin-middleware 1.0.1 → 1.0.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/.xpertai-plugin/plugin.json +2 -2
- package/examples/request.example.json +90 -30
- package/index.js +502 -267
- package/package.json +2 -2
- package/src/middlewares/plugin-middleware.middleware.ts +455 -144
- package/src/schemas/config.schema.ts +3 -14
|
@@ -3,7 +3,8 @@ import { z } from "zod";
|
|
|
3
3
|
/**
|
|
4
4
|
* 插件中间件配置 Schema
|
|
5
5
|
*
|
|
6
|
-
* 定义插件运行所需的所有配置项,包括平台地址、登录凭据、组织 ID
|
|
6
|
+
* 定义插件运行所需的所有配置项,包括平台地址、登录凭据、组织 ID 和缓存策略。
|
|
7
|
+
* 通过 /api/auth/login 登录获取 token 后调用平台 API。
|
|
7
8
|
*/
|
|
8
9
|
export const PluginMiddlewareConfigSchema = z.object({
|
|
9
10
|
/** XpertAI 平台基础地址,用于调用登录和插件 API */
|
|
@@ -22,21 +23,9 @@ export const PluginMiddlewareConfigSchema = z.object({
|
|
|
22
23
|
organizationId: z.string().optional()
|
|
23
24
|
.describe("组织 ID,用于限定插件查询范围"),
|
|
24
25
|
|
|
25
|
-
/** 是否在启动时自动发现可用的中间件插件 */
|
|
26
|
-
autoDiscover: z.boolean().default(true)
|
|
27
|
-
.describe("是否在启动时自动发现可用的中间件插件"),
|
|
28
|
-
|
|
29
26
|
/** 插件发现缓存有效期(秒),过期后自动刷新 */
|
|
30
27
|
cacheTtlSeconds: z.number().int().min(10).max(3600).default(300)
|
|
31
|
-
.describe("插件发现缓存有效期(秒)")
|
|
32
|
-
|
|
33
|
-
/** 加载超时时间(毫秒) */
|
|
34
|
-
loadTimeoutMs: z.number().int().min(1000).max(120000).default(30000)
|
|
35
|
-
.describe("插件加载超时时间(毫秒)"),
|
|
36
|
-
|
|
37
|
-
/** 是否启用离线模式(API 不可用时仍可本地管理插件状态) */
|
|
38
|
-
offlineMode: z.boolean().default(true)
|
|
39
|
-
.describe("是否启用离线模式")
|
|
28
|
+
.describe("插件发现缓存有效期(秒)")
|
|
40
29
|
});
|
|
41
30
|
|
|
42
31
|
export type PluginMiddlewareConfig = z.infer<typeof PluginMiddlewareConfigSchema>;
|