@route-forge/core 2.2.0 → 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/README.md +32 -24
- package/README_zh.md +31 -24
- package/dist/codegen.cjs +7 -8
- package/dist/codegen.cjs.map +1 -1
- package/dist/codegen.d.cts +2 -3
- package/dist/codegen.d.ts +2 -3
- package/dist/codegen.js +7 -8
- package/dist/codegen.js.map +1 -1
- package/dist/index.cjs +183 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -9
- package/dist/index.d.ts +28 -9
- package/dist/index.js +182 -84
- package/dist/index.js.map +1 -1
- package/dist/route-forge.global.js +183 -83
- package/dist/route-forge.global.js.map +1 -1
- package/dist/route-forge.global.min.js +2 -2
- package/dist/{types-CDKE8rw-.d.cts → types-B_vdcRqx.d.cts} +57 -18
- package/dist/{types-CDKE8rw-.d.ts → types-B_vdcRqx.d.ts} +57 -18
- package/package.json +4 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as RouteForgeOptions, b as RouteForge, I as InterceptorManager, c as InterceptorHandler, C as CacheStorage, R as RouteMeta, L as LevelRoutesResponse } from './types-
|
|
2
|
-
export { A as AdapterOption,
|
|
1
|
+
import { a as RouteForgeOptions, b as RouteForge, I as InterceptorManager, c as InterceptorHandler, C as CacheStorage, R as RouteMeta, L as LevelRoutesResponse, d as ResponseData } from './types-B_vdcRqx.cjs';
|
|
2
|
+
export { A as AdapterOption, e as ApiCallParams, B as BoundForge, F as Fetcher, f as ForgeApiParams, g as ForgeApiResponse, h as ForgeRequest, i as ForgeRouteMap, j as ForgeRouteName, k as LoadingChangeCallback, l as LoadingChangeEvent, m as LoadingTracker, n as RequestConfig, S as SummaryResponse, U as UseForgeApiBoundCall, o as UseForgeApiBoundReturn, p as UseForgeApiCall, q as UseForgeApiReturn } from './types-B_vdcRqx.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Route Forge 主入口:createRouteForge
|
|
@@ -13,7 +13,7 @@ export { A as AdapterOption, d as ApiCallParams, B as BoundForge, F as Fetcher,
|
|
|
13
13
|
* - Adapter auto 检测 / builtin / axios / 自定义 Fetcher(§4.3)
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
declare function createRouteForge(options
|
|
16
|
+
declare function createRouteForge(options?: RouteForgeOptions): RouteForge;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* 拦截器管理器实现
|
|
@@ -118,6 +118,8 @@ declare class RouteCache {
|
|
|
118
118
|
interface RouteResolver {
|
|
119
119
|
load(level: string | string[]): Promise<void>;
|
|
120
120
|
hasRoute(level: string, name: string): boolean;
|
|
121
|
+
/** 可选:该层级当前已加载的路由名列表(UnknownRouteError 附候选值用) */
|
|
122
|
+
getRouteNames?(level: string): string[];
|
|
121
123
|
}
|
|
122
124
|
/**
|
|
123
125
|
* 异步版本:先确保层级已加载,再做歧义消解。
|
|
@@ -134,6 +136,7 @@ declare function resolveRouteNameSync(forge: RouteResolver, level: string, prefi
|
|
|
134
136
|
* Route Forge 错误基类与具体错误类
|
|
135
137
|
* @see .docs/SPEC.md §6
|
|
136
138
|
*/
|
|
139
|
+
|
|
137
140
|
interface ForgeErrorContext {
|
|
138
141
|
[key: string]: unknown;
|
|
139
142
|
}
|
|
@@ -158,15 +161,19 @@ declare class ForgeError extends Error {
|
|
|
158
161
|
}
|
|
159
162
|
/** RF_FE_001:路由名不存在于已加载层级中 */
|
|
160
163
|
declare class UnknownRouteError extends ForgeError {
|
|
161
|
-
constructor(route: string, level?: string);
|
|
164
|
+
constructor(route: string, level?: string, candidates?: string[]);
|
|
162
165
|
}
|
|
163
166
|
/** RF_FE_002:路由所在层级未在 levels 声明 */
|
|
164
167
|
declare class UnknownLevelError extends ForgeError {
|
|
165
|
-
constructor(level: string);
|
|
168
|
+
constructor(level: string, candidates?: string[]);
|
|
166
169
|
}
|
|
167
|
-
/** RF_FE_003
|
|
170
|
+
/** RF_FE_003:必填路径参数缺失(无后端 default 时,前端校验恒开) */
|
|
168
171
|
declare class MissingRouteParamError extends ForgeError {
|
|
169
|
-
constructor(route: string, missingParams: string[]);
|
|
172
|
+
constructor(route: string, missingParams: string[], uri?: string);
|
|
173
|
+
}
|
|
174
|
+
/** RF_FE_003:路径参数收到非原始值(对象/数组等,无法安全插入 URI) */
|
|
175
|
+
declare class InvalidPathParamError extends ForgeError {
|
|
176
|
+
constructor(route: string, param: string, value: unknown);
|
|
170
177
|
}
|
|
171
178
|
/** RF_FE_005:adapter: 'axios' 但未检测到 axios */
|
|
172
179
|
declare class AdapterNotFoundError extends ForgeError {
|
|
@@ -180,8 +187,15 @@ declare class InvalidInterceptorReturnError extends ForgeError {
|
|
|
180
187
|
declare class NetworkError extends ForgeError {
|
|
181
188
|
constructor(message: string, route?: string, level?: string, cause?: unknown);
|
|
182
189
|
}
|
|
183
|
-
/**
|
|
190
|
+
/**
|
|
191
|
+
* RF_FE_008:HTTP 非 2xx 且未被 onRejected 拦截器恢复。
|
|
192
|
+
*
|
|
193
|
+
* `response` 携带完整的 ResponseData(status/headers/data/config),
|
|
194
|
+
* 供响应拦截器 onRejected 链与最终 catch 逐段检查响应体——典型场景:
|
|
195
|
+
* Laravel 422 校验错误回显(`err.response.data.errors`)。
|
|
196
|
+
*/
|
|
184
197
|
declare class HTTPError extends ForgeError {
|
|
198
|
+
readonly response?: ResponseData;
|
|
185
199
|
constructor(message: string, opts: {
|
|
186
200
|
route?: string;
|
|
187
201
|
level?: string;
|
|
@@ -189,11 +203,16 @@ declare class HTTPError extends ForgeError {
|
|
|
189
203
|
url?: string;
|
|
190
204
|
method?: string;
|
|
191
205
|
cause?: unknown;
|
|
206
|
+
response?: ResponseData;
|
|
192
207
|
});
|
|
193
208
|
}
|
|
194
209
|
/** RF_FE_009:请求被 AbortSignal 取消 */
|
|
195
210
|
declare class RequestAbortedError extends ForgeError {
|
|
196
211
|
constructor(route?: string, level?: string, cause?: unknown);
|
|
197
212
|
}
|
|
213
|
+
/** RF_FE_010:auto-discovery 未完成时调用 route()/hasRoute() 的同步守卫(api() 内部 await discovery,不受此限) */
|
|
214
|
+
declare class DiscoveryNotReadyError extends ForgeError {
|
|
215
|
+
constructor();
|
|
216
|
+
}
|
|
198
217
|
|
|
199
|
-
export { AdapterNotFoundError, CacheStorage, ForgeError, type ForgeErrorCode, HTTPError, InterceptorHandler, InterceptorManager, InterceptorManagerImpl, InvalidInterceptorReturnError, LevelRoutesResponse, MissingRouteParamError, NetworkError, RequestAbortedError, RouteCache, RouteForge, RouteForgeOptions, RouteMeta, type RouteResolver, UnknownLevelError, UnknownRouteError, createInterceptorManager, createRouteForge, resolveRouteName, resolveRouteNameSync };
|
|
218
|
+
export { AdapterNotFoundError, CacheStorage, DiscoveryNotReadyError, ForgeError, type ForgeErrorCode, HTTPError, InterceptorHandler, InterceptorManager, InterceptorManagerImpl, InvalidInterceptorReturnError, InvalidPathParamError, LevelRoutesResponse, MissingRouteParamError, NetworkError, RequestAbortedError, ResponseData, RouteCache, RouteForge, RouteForgeOptions, RouteMeta, type RouteResolver, UnknownLevelError, UnknownRouteError, createInterceptorManager, createRouteForge, resolveRouteName, resolveRouteNameSync };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as RouteForgeOptions, b as RouteForge, I as InterceptorManager, c as InterceptorHandler, C as CacheStorage, R as RouteMeta, L as LevelRoutesResponse } from './types-
|
|
2
|
-
export { A as AdapterOption,
|
|
1
|
+
import { a as RouteForgeOptions, b as RouteForge, I as InterceptorManager, c as InterceptorHandler, C as CacheStorage, R as RouteMeta, L as LevelRoutesResponse, d as ResponseData } from './types-B_vdcRqx.js';
|
|
2
|
+
export { A as AdapterOption, e as ApiCallParams, B as BoundForge, F as Fetcher, f as ForgeApiParams, g as ForgeApiResponse, h as ForgeRequest, i as ForgeRouteMap, j as ForgeRouteName, k as LoadingChangeCallback, l as LoadingChangeEvent, m as LoadingTracker, n as RequestConfig, S as SummaryResponse, U as UseForgeApiBoundCall, o as UseForgeApiBoundReturn, p as UseForgeApiCall, q as UseForgeApiReturn } from './types-B_vdcRqx.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Route Forge 主入口:createRouteForge
|
|
@@ -13,7 +13,7 @@ export { A as AdapterOption, d as ApiCallParams, B as BoundForge, F as Fetcher,
|
|
|
13
13
|
* - Adapter auto 检测 / builtin / axios / 自定义 Fetcher(§4.3)
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
declare function createRouteForge(options
|
|
16
|
+
declare function createRouteForge(options?: RouteForgeOptions): RouteForge;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* 拦截器管理器实现
|
|
@@ -118,6 +118,8 @@ declare class RouteCache {
|
|
|
118
118
|
interface RouteResolver {
|
|
119
119
|
load(level: string | string[]): Promise<void>;
|
|
120
120
|
hasRoute(level: string, name: string): boolean;
|
|
121
|
+
/** 可选:该层级当前已加载的路由名列表(UnknownRouteError 附候选值用) */
|
|
122
|
+
getRouteNames?(level: string): string[];
|
|
121
123
|
}
|
|
122
124
|
/**
|
|
123
125
|
* 异步版本:先确保层级已加载,再做歧义消解。
|
|
@@ -134,6 +136,7 @@ declare function resolveRouteNameSync(forge: RouteResolver, level: string, prefi
|
|
|
134
136
|
* Route Forge 错误基类与具体错误类
|
|
135
137
|
* @see .docs/SPEC.md §6
|
|
136
138
|
*/
|
|
139
|
+
|
|
137
140
|
interface ForgeErrorContext {
|
|
138
141
|
[key: string]: unknown;
|
|
139
142
|
}
|
|
@@ -158,15 +161,19 @@ declare class ForgeError extends Error {
|
|
|
158
161
|
}
|
|
159
162
|
/** RF_FE_001:路由名不存在于已加载层级中 */
|
|
160
163
|
declare class UnknownRouteError extends ForgeError {
|
|
161
|
-
constructor(route: string, level?: string);
|
|
164
|
+
constructor(route: string, level?: string, candidates?: string[]);
|
|
162
165
|
}
|
|
163
166
|
/** RF_FE_002:路由所在层级未在 levels 声明 */
|
|
164
167
|
declare class UnknownLevelError extends ForgeError {
|
|
165
|
-
constructor(level: string);
|
|
168
|
+
constructor(level: string, candidates?: string[]);
|
|
166
169
|
}
|
|
167
|
-
/** RF_FE_003
|
|
170
|
+
/** RF_FE_003:必填路径参数缺失(无后端 default 时,前端校验恒开) */
|
|
168
171
|
declare class MissingRouteParamError extends ForgeError {
|
|
169
|
-
constructor(route: string, missingParams: string[]);
|
|
172
|
+
constructor(route: string, missingParams: string[], uri?: string);
|
|
173
|
+
}
|
|
174
|
+
/** RF_FE_003:路径参数收到非原始值(对象/数组等,无法安全插入 URI) */
|
|
175
|
+
declare class InvalidPathParamError extends ForgeError {
|
|
176
|
+
constructor(route: string, param: string, value: unknown);
|
|
170
177
|
}
|
|
171
178
|
/** RF_FE_005:adapter: 'axios' 但未检测到 axios */
|
|
172
179
|
declare class AdapterNotFoundError extends ForgeError {
|
|
@@ -180,8 +187,15 @@ declare class InvalidInterceptorReturnError extends ForgeError {
|
|
|
180
187
|
declare class NetworkError extends ForgeError {
|
|
181
188
|
constructor(message: string, route?: string, level?: string, cause?: unknown);
|
|
182
189
|
}
|
|
183
|
-
/**
|
|
190
|
+
/**
|
|
191
|
+
* RF_FE_008:HTTP 非 2xx 且未被 onRejected 拦截器恢复。
|
|
192
|
+
*
|
|
193
|
+
* `response` 携带完整的 ResponseData(status/headers/data/config),
|
|
194
|
+
* 供响应拦截器 onRejected 链与最终 catch 逐段检查响应体——典型场景:
|
|
195
|
+
* Laravel 422 校验错误回显(`err.response.data.errors`)。
|
|
196
|
+
*/
|
|
184
197
|
declare class HTTPError extends ForgeError {
|
|
198
|
+
readonly response?: ResponseData;
|
|
185
199
|
constructor(message: string, opts: {
|
|
186
200
|
route?: string;
|
|
187
201
|
level?: string;
|
|
@@ -189,11 +203,16 @@ declare class HTTPError extends ForgeError {
|
|
|
189
203
|
url?: string;
|
|
190
204
|
method?: string;
|
|
191
205
|
cause?: unknown;
|
|
206
|
+
response?: ResponseData;
|
|
192
207
|
});
|
|
193
208
|
}
|
|
194
209
|
/** RF_FE_009:请求被 AbortSignal 取消 */
|
|
195
210
|
declare class RequestAbortedError extends ForgeError {
|
|
196
211
|
constructor(route?: string, level?: string, cause?: unknown);
|
|
197
212
|
}
|
|
213
|
+
/** RF_FE_010:auto-discovery 未完成时调用 route()/hasRoute() 的同步守卫(api() 内部 await discovery,不受此限) */
|
|
214
|
+
declare class DiscoveryNotReadyError extends ForgeError {
|
|
215
|
+
constructor();
|
|
216
|
+
}
|
|
198
217
|
|
|
199
|
-
export { AdapterNotFoundError, CacheStorage, ForgeError, type ForgeErrorCode, HTTPError, InterceptorHandler, InterceptorManager, InterceptorManagerImpl, InvalidInterceptorReturnError, LevelRoutesResponse, MissingRouteParamError, NetworkError, RequestAbortedError, RouteCache, RouteForge, RouteForgeOptions, RouteMeta, type RouteResolver, UnknownLevelError, UnknownRouteError, createInterceptorManager, createRouteForge, resolveRouteName, resolveRouteNameSync };
|
|
218
|
+
export { AdapterNotFoundError, CacheStorage, DiscoveryNotReadyError, ForgeError, type ForgeErrorCode, HTTPError, InterceptorHandler, InterceptorManager, InterceptorManagerImpl, InvalidInterceptorReturnError, InvalidPathParamError, LevelRoutesResponse, MissingRouteParamError, NetworkError, RequestAbortedError, ResponseData, RouteCache, RouteForge, RouteForgeOptions, RouteMeta, type RouteResolver, UnknownLevelError, UnknownRouteError, createInterceptorManager, createRouteForge, resolveRouteName, resolveRouteNameSync };
|