@ubean/routes 0.4.5 → 0.4.6
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/index.d.ts +72 -72
- package/dist/runtime.d.ts +7 -7
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -8,15 +8,15 @@ import { FetchAdapter } from "@soybeanjs/fetch";
|
|
|
8
8
|
interface MiddlewareChain extends Array<MiddlewareHandler> {
|
|
9
9
|
__routeMeta?: RouteMeta$1;
|
|
10
10
|
}
|
|
11
|
-
declare function defineHandler<I extends Input$1 = {}, R extends HandlerResponse<any> = any>(handler1: H<UbeanEnv$1, any, I, R>): [H<UbeanEnv$1, any, I, R>];
|
|
12
|
-
declare function defineHandler<I extends Input$1 = {}, I2 extends Input$1 = I, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any>(handler1: H<UbeanEnv$1, any, I, R>, handler2: H<UbeanEnv$1, any, I & I2, R2>): [H<UbeanEnv$1, any, I, R>, H<UbeanEnv$1, any, I & I2, R2>];
|
|
13
|
-
declare function defineHandler<I extends Input$1 = {}, I2 extends Input$1 = I, I3 extends Input$1 = I & I2, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any>(handler1: H<UbeanEnv$1, any, I, R>, handler2: H<UbeanEnv$1, any, I2, R2>, handler3: H<UbeanEnv$1, any, I3, R3>): [H<UbeanEnv$1, any, I, R>, H<UbeanEnv$1, any, I2, R2>, H<UbeanEnv$1, any, I3, R3>];
|
|
14
|
-
declare function defineHandler<I extends Input$1 = {}, I2 extends Input$1 = I, I3 extends Input$1 = I & I2, I4 extends Input$1 = I & I2 & I3, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any, R4 extends HandlerResponse<any> = any>(handler1: H<UbeanEnv$1, any, I, R>, handler2: H<UbeanEnv$1, any, I2, R2>, handler3: H<UbeanEnv$1, any, I3, R3>, handler4: H<UbeanEnv$1, any, I4, R4>): [H<UbeanEnv$1, any, I, R>, H<UbeanEnv$1, any, I2, R2>, H<UbeanEnv$1, any, I3, R3>, H<UbeanEnv$1, any, I4, R4>];
|
|
15
|
-
declare function defineHandler<I extends Input$1 = {}, I2 extends Input$1 = I, I3 extends Input$1 = I & I2, I4 extends Input$1 = I & I2 & I3, I5 extends Input$1 = I & I2 & I3 & I4, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any, R4 extends HandlerResponse<any> = any, R5 extends HandlerResponse<any> = any>(handler1: H<UbeanEnv$1, any, I, R>, handler2: H<UbeanEnv$1, any, I2, R2>, handler3: H<UbeanEnv$1, any, I3, R3>, handler4: H<UbeanEnv$1, any, I4, R4>, handler5: H<UbeanEnv$1, any, I5, R5>): [H<UbeanEnv$1, any, I, R>, H<UbeanEnv$1, any, I2, R2>, H<UbeanEnv$1, any, I3, R3>, H<UbeanEnv$1, any, I4, R4>, H<UbeanEnv$1, any, I5, R5>];
|
|
16
|
-
declare function isHandlerChain(obj: unknown): obj is MiddlewareChain;
|
|
17
|
-
declare function extractRouteMeta(handlers: MiddlewareHandler[]): RouteMeta$1;
|
|
18
|
-
declare function defineHandlerMeta(meta: Partial<RouteMeta$1>): (_c: Context<UbeanEnv$1>, next: Next) => Promise<void>;
|
|
19
|
-
declare function defineMiddleware(handler: MiddlewareHandler<UbeanEnv$1>): MiddlewareHandler<UbeanEnv$1>;
|
|
11
|
+
export declare function defineHandler<I extends Input$1 = {}, R extends HandlerResponse<any> = any>(handler1: H<UbeanEnv$1, any, I, R>): [H<UbeanEnv$1, any, I, R>];
|
|
12
|
+
export declare function defineHandler<I extends Input$1 = {}, I2 extends Input$1 = I, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any>(handler1: H<UbeanEnv$1, any, I, R>, handler2: H<UbeanEnv$1, any, I & I2, R2>): [H<UbeanEnv$1, any, I, R>, H<UbeanEnv$1, any, I & I2, R2>];
|
|
13
|
+
export declare function defineHandler<I extends Input$1 = {}, I2 extends Input$1 = I, I3 extends Input$1 = I & I2, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any>(handler1: H<UbeanEnv$1, any, I, R>, handler2: H<UbeanEnv$1, any, I2, R2>, handler3: H<UbeanEnv$1, any, I3, R3>): [H<UbeanEnv$1, any, I, R>, H<UbeanEnv$1, any, I2, R2>, H<UbeanEnv$1, any, I3, R3>];
|
|
14
|
+
export declare function defineHandler<I extends Input$1 = {}, I2 extends Input$1 = I, I3 extends Input$1 = I & I2, I4 extends Input$1 = I & I2 & I3, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any, R4 extends HandlerResponse<any> = any>(handler1: H<UbeanEnv$1, any, I, R>, handler2: H<UbeanEnv$1, any, I2, R2>, handler3: H<UbeanEnv$1, any, I3, R3>, handler4: H<UbeanEnv$1, any, I4, R4>): [H<UbeanEnv$1, any, I, R>, H<UbeanEnv$1, any, I2, R2>, H<UbeanEnv$1, any, I3, R3>, H<UbeanEnv$1, any, I4, R4>];
|
|
15
|
+
export declare function defineHandler<I extends Input$1 = {}, I2 extends Input$1 = I, I3 extends Input$1 = I & I2, I4 extends Input$1 = I & I2 & I3, I5 extends Input$1 = I & I2 & I3 & I4, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any, R4 extends HandlerResponse<any> = any, R5 extends HandlerResponse<any> = any>(handler1: H<UbeanEnv$1, any, I, R>, handler2: H<UbeanEnv$1, any, I2, R2>, handler3: H<UbeanEnv$1, any, I3, R3>, handler4: H<UbeanEnv$1, any, I4, R4>, handler5: H<UbeanEnv$1, any, I5, R5>): [H<UbeanEnv$1, any, I, R>, H<UbeanEnv$1, any, I2, R2>, H<UbeanEnv$1, any, I3, R3>, H<UbeanEnv$1, any, I4, R4>, H<UbeanEnv$1, any, I5, R5>];
|
|
16
|
+
export declare function isHandlerChain(obj: unknown): obj is MiddlewareChain;
|
|
17
|
+
export declare function extractRouteMeta(handlers: MiddlewareHandler[]): RouteMeta$1;
|
|
18
|
+
export declare function defineHandlerMeta(meta: Partial<RouteMeta$1>): (_c: Context<UbeanEnv$1>, next: Next) => Promise<void>;
|
|
19
|
+
export declare function defineMiddleware(handler: MiddlewareHandler<UbeanEnv$1>): MiddlewareHandler<UbeanEnv$1>;
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/server-router.d.ts
|
|
22
22
|
interface CompiledRoute {
|
|
@@ -44,7 +44,7 @@ interface CompiledLayout {
|
|
|
44
44
|
filePath: string;
|
|
45
45
|
isDefault: boolean;
|
|
46
46
|
}
|
|
47
|
-
declare class UbeanRouter {
|
|
47
|
+
export declare class UbeanRouter {
|
|
48
48
|
private apiContext;
|
|
49
49
|
private middlewares;
|
|
50
50
|
private pages;
|
|
@@ -63,14 +63,14 @@ declare class UbeanRouter {
|
|
|
63
63
|
getLayouts(): CompiledLayout[];
|
|
64
64
|
getPageRouteNames(): string[];
|
|
65
65
|
}
|
|
66
|
-
declare function useRouter(): UbeanRouter;
|
|
66
|
+
export declare function useRouter(): UbeanRouter;
|
|
67
67
|
/**
|
|
68
68
|
* 创建服务端 rou3 router 实例(无参数)。
|
|
69
69
|
*
|
|
70
70
|
* 命名说明:与 `@ubean/client` 的 `createUbeanRouter`(Vue Router 工厂,
|
|
71
71
|
* 接受 options)曾是同名冲突,服务端版本改名 `createServerRouter` 彻底消歧。
|
|
72
72
|
*/
|
|
73
|
-
declare function createServerRouter(): UbeanRouter;
|
|
73
|
+
export declare function createServerRouter(): UbeanRouter;
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/isr.d.ts
|
|
76
76
|
/**
|
|
@@ -115,34 +115,34 @@ interface IsrServeOptions {
|
|
|
115
115
|
/** cache store(必传 —— 由调用方通过 RegisterOptions.cacheStore 注入) */
|
|
116
116
|
store: IsrCacheStore;
|
|
117
117
|
}
|
|
118
|
-
declare function buildIsrCacheKey(pathname: string): string;
|
|
118
|
+
export declare function buildIsrCacheKey(pathname: string): string;
|
|
119
119
|
/**
|
|
120
120
|
* 读取缓存的 ISR entry(仅未过期)。
|
|
121
121
|
*/
|
|
122
|
-
declare function getIsrCache(store: IsrCacheStore, pathname: string): Promise<IsrCacheEntry | undefined>;
|
|
122
|
+
export declare function getIsrCache(store: IsrCacheStore, pathname: string): Promise<IsrCacheEntry | undefined>;
|
|
123
123
|
/**
|
|
124
124
|
* 读取缓存的 ISR entry(即使已过期,用于 SWR)。
|
|
125
125
|
* 后端不支持 `peek` 时退化为 `get`(无 SWR)。
|
|
126
126
|
*/
|
|
127
|
-
declare function getStaleIsrCache(store: IsrCacheStore, pathname: string): Promise<IsrCacheEntry | undefined>;
|
|
127
|
+
export declare function getStaleIsrCache(store: IsrCacheStore, pathname: string): Promise<IsrCacheEntry | undefined>;
|
|
128
128
|
/**
|
|
129
129
|
* 写入 ISR 缓存。
|
|
130
130
|
*/
|
|
131
|
-
declare function setIsrCache(store: IsrCacheStore, pathname: string, entry: IsrCacheEntry, ttl: number): Promise<void>;
|
|
131
|
+
export declare function setIsrCache(store: IsrCacheStore, pathname: string, entry: IsrCacheEntry, ttl: number): Promise<void>;
|
|
132
132
|
/**
|
|
133
133
|
* 失效指定路径的 ISR 缓存。需要调用方提供 store(避免本包依赖全局单例)。
|
|
134
134
|
*/
|
|
135
|
-
declare function invalidateIsrCache(store: IsrCacheStore, pathname: string): Promise<boolean>;
|
|
135
|
+
export declare function invalidateIsrCache(store: IsrCacheStore, pathname: string): Promise<boolean>;
|
|
136
136
|
/**
|
|
137
137
|
* 失效所有匹配模式的 ISR 缓存。仅对内存存储有效(读取底层 Map)。
|
|
138
138
|
*/
|
|
139
|
-
declare function invalidateIsrCachePattern(store: IsrCacheStore, pattern: RegExp): Promise<number>;
|
|
139
|
+
export declare function invalidateIsrCachePattern(store: IsrCacheStore, pattern: RegExp): Promise<number>;
|
|
140
140
|
/**
|
|
141
141
|
* 判断 entry 是否已过期。配合 `getStaleIsrCache` 用于 SWR 判定。
|
|
142
142
|
* 仅内存存储可用 —— 其他后端在 `getStaleIsrCache` 已退化为 `get`(永远 fresh),
|
|
143
143
|
* 不会进入此分支。
|
|
144
144
|
*/
|
|
145
|
-
declare function isIsrEntryStale(pathname: string, store: IsrCacheStore): boolean;
|
|
145
|
+
export declare function isIsrEntryStale(pathname: string, store: IsrCacheStore): boolean;
|
|
146
146
|
/**
|
|
147
147
|
* ISR 主入口:检查缓存 → 命中则返回,未命中/过期则调用 render 重新生成。
|
|
148
148
|
*
|
|
@@ -153,12 +153,12 @@ declare function isIsrEntryStale(pathname: string, store: IsrCacheStore): boolea
|
|
|
153
153
|
* 过期时删除 entry 导致 SWR 无法读取旧内容。后端不支持 `peek` 时退化为 `get`
|
|
154
154
|
* (SWR 自动降级为同步重新生成)。
|
|
155
155
|
*/
|
|
156
|
-
declare function serveIsr(_c: Context<UbeanEnv$1>, options: IsrServeOptions): Promise<Response | undefined>;
|
|
156
|
+
export declare function serveIsr(_c: Context<UbeanEnv$1>, options: IsrServeOptions): Promise<Response | undefined>;
|
|
157
157
|
/**
|
|
158
158
|
* 从 context 读取匹配到的 routeRule,提取 ISR 规则。
|
|
159
159
|
* 返回 `undefined` 表示该路由未启用 ISR。
|
|
160
160
|
*/
|
|
161
|
-
declare function getIsrRuleFromContext(c: Context<UbeanEnv$1>): IsrRule$1 | undefined;
|
|
161
|
+
export declare function getIsrRuleFromContext(c: Context<UbeanEnv$1>): IsrRule$1 | undefined;
|
|
162
162
|
//#endregion
|
|
163
163
|
//#region src/router.d.ts
|
|
164
164
|
/**
|
|
@@ -234,14 +234,14 @@ interface RegisterOptions {
|
|
|
234
234
|
*/
|
|
235
235
|
colorModeScript?: string;
|
|
236
236
|
}
|
|
237
|
-
declare function convertUbeanRoutePath(path: string): string;
|
|
238
|
-
declare function sortPagesForRegistration<T extends {
|
|
237
|
+
export declare function convertUbeanRoutePath(path: string): string;
|
|
238
|
+
export declare function sortPagesForRegistration<T extends {
|
|
239
239
|
route: string;
|
|
240
240
|
}>(pages: readonly T[]): T[];
|
|
241
|
-
declare function registerApiRoutes(app: RouteRegistrar, options: RegisterOptions): Promise<void>;
|
|
242
|
-
declare function registerPageRoutes(app: RouteRegistrar, options: RegisterOptions): Promise<void>;
|
|
243
|
-
declare function registerRoutes(app: RouteRegistrar, options: RegisterOptions): Promise<void>;
|
|
244
|
-
declare function createRouteLoader(importMetaGlob: Record<string, () => Promise<any>>): {
|
|
241
|
+
export declare function registerApiRoutes(app: RouteRegistrar, options: RegisterOptions): Promise<void>;
|
|
242
|
+
export declare function registerPageRoutes(app: RouteRegistrar, options: RegisterOptions): Promise<void>;
|
|
243
|
+
export declare function registerRoutes(app: RouteRegistrar, options: RegisterOptions): Promise<void>;
|
|
244
|
+
export declare function createRouteLoader(importMetaGlob: Record<string, () => Promise<any>>): {
|
|
245
245
|
[k: string]: () => Promise<any>;
|
|
246
246
|
};
|
|
247
247
|
//#endregion
|
|
@@ -254,7 +254,7 @@ declare function createRouteLoader(importMetaGlob: Record<string, () => Promise<
|
|
|
254
254
|
* - target containing `$1` receives the captured suffix without a leading slash
|
|
255
255
|
* - absolute `https://…` targets keep the origin and transform the pathname
|
|
256
256
|
*/
|
|
257
|
-
declare function applyPathTransform(requestPath: string, rulePath: string, target: string): string;
|
|
257
|
+
export declare function applyPathTransform(requestPath: string, rulePath: string, target: string): string;
|
|
258
258
|
//#endregion
|
|
259
259
|
//#region src/route-rules.d.ts
|
|
260
260
|
interface CompiledRouteRule {
|
|
@@ -270,14 +270,14 @@ interface RouteRulesMiddlewareOptions {
|
|
|
270
270
|
*/
|
|
271
271
|
dispatch?: (request: Request) => Promise<Response>;
|
|
272
272
|
}
|
|
273
|
-
declare function compileRouteRules(rules: Record<string, RouteRule$1>): CompiledRouteRule[];
|
|
273
|
+
export declare function compileRouteRules(rules: Record<string, RouteRule$1>): CompiledRouteRule[];
|
|
274
274
|
/**
|
|
275
275
|
* 规范化 `isr` 字段为 `IsrRule` 对象形式。
|
|
276
276
|
* `number` → `{ ttl: n }`,`undefined` → `undefined`。
|
|
277
277
|
*/
|
|
278
|
-
declare function normalizeIsrRule(isr: RouteRule$1['isr']): IsrRule$1 | undefined;
|
|
279
|
-
declare function matchRouteRules(path: string, compiledRules: CompiledRouteRule[]): RouteRule$1;
|
|
280
|
-
declare function createRouteRulesMiddleware(rules: Record<string, RouteRule$1>, options?: RouteRulesMiddlewareOptions): (c: Context, next: Next) => Promise<Response | undefined>;
|
|
278
|
+
export declare function normalizeIsrRule(isr: RouteRule$1['isr']): IsrRule$1 | undefined;
|
|
279
|
+
export declare function matchRouteRules(path: string, compiledRules: CompiledRouteRule[]): RouteRule$1;
|
|
280
|
+
export declare function createRouteRulesMiddleware(rules: Record<string, RouteRule$1>, options?: RouteRulesMiddlewareOptions): (c: Context, next: Next) => Promise<Response | undefined>;
|
|
281
281
|
//#endregion
|
|
282
282
|
//#region src/select-ssr.d.ts
|
|
283
283
|
type SelectSsrValue = boolean | 'streaming' | 'data-only';
|
|
@@ -299,8 +299,8 @@ interface ResolvedSelectSsr {
|
|
|
299
299
|
* the global exclude list. Glob exclude stays backward-compatible (CSR shell
|
|
300
300
|
* still runs loader). Explicit `ssr: false` skips the loader.
|
|
301
301
|
*/
|
|
302
|
-
declare function resolveSelectSsr(input: ResolveSelectSsrInput): ResolvedSelectSsr;
|
|
303
|
-
declare function ssrModeHeader(mode: SelectSsrMode): string;
|
|
302
|
+
export declare function resolveSelectSsr(input: ResolveSelectSsrInput): ResolvedSelectSsr;
|
|
303
|
+
export declare function ssrModeHeader(mode: SelectSsrMode): string;
|
|
304
304
|
//#endregion
|
|
305
305
|
//#region src/actions/define.d.ts
|
|
306
306
|
interface DefineActionOptions {
|
|
@@ -330,19 +330,19 @@ interface DefineActionOptions {
|
|
|
330
330
|
* output). On validation failure, the action returns an `ActionResult`
|
|
331
331
|
* with `errors` set to the schema's issue messages.
|
|
332
332
|
*/
|
|
333
|
-
declare function defineAction<TOutput>(schema: ActionSchema$1<TOutput>, handler: ActionHandler$1<TOutput, unknown>, options?: DefineActionOptions): ServerAction$1<TOutput, unknown>;
|
|
333
|
+
export declare function defineAction<TOutput>(schema: ActionSchema$1<TOutput>, handler: ActionHandler$1<TOutput, unknown>, options?: DefineActionOptions): ServerAction$1<TOutput, unknown>;
|
|
334
334
|
/**
|
|
335
335
|
* Define a server action without a schema.
|
|
336
336
|
*
|
|
337
337
|
* The handler receives the raw input (FormData or parsed JSON object).
|
|
338
338
|
*/
|
|
339
|
-
declare function defineAction<TInput = unknown, TOutput = unknown>(handler: ActionHandler$1<TInput, TOutput>, options?: DefineActionOptions): ServerAction$1<TInput, TOutput>;
|
|
339
|
+
export declare function defineAction<TInput = unknown, TOutput = unknown>(handler: ActionHandler$1<TInput, TOutput>, options?: DefineActionOptions): ServerAction$1<TInput, TOutput>;
|
|
340
340
|
/**
|
|
341
341
|
* Type-safe server function. Same ID, registry, and `POST /__actions` RPC as
|
|
342
342
|
* `defineAction` — use this alias when the function is a loader/query as well
|
|
343
343
|
* as a mutation. Do not invent a second RPC.
|
|
344
344
|
*/
|
|
345
|
-
declare const defineServerFn: typeof defineAction;
|
|
345
|
+
export declare const defineServerFn: typeof defineAction;
|
|
346
346
|
/**
|
|
347
347
|
* Parse a Request body into a plain object suitable for action handlers.
|
|
348
348
|
*
|
|
@@ -351,8 +351,8 @@ declare const defineServerFn: typeof defineAction;
|
|
|
351
351
|
* from FormData entries (string values, files skipped)
|
|
352
352
|
* - Otherwise → empty object (handler can read `ctx.request` directly)
|
|
353
353
|
*/
|
|
354
|
-
declare function parseActionInput(request: Request): Promise<Record<string, unknown>>;
|
|
355
|
-
declare function validateActionInput<T>(schema: ActionSchema$1<T>, input: unknown): {
|
|
354
|
+
export declare function parseActionInput(request: Request): Promise<Record<string, unknown>>;
|
|
355
|
+
export declare function validateActionInput<T>(schema: ActionSchema$1<T>, input: unknown): {
|
|
356
356
|
success: true;
|
|
357
357
|
data: T;
|
|
358
358
|
} | {
|
|
@@ -367,7 +367,7 @@ declare function validateActionInput<T>(schema: ActionSchema$1<T>, input: unknow
|
|
|
367
367
|
* - Other thrown error → `{ error: { message }, status: 500 }`
|
|
368
368
|
* - Plain value → `{ data: value, status: 200 }`
|
|
369
369
|
*/
|
|
370
|
-
declare function normalizeActionResult(result: unknown, error: unknown, failureStatus?: number): {
|
|
370
|
+
export declare function normalizeActionResult(result: unknown, error: unknown, failureStatus?: number): {
|
|
371
371
|
data?: unknown;
|
|
372
372
|
error?: {
|
|
373
373
|
message: string;
|
|
@@ -383,17 +383,17 @@ declare function normalizeActionResult(result: unknown, error: unknown, failureS
|
|
|
383
383
|
* - `context`: the Hono context (for `c.set`, `c.get`, etc.)
|
|
384
384
|
* - `params`: route params from `c.req.param()`
|
|
385
385
|
*/
|
|
386
|
-
declare function buildActionContext(c: Context<UbeanEnv$1>): ActionContext$1;
|
|
386
|
+
export declare function buildActionContext(c: Context<UbeanEnv$1>): ActionContext$1;
|
|
387
387
|
//#endregion
|
|
388
388
|
//#region src/actions/request-context.d.ts
|
|
389
389
|
interface ActionContextStorage {
|
|
390
390
|
getStore(): ActionContext$1 | undefined;
|
|
391
391
|
run<T>(ctx: ActionContext$1, fn: () => T): T;
|
|
392
392
|
}
|
|
393
|
-
declare function bindActionContextStorage(storage: ActionContextStorage): void;
|
|
394
|
-
declare function getActionContext(): ActionContext$1 | undefined;
|
|
395
|
-
declare function runWithActionContext<T>(ctx: ActionContext$1, fn: () => T): T;
|
|
396
|
-
declare function createDetachedActionContext(request?: Request): ActionContext$1;
|
|
393
|
+
export declare function bindActionContextStorage(storage: ActionContextStorage): void;
|
|
394
|
+
export declare function getActionContext(): ActionContext$1 | undefined;
|
|
395
|
+
export declare function runWithActionContext<T>(ctx: ActionContext$1, fn: () => T): T;
|
|
396
|
+
export declare function createDetachedActionContext(request?: Request): ActionContext$1;
|
|
397
397
|
//#endregion
|
|
398
398
|
//#region src/actions/openapi.d.ts
|
|
399
399
|
/**
|
|
@@ -402,7 +402,7 @@ declare function createDetachedActionContext(request?: Request): ActionContext$1
|
|
|
402
402
|
* Per-action operations stay on the same endpoint (id in the body) so this
|
|
403
403
|
* does not create a second RPC surface.
|
|
404
404
|
*/
|
|
405
|
-
declare function describeActionsOpenApi(): {
|
|
405
|
+
export declare function describeActionsOpenApi(): {
|
|
406
406
|
paths: Record<string, {
|
|
407
407
|
post: {
|
|
408
408
|
summary: string;
|
|
@@ -435,13 +435,13 @@ declare function describeActionsOpenApi(): {
|
|
|
435
435
|
* @param exportName The export name (e.g. `login`, `default`)
|
|
436
436
|
* @returns A stable action ID string
|
|
437
437
|
*/
|
|
438
|
-
declare function createActionId(filePath: string, exportName: string): string;
|
|
438
|
+
export declare function createActionId(filePath: string, exportName: string): string;
|
|
439
439
|
/**
|
|
440
440
|
* Validate that a string is a well-formed action ID.
|
|
441
441
|
*
|
|
442
442
|
* Used by the dispatcher to reject malformed requests early.
|
|
443
443
|
*/
|
|
444
|
-
declare function isValidActionId(id: string): boolean;
|
|
444
|
+
export declare function isValidActionId(id: string): boolean;
|
|
445
445
|
//#endregion
|
|
446
446
|
//#region src/actions/registry.d.ts
|
|
447
447
|
/**
|
|
@@ -454,31 +454,31 @@ declare function isValidActionId(id: string): boolean;
|
|
|
454
454
|
* no-op (HMR-safe: re-registering the same action on hot reload doesn't
|
|
455
455
|
* throw).
|
|
456
456
|
*/
|
|
457
|
-
declare function registerAction(action: ServerAction$1): void;
|
|
457
|
+
export declare function registerAction(action: ServerAction$1): void;
|
|
458
458
|
/**
|
|
459
459
|
* Look up a registered server action by ID.
|
|
460
460
|
*/
|
|
461
|
-
declare function getAction(id: ActionId$1): ServerAction$1 | undefined;
|
|
461
|
+
export declare function getAction(id: ActionId$1): ServerAction$1 | undefined;
|
|
462
462
|
/**
|
|
463
463
|
* Check whether an action with the given ID is registered.
|
|
464
464
|
*/
|
|
465
|
-
declare function hasAction(id: ActionId$1): boolean;
|
|
465
|
+
export declare function hasAction(id: ActionId$1): boolean;
|
|
466
466
|
/**
|
|
467
467
|
* List all registered actions (for debugging / DevTools).
|
|
468
468
|
*/
|
|
469
|
-
declare function listActions(): ServerAction$1[];
|
|
469
|
+
export declare function listActions(): ServerAction$1[];
|
|
470
470
|
/**
|
|
471
471
|
* Clear the registry (for tests).
|
|
472
472
|
*
|
|
473
473
|
* Not intended for application code — actions are registered once at
|
|
474
474
|
* module load and remain for the lifetime of the process.
|
|
475
475
|
*/
|
|
476
|
-
declare function clearActions(): void;
|
|
476
|
+
export declare function clearActions(): void;
|
|
477
477
|
/**
|
|
478
478
|
* Register a map of actions at once (bulk registration helper for the
|
|
479
479
|
* Vite plugin's virtual module).
|
|
480
480
|
*/
|
|
481
|
-
declare function registerActions(actions: ServerAction$1[]): void;
|
|
481
|
+
export declare function registerActions(actions: ServerAction$1[]): void;
|
|
482
482
|
//#endregion
|
|
483
483
|
//#region src/actions/dispatch.d.ts
|
|
484
484
|
/**
|
|
@@ -495,7 +495,7 @@ declare function registerActions(actions: ServerAction$1[]): void;
|
|
|
495
495
|
* Returns an `ActionResult` (serializable). When the action ID is unknown
|
|
496
496
|
* or invalid, returns a 404 error result without throwing.
|
|
497
497
|
*/
|
|
498
|
-
declare function dispatchAction(actionId: string, c: Context<UbeanEnv$1>, preParsedInput?: unknown): Promise<ActionResult$1>;
|
|
498
|
+
export declare function dispatchAction(actionId: string, c: Context<UbeanEnv$1>, preParsedInput?: unknown): Promise<ActionResult$1>;
|
|
499
499
|
/**
|
|
500
500
|
* Run an arbitrary `ServerAction` against the given Hono context.
|
|
501
501
|
*
|
|
@@ -507,7 +507,7 @@ declare function dispatchAction(actionId: string, c: Context<UbeanEnv$1>, prePar
|
|
|
507
507
|
* has already read the request body — e.g. the RPC middleware extracting
|
|
508
508
|
* the `{ id, args }` envelope).
|
|
509
509
|
*/
|
|
510
|
-
declare function runAction<TInput, TOutput>(action: ServerAction$1<TInput, TOutput>, c: Context<UbeanEnv$1>, preParsedInput?: unknown): Promise<ActionResult$1<TOutput>>;
|
|
510
|
+
export declare function runAction<TInput, TOutput>(action: ServerAction$1<TInput, TOutput>, c: Context<UbeanEnv$1>, preParsedInput?: unknown): Promise<ActionResult$1<TOutput>>;
|
|
511
511
|
/**
|
|
512
512
|
* Run a page-level form action by name (SvelteKit-style `?/name` convention).
|
|
513
513
|
*
|
|
@@ -533,7 +533,7 @@ declare function runAction<TInput, TOutput>(action: ServerAction$1<TInput, TOutp
|
|
|
533
533
|
* `ActionResult` into an HTTP response (HTML for browser navigation,
|
|
534
534
|
* JSON for SPA `submit()` calls).
|
|
535
535
|
*/
|
|
536
|
-
declare function runPageAction(actions: Record<string, ServerAction$1>, actionName: string, c: Context<UbeanEnv$1>): Promise<ActionResult$1 | null>;
|
|
536
|
+
export declare function runPageAction(actions: Record<string, ServerAction$1>, actionName: string, c: Context<UbeanEnv$1>): Promise<ActionResult$1 | null>;
|
|
537
537
|
//#endregion
|
|
538
538
|
//#region src/actions/constants.d.ts
|
|
539
539
|
/**
|
|
@@ -542,8 +542,8 @@ declare function runPageAction(actions: Record<string, ServerAction$1>, actionNa
|
|
|
542
542
|
* Kept in a leaf module so the browser runtime can import them without
|
|
543
543
|
* pulling the Hono middleware barrel.
|
|
544
544
|
*/
|
|
545
|
-
declare const ACTIONS_ENDPOINT = "/__actions";
|
|
546
|
-
declare const ACTION_RESPONSE_HEADER = "x-ubean-action";
|
|
545
|
+
export declare const ACTIONS_ENDPOINT = "/__actions";
|
|
546
|
+
export declare const ACTION_RESPONSE_HEADER = "x-ubean-action";
|
|
547
547
|
//#endregion
|
|
548
548
|
//#region src/actions/middleware.d.ts
|
|
549
549
|
/**
|
|
@@ -563,14 +563,14 @@ declare const ACTION_RESPONSE_HEADER = "x-ubean-action";
|
|
|
563
563
|
* The middleware is auto-registered by ubean's dev server / production
|
|
564
564
|
* server setup — users don't need to mount it manually.
|
|
565
565
|
*/
|
|
566
|
-
declare function createActionsMiddleware(): MiddlewareHandler<UbeanEnv$1>;
|
|
566
|
+
export declare function createActionsMiddleware(): MiddlewareHandler<UbeanEnv$1>;
|
|
567
567
|
/**
|
|
568
568
|
* Check whether a request targets the actions endpoint.
|
|
569
569
|
*
|
|
570
570
|
* Used by route registrars to skip registering regular API routes for
|
|
571
571
|
* the `/__actions` path.
|
|
572
572
|
*/
|
|
573
|
-
declare function isActionsRequest(c: {
|
|
573
|
+
export declare function isActionsRequest(c: {
|
|
574
574
|
req: {
|
|
575
575
|
path: string;
|
|
576
576
|
method: string;
|
|
@@ -581,7 +581,7 @@ declare function isActionsRequest(c: {
|
|
|
581
581
|
*
|
|
582
582
|
* Used by the client `callAction()` to validate the response shape.
|
|
583
583
|
*/
|
|
584
|
-
declare function isActionResponse(response: Response): boolean;
|
|
584
|
+
export declare function isActionResponse(response: Response): boolean;
|
|
585
585
|
//#endregion
|
|
586
586
|
//#region src/actions/form-action.d.ts
|
|
587
587
|
/**
|
|
@@ -614,7 +614,7 @@ declare function isActionResponse(response: Response): boolean;
|
|
|
614
614
|
* @returns The action name, or `'default'` when no specific action is
|
|
615
615
|
* specified.
|
|
616
616
|
*/
|
|
617
|
-
declare function parseFormActionName(url: string | URL): string;
|
|
617
|
+
export declare function parseFormActionName(url: string | URL): string;
|
|
618
618
|
/**
|
|
619
619
|
* Build a form action URL for the current page.
|
|
620
620
|
*
|
|
@@ -629,12 +629,12 @@ declare function parseFormActionName(url: string | URL): string;
|
|
|
629
629
|
* the browser submits to the current page URL with the action name
|
|
630
630
|
* appended as a query parameter.
|
|
631
631
|
*/
|
|
632
|
-
declare function buildFormActionUrl(actionName?: string): string;
|
|
632
|
+
export declare function buildFormActionUrl(actionName?: string): string;
|
|
633
633
|
/**
|
|
634
634
|
* Check whether a URL's query string contains a form action specifier
|
|
635
635
|
* (`?/<name>` pattern).
|
|
636
636
|
*/
|
|
637
|
-
declare function hasFormAction(url: string | URL): boolean;
|
|
637
|
+
export declare function hasFormAction(url: string | URL): boolean;
|
|
638
638
|
//#endregion
|
|
639
639
|
//#region src/internal-fetch.d.ts
|
|
640
640
|
interface InternalFetchOptions {
|
|
@@ -644,9 +644,9 @@ interface InternalFetchOptions {
|
|
|
644
644
|
forwardHeaders?: string[];
|
|
645
645
|
}
|
|
646
646
|
type AppFetcher = (request: Request) => Response | Promise<Response>;
|
|
647
|
-
declare function setInternalFetcher(fetcher: AppFetcher): void;
|
|
648
|
-
declare function getInternalFetcher(): AppFetcher | null;
|
|
649
|
-
declare function clearInternalFetcher(): void;
|
|
647
|
+
export declare function setInternalFetcher(fetcher: AppFetcher): void;
|
|
648
|
+
export declare function getInternalFetcher(): AppFetcher | null;
|
|
649
|
+
export declare function clearInternalFetcher(): void;
|
|
650
650
|
/**
|
|
651
651
|
* 创建进程内调度适配器。
|
|
652
652
|
*
|
|
@@ -667,7 +667,7 @@ declare function clearInternalFetcher(): void;
|
|
|
667
667
|
* @param c - Hono Context(可选,用于转发 cookie/authorization 等请求头)
|
|
668
668
|
* @param options - 选项(`headers` 自定义额外 header,`forwardHeaders` 自定义转发 header 列表)
|
|
669
669
|
*/
|
|
670
|
-
declare function createInternalAdapter(c?: Context<UbeanEnv$1>, options?: InternalFetchOptions): FetchAdapter;
|
|
670
|
+
export declare function createInternalAdapter(c?: Context<UbeanEnv$1>, options?: InternalFetchOptions): FetchAdapter;
|
|
671
671
|
//#endregion
|
|
672
672
|
//#region src/bot-detection.d.ts
|
|
673
673
|
/**
|
|
@@ -688,7 +688,7 @@ declare function createInternalAdapter(c?: Context<UbeanEnv$1>, options?: Intern
|
|
|
688
688
|
* @param ua User-Agent 字符串(来自 `c.req.header('user-agent')`)
|
|
689
689
|
* @returns `true` 表示疑似爬虫,应降级为缓冲渲染以保证 metadata 完整
|
|
690
690
|
*/
|
|
691
|
-
declare function isBotUserAgent(ua: string | undefined | null): boolean;
|
|
691
|
+
export declare function isBotUserAgent(ua: string | undefined | null): boolean;
|
|
692
692
|
//#endregion
|
|
693
693
|
//#region src/openapi.d.ts
|
|
694
694
|
interface OpenAPIGenerationOptions {
|
|
@@ -697,9 +697,9 @@ interface OpenAPIGenerationOptions {
|
|
|
697
697
|
description?: string;
|
|
698
698
|
baseURL?: string;
|
|
699
699
|
}
|
|
700
|
-
declare function registerOpenAPIRoutes(app: Hono<UbeanEnv$1>, options?: OpenAPIGenerationOptions & {
|
|
700
|
+
export declare function registerOpenAPIRoutes(app: Hono<UbeanEnv$1>, options?: OpenAPIGenerationOptions & {
|
|
701
701
|
scalarPath?: string;
|
|
702
702
|
openAPIPath?: string;
|
|
703
703
|
}): void;
|
|
704
704
|
//#endregion
|
|
705
|
-
export {
|
|
705
|
+
export { ACTION_BRAND, type ActionContext, type ActionContextStorage, ActionError, type ActionFailure, type ActionHandler, type ActionId, type ActionResult, type ActionSchema, type CompiledLayout, type CompiledMiddleware, type CompiledPage, type CompiledRoute, type CompiledRouteRule, type ComposedHandler, type DefineActionOptions, type GenericSchema, type Input, type InternalFetchOptions, type IsrCacheEntry, type IsrCacheEntryInternal, type IsrCacheStore, type IsrRule, type IsrServeOptions, type OpenAPIGenerationOptions, type RegisterOptions, type ResolveSelectSsrInput, type ResolvedSelectSsr, type RouteMeta, type RouteRegistrar, type RouteRule, type RouteRulesMiddlewareOptions, type SelectSsrMode, type SelectSsrValue, type ServerAction, type Span, type SpanAttributes, type SpanContext, type SpanEndOptions, type SpanEvent, type SpanOptions, type SpanStatus, type UbeanBindings, type UbeanContext, type UbeanEnv, type UbeanHandler, type UbeanMiddleware, type UbeanVariables, fail, invokeServerFn, isActionFailure, isServerAction, unwrapActionResult, unwrapServerFnResult };
|
package/dist/runtime.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { Ref } from "vue";
|
|
|
16
16
|
*
|
|
17
17
|
* @param actionId The stable action ID (e.g. `act_xxxxxxxxxxxx`)
|
|
18
18
|
*/
|
|
19
|
-
declare function createActionStub<TInput = unknown, TOutput = unknown>(actionId: string): ServerAction<TInput, TOutput>;
|
|
19
|
+
export declare function createActionStub<TInput = unknown, TOutput = unknown>(actionId: string): ServerAction<TInput, TOutput>;
|
|
20
20
|
/**
|
|
21
21
|
* Low-level RPC: invoke a registered server action by ID.
|
|
22
22
|
*
|
|
@@ -28,8 +28,8 @@ declare function createActionStub<TInput = unknown, TOutput = unknown>(actionId:
|
|
|
28
28
|
* @param args Arguments to pass to the action handler (serialized as JSON)
|
|
29
29
|
* @returns The `ActionResult` returned by the server
|
|
30
30
|
*/
|
|
31
|
-
declare function callAction<T = unknown>(actionId: string, args?: unknown[]): Promise<ActionResult<T>>;
|
|
32
|
-
interface UseActionReturn<TInput = unknown, TOutput = unknown> {
|
|
31
|
+
export declare function callAction<T = unknown>(actionId: string, args?: unknown[]): Promise<ActionResult<T>>;
|
|
32
|
+
export interface UseActionReturn<TInput = unknown, TOutput = unknown> {
|
|
33
33
|
/** Reactive flag: `true` while the action is in flight. */
|
|
34
34
|
pending: Ref<boolean>;
|
|
35
35
|
/** The latest `ActionResult.data` (success), or `null` on error. */
|
|
@@ -79,8 +79,8 @@ interface UseActionReturn<TInput = unknown, TOutput = unknown> {
|
|
|
79
79
|
* await submit(email, password);
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
|
-
declare function useAction<TInput = unknown, TOutput = unknown>(actionOrId: ServerAction<TInput, TOutput> | string): UseActionReturn<TInput, TOutput>;
|
|
83
|
-
interface UseFormActionReturn {
|
|
82
|
+
export declare function useAction<TInput = unknown, TOutput = unknown>(actionOrId: ServerAction<TInput, TOutput> | string): UseActionReturn<TInput, TOutput>;
|
|
83
|
+
export interface UseFormActionReturn {
|
|
84
84
|
/** The form `action` attribute value (e.g. `?/login`). */
|
|
85
85
|
action: string;
|
|
86
86
|
/** Reactive flag: `true` while the form is submitting via SPA. */
|
|
@@ -144,6 +144,6 @@ interface UseFormActionReturn {
|
|
|
144
144
|
* `?/login` — the server renders the result HTML, providing full
|
|
145
145
|
* progressive enhancement.
|
|
146
146
|
*/
|
|
147
|
-
declare function useFormAction(actionName?: string): UseFormActionReturn;
|
|
147
|
+
export declare function useFormAction(actionName?: string): UseFormActionReturn;
|
|
148
148
|
//#endregion
|
|
149
|
-
export {
|
|
149
|
+
export { invokeServerFn, unwrapActionResult, unwrapServerFnResult };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubean/routes",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "Server routes runtime for ubean (defineHandler, defineMiddleware, registerRoutes, Server Actions, rou3 server router, route rules, ISR, internal-fetch, OpenAPI)",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -24,23 +24,23 @@
|
|
|
24
24
|
"@soybeanjs/fetch": "^0.1.0",
|
|
25
25
|
"@standard-community/standard-json": "^0.3.6",
|
|
26
26
|
"@standard-community/standard-openapi": "^0.2.10",
|
|
27
|
-
"@ubean/i18n": "0.4.
|
|
28
|
-
"@ubean/shared": "0.4.
|
|
27
|
+
"@ubean/i18n": "0.4.6",
|
|
28
|
+
"@ubean/shared": "0.4.6",
|
|
29
29
|
"hono": "4.13.7",
|
|
30
30
|
"hono-openapi": "^1.3.2",
|
|
31
31
|
"rou3": "^0.9.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^26.5.0",
|
|
35
|
-
"@ubean/pages": "0.4.
|
|
36
|
-
"@ubean/scan": "0.4.
|
|
37
|
-
"typescript": "
|
|
38
|
-
"vite-plus": "0.3.
|
|
35
|
+
"@ubean/pages": "0.4.6",
|
|
36
|
+
"@ubean/scan": "0.4.6",
|
|
37
|
+
"typescript": "npm:typescript-native-bridge@latest",
|
|
38
|
+
"vite-plus": "0.3.1",
|
|
39
39
|
"vue": "^3.5.42"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@ubean/pages": "0.4.
|
|
43
|
-
"@ubean/scan": "0.4.
|
|
42
|
+
"@ubean/pages": "0.4.6",
|
|
43
|
+
"@ubean/scan": "0.4.6",
|
|
44
44
|
"vue": "^3.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|