@jeffusion/bungee-types 2.4.0 → 3.1.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.
Files changed (2) hide show
  1. package/dist/types.d.ts +45 -4
  2. 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,12 +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>;
63
80
  disabled?: boolean;
64
81
  description?: string;
82
+ condition?: string;
65
83
  }
66
84
  export interface RouteConfig extends ModificationRules {
67
85
  path: string;
@@ -71,13 +89,15 @@ export interface RouteConfig extends ModificationRules {
71
89
  upstreams: Upstream[];
72
90
  failover?: {
73
91
  enabled: boolean;
74
- retryableStatusCodes: number[];
92
+ retryableStatusCodes?: number | string | (number | string)[];
75
93
  consecutiveFailuresThreshold?: number;
76
94
  recoveryIntervalMs?: number;
77
95
  recoveryTimeoutMs?: number;
78
96
  healthyThreshold?: number;
79
97
  requestTimeoutMs?: number;
80
98
  connectTimeoutMs?: number;
99
+ autoDisableThreshold?: number;
100
+ autoEnableOnHealthCheck?: boolean;
81
101
  slowStart?: {
82
102
  enabled: boolean;
83
103
  durationMs?: number;
@@ -92,6 +112,10 @@ export interface RouteConfig extends ModificationRules {
92
112
  expectedStatus?: number[];
93
113
  unhealthyThreshold?: number;
94
114
  healthyThreshold?: number;
115
+ body?: string;
116
+ contentType?: string;
117
+ headers?: Record<string, string>;
118
+ query?: Record<string, string>;
95
119
  };
96
120
  };
97
121
  }
@@ -104,16 +128,33 @@ export interface LoggingConfig {
104
128
  }
105
129
  /**
106
130
  * Plugin 配置
131
+ *
132
+ * 支持两种引用方式:
133
+ * 1. 通过 name 引用(推荐):自动从插件目录解析路径
134
+ * 2. 通过 path 引用(高级):手动指定插件文件路径
107
135
  */
108
136
  export interface PluginConfig {
109
137
  /**
110
- * Plugin 文件路径(绝对路径或相对于配置文件的路径)
138
+ * Plugin 名称(唯一标识符)
139
+ * 这是插件的唯一标识,用于引用和管理插件
140
+ *
141
+ * 示例: "ai-transformer", "token-cache"
111
142
  */
112
- path: string;
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;
113
154
  /**
114
155
  * 传递给 Plugin 的初始化选项
115
156
  */
116
- options?: Record<string, any>;
157
+ options?: PluginConfigOptions;
117
158
  /**
118
159
  * Plugin 是否启用(默认 true)
119
160
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffusion/bungee-types",
3
- "version": "2.4.0",
3
+ "version": "3.1.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",