@jeffusion/bungee-types 4.0.0 → 4.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/dist/types.d.ts +108 -32
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -71,76 +71,135 @@ export interface AuthConfig {
|
|
|
71
71
|
*/
|
|
72
72
|
tokens: string[];
|
|
73
73
|
}
|
|
74
|
-
export interface
|
|
74
|
+
export interface Endpoint extends ModificationRules {
|
|
75
75
|
id?: string;
|
|
76
76
|
target: string;
|
|
77
77
|
weight?: number;
|
|
78
78
|
priority?: number;
|
|
79
79
|
plugins?: Array<PluginConfig | string>;
|
|
80
|
-
|
|
80
|
+
is_disabled?: boolean;
|
|
81
81
|
description?: string;
|
|
82
82
|
condition?: string;
|
|
83
83
|
}
|
|
84
84
|
export interface StickySessionConfig {
|
|
85
85
|
enabled: boolean;
|
|
86
|
-
|
|
86
|
+
key_expression?: string;
|
|
87
87
|
}
|
|
88
88
|
export interface RouteTimeoutsConfig {
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
connect_ms?: number;
|
|
90
|
+
request_ms?: number;
|
|
91
91
|
}
|
|
92
92
|
export interface FailoverPassiveHealthConfig {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
consecutive_failures?: number;
|
|
94
|
+
healthy_successes?: number;
|
|
95
|
+
auto_disable_threshold?: number;
|
|
96
|
+
auto_enable_on_active_health_check?: boolean;
|
|
97
97
|
}
|
|
98
98
|
export interface FailoverRecoveryConfig {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
probe_interval_ms?: number;
|
|
100
|
+
probe_timeout_ms?: number;
|
|
101
101
|
}
|
|
102
102
|
export interface FailoverSlowStartConfig {
|
|
103
103
|
enabled: boolean;
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
duration_ms?: number;
|
|
105
|
+
initial_weight_factor?: number;
|
|
106
106
|
}
|
|
107
107
|
export interface FailoverHealthCheckConfig {
|
|
108
108
|
enabled: boolean;
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
interval_ms?: number;
|
|
110
|
+
timeout_ms?: number;
|
|
111
111
|
path?: string;
|
|
112
112
|
method?: string;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
expected_status?: number[];
|
|
114
|
+
unhealthy_threshold?: number;
|
|
115
|
+
healthy_threshold?: number;
|
|
116
116
|
body?: string;
|
|
117
|
-
|
|
117
|
+
content_type?: string;
|
|
118
118
|
headers?: Record<string, string>;
|
|
119
119
|
query?: Record<string, string>;
|
|
120
120
|
}
|
|
121
|
+
export interface Service {
|
|
122
|
+
name: string;
|
|
123
|
+
endpoints: Endpoint[];
|
|
124
|
+
plugins?: Array<PluginConfig | string>;
|
|
125
|
+
health_check?: FailoverHealthCheckConfig;
|
|
126
|
+
failover?: FailoverConfig;
|
|
127
|
+
sticky_session?: StickySessionConfig;
|
|
128
|
+
}
|
|
121
129
|
export interface FailoverConfig {
|
|
122
130
|
enabled: boolean;
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
retry_on?: number | string | (number | string)[];
|
|
132
|
+
passive_health?: FailoverPassiveHealthConfig;
|
|
125
133
|
recovery?: FailoverRecoveryConfig;
|
|
126
|
-
|
|
127
|
-
|
|
134
|
+
slow_start?: FailoverSlowStartConfig;
|
|
135
|
+
health_check?: FailoverHealthCheckConfig;
|
|
136
|
+
}
|
|
137
|
+
export interface RateLimitConfig {
|
|
138
|
+
enabled: boolean;
|
|
139
|
+
requests_per_second?: number;
|
|
140
|
+
burst?: number;
|
|
141
|
+
key_expression?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface CorsConfig {
|
|
144
|
+
enabled: boolean;
|
|
145
|
+
allowed_origins?: string[];
|
|
146
|
+
allowed_methods?: string[];
|
|
147
|
+
allowed_headers?: string[];
|
|
148
|
+
expose_headers?: string[];
|
|
149
|
+
allow_credentials?: boolean;
|
|
150
|
+
max_age?: number;
|
|
151
|
+
}
|
|
152
|
+
export interface DirectResponseConfig {
|
|
153
|
+
enabled: boolean;
|
|
154
|
+
status: number;
|
|
155
|
+
body?: string;
|
|
156
|
+
content_type?: string;
|
|
157
|
+
headers?: Record<string, string>;
|
|
158
|
+
}
|
|
159
|
+
export interface RedirectConfig {
|
|
160
|
+
enabled: boolean;
|
|
161
|
+
url: string;
|
|
162
|
+
status?: 301 | 302 | 307 | 308;
|
|
163
|
+
preserve_path?: boolean;
|
|
164
|
+
}
|
|
165
|
+
export interface ResponseRuleConfig {
|
|
166
|
+
enabled: boolean;
|
|
167
|
+
path: string;
|
|
168
|
+
match_type?: 'exact' | 'prefix' | 'regex';
|
|
169
|
+
type: 'direct_response' | 'redirect';
|
|
170
|
+
status?: number;
|
|
171
|
+
body?: string;
|
|
172
|
+
content_type?: string;
|
|
173
|
+
headers?: Record<string, string>;
|
|
174
|
+
url?: string;
|
|
175
|
+
preserve_path?: boolean;
|
|
176
|
+
}
|
|
177
|
+
export interface RetryConfig {
|
|
178
|
+
enabled: boolean;
|
|
179
|
+
max_retries?: number;
|
|
180
|
+
retry_on?: number[];
|
|
181
|
+
per_retry_timeout_ms?: number;
|
|
128
182
|
}
|
|
129
183
|
export interface RouteConfig extends ModificationRules {
|
|
130
184
|
path: string;
|
|
131
|
-
|
|
185
|
+
service?: string;
|
|
186
|
+
endpoints?: Endpoint[];
|
|
187
|
+
path_rewrite?: Record<string, string>;
|
|
132
188
|
auth?: AuthConfig;
|
|
133
189
|
plugins?: Array<PluginConfig | string>;
|
|
134
|
-
stickySession?: StickySessionConfig;
|
|
135
|
-
upstreams: Upstream[];
|
|
136
190
|
timeouts?: RouteTimeoutsConfig;
|
|
137
|
-
|
|
191
|
+
rate_limit?: RateLimitConfig;
|
|
192
|
+
cors?: CorsConfig;
|
|
193
|
+
response_rules?: ResponseRuleConfig[];
|
|
194
|
+
direct_response?: DirectResponseConfig;
|
|
195
|
+
redirect?: RedirectConfig;
|
|
196
|
+
retry?: RetryConfig;
|
|
138
197
|
}
|
|
139
198
|
export interface LoggingConfig {
|
|
140
199
|
body?: {
|
|
141
200
|
enabled: boolean;
|
|
142
|
-
|
|
143
|
-
|
|
201
|
+
max_size: number;
|
|
202
|
+
retention_days: number;
|
|
144
203
|
};
|
|
145
204
|
}
|
|
146
205
|
/**
|
|
@@ -177,12 +236,29 @@ export interface PluginConfig {
|
|
|
177
236
|
*/
|
|
178
237
|
enabled?: boolean;
|
|
179
238
|
}
|
|
239
|
+
/** Plugin execution phase in the three-phase pipeline */
|
|
240
|
+
export type PluginPhase = 'route' | 'service' | 'upstream';
|
|
241
|
+
/**
|
|
242
|
+
* Result of onInterceptRequest hook.
|
|
243
|
+
* Distinguishes terminal short-circuit from failover trigger.
|
|
244
|
+
* - respond: terminal short-circuit, no failover
|
|
245
|
+
* - failover: trigger upstream switch (only valid in Phase 3/upstream)
|
|
246
|
+
* - undefined: continue normal flow
|
|
247
|
+
*/
|
|
248
|
+
export type InterceptResult = {
|
|
249
|
+
action: 'respond';
|
|
250
|
+
response: Response;
|
|
251
|
+
} | {
|
|
252
|
+
action: 'failover';
|
|
253
|
+
reason?: string;
|
|
254
|
+
} | undefined;
|
|
180
255
|
export interface AppConfig {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
256
|
+
config_version?: number;
|
|
257
|
+
log_level?: string;
|
|
258
|
+
body_parser_limit?: string;
|
|
184
259
|
auth?: AuthConfig;
|
|
185
260
|
logging?: LoggingConfig;
|
|
186
261
|
plugins?: Array<PluginConfig | string>;
|
|
262
|
+
services?: Service[];
|
|
187
263
|
routes: RouteConfig[];
|
|
188
264
|
}
|