@jeffusion/bungee-types 2.3.1 → 3.0.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/dist/types.d.ts +47 -4
- package/package.json +6 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件配置值类型
|
|
3
|
+
* 定义了插件配置中允许的值类型,比 `any` 更具体
|
|
4
|
+
*
|
|
5
|
+
* 这个类型约束了配置值可以是:
|
|
6
|
+
* - 基本类型: string, number, boolean, null
|
|
7
|
+
* - 数组: 元素可以是任意 PluginConfigValue
|
|
8
|
+
* - 对象: 值可以是任意 PluginConfigValue
|
|
9
|
+
*/
|
|
10
|
+
export type PluginConfigValue = string | number | boolean | null | PluginConfigValue[] | {
|
|
11
|
+
[key: string]: PluginConfigValue;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 插件配置选项类型
|
|
15
|
+
*/
|
|
16
|
+
export type PluginConfigOptions = Record<string, PluginConfigValue>;
|
|
1
17
|
export interface ModificationRules {
|
|
2
18
|
headers?: {
|
|
3
19
|
add?: Record<string, string>;
|
|
@@ -56,10 +72,14 @@ export interface AuthConfig {
|
|
|
56
72
|
tokens: string[];
|
|
57
73
|
}
|
|
58
74
|
export interface Upstream extends ModificationRules {
|
|
75
|
+
id?: string;
|
|
59
76
|
target: string;
|
|
60
77
|
weight?: number;
|
|
61
78
|
priority?: number;
|
|
62
79
|
plugins?: Array<PluginConfig | string>;
|
|
80
|
+
disabled?: boolean;
|
|
81
|
+
description?: string;
|
|
82
|
+
condition?: string;
|
|
63
83
|
}
|
|
64
84
|
export interface RouteConfig extends ModificationRules {
|
|
65
85
|
path: string;
|
|
@@ -69,13 +89,15 @@ export interface RouteConfig extends ModificationRules {
|
|
|
69
89
|
upstreams: Upstream[];
|
|
70
90
|
failover?: {
|
|
71
91
|
enabled: boolean;
|
|
72
|
-
retryableStatusCodes
|
|
92
|
+
retryableStatusCodes?: number | string | (number | string)[];
|
|
73
93
|
consecutiveFailuresThreshold?: number;
|
|
74
94
|
recoveryIntervalMs?: number;
|
|
75
95
|
recoveryTimeoutMs?: number;
|
|
76
96
|
healthyThreshold?: number;
|
|
77
97
|
requestTimeoutMs?: number;
|
|
78
98
|
connectTimeoutMs?: number;
|
|
99
|
+
autoDisableThreshold?: number;
|
|
100
|
+
autoEnableOnHealthCheck?: boolean;
|
|
79
101
|
slowStart?: {
|
|
80
102
|
enabled: boolean;
|
|
81
103
|
durationMs?: number;
|
|
@@ -90,6 +112,10 @@ export interface RouteConfig extends ModificationRules {
|
|
|
90
112
|
expectedStatus?: number[];
|
|
91
113
|
unhealthyThreshold?: number;
|
|
92
114
|
healthyThreshold?: number;
|
|
115
|
+
body?: string;
|
|
116
|
+
contentType?: string;
|
|
117
|
+
headers?: Record<string, string>;
|
|
118
|
+
query?: Record<string, string>;
|
|
93
119
|
};
|
|
94
120
|
};
|
|
95
121
|
}
|
|
@@ -102,16 +128,33 @@ export interface LoggingConfig {
|
|
|
102
128
|
}
|
|
103
129
|
/**
|
|
104
130
|
* Plugin 配置
|
|
131
|
+
*
|
|
132
|
+
* 支持两种引用方式:
|
|
133
|
+
* 1. 通过 name 引用(推荐):自动从插件目录解析路径
|
|
134
|
+
* 2. 通过 path 引用(高级):手动指定插件文件路径
|
|
105
135
|
*/
|
|
106
136
|
export interface PluginConfig {
|
|
107
137
|
/**
|
|
108
|
-
* Plugin
|
|
138
|
+
* Plugin 名称(唯一标识符)
|
|
139
|
+
* 这是插件的唯一标识,用于引用和管理插件
|
|
140
|
+
*
|
|
141
|
+
* 示例: "ai-transformer", "token-cache"
|
|
109
142
|
*/
|
|
110
|
-
|
|
143
|
+
name: string;
|
|
144
|
+
/**
|
|
145
|
+
* Plugin 文件路径(可选,仅用于高级场景)
|
|
146
|
+
* 如果指定了 path,将直接加载该路径的插件文件
|
|
147
|
+
* 如果未指定,将通过 name 在插件目录中查找
|
|
148
|
+
*
|
|
149
|
+
* 支持:
|
|
150
|
+
* - 绝对路径: "/absolute/path/to/plugin.ts"
|
|
151
|
+
* - 相对路径(相对于配置文件): "./plugins/custom-plugin.ts"
|
|
152
|
+
*/
|
|
153
|
+
path?: string;
|
|
111
154
|
/**
|
|
112
155
|
* 传递给 Plugin 的初始化选项
|
|
113
156
|
*/
|
|
114
|
-
options?:
|
|
157
|
+
options?: PluginConfigOptions;
|
|
115
158
|
/**
|
|
116
159
|
* Plugin 是否启用(默认 true)
|
|
117
160
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeffusion/bungee-types",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "TypeScript type definitions for Bungee",
|
|
5
5
|
"main": "./dist/index.d.ts",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
"*.ts",
|
|
28
28
|
"README.md"
|
|
29
29
|
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/jeffusion/bungee",
|
|
33
|
+
"directory": "packages/types"
|
|
34
|
+
},
|
|
30
35
|
"license": "MIT",
|
|
31
36
|
"devDependencies": {
|
|
32
37
|
"bun-types": "^1.3.2",
|