@kevisual/router 0.0.71 → 0.0.73
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/app.d.ts +5 -0
- package/dist/app.js +19518 -0
- package/dist/opencode.d.ts +8 -3
- package/dist/opencode.js +13380 -14323
- package/dist/router-browser.d.ts +25 -21
- package/dist/router-browser.js +14059 -15098
- package/dist/router-define.d.ts +399 -3
- package/dist/router-define.js +126 -124
- package/dist/router-simple.js +665 -759
- package/dist/router.d.ts +25 -21
- package/dist/router.js +17840 -21155
- package/dist/ws.d.ts +8 -3
- package/dist/ws.js +2980 -150
- package/package.json +19 -54
- package/src/app.ts +2 -2
- package/src/browser.ts +1 -1
- package/src/index.ts +1 -1
- package/src/route.ts +30 -15
- package/src/router-define.ts +1 -1
- package/src/utils/random.ts +8 -0
package/dist/router-browser.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { RouteOpts as RouteOpts$1, QueryRouterServer as QueryRouterServer$1, RouteMiddleware as RouteMiddleware$1, Run as Run$1 } from '@kevisual/router';
|
|
4
3
|
import { Query, DataOpts, Result } from '@kevisual/query/query';
|
|
5
4
|
|
|
6
5
|
declare class MockProcess {
|
|
@@ -198,7 +197,7 @@ declare class Route<U = {
|
|
|
198
197
|
define<T extends {
|
|
199
198
|
[key: string]: any;
|
|
200
199
|
} = RouterContextT>(path: string, key: string, fn: Run<T & U>): this;
|
|
201
|
-
update(opts: DefineRouteOpts,
|
|
200
|
+
update(opts: DefineRouteOpts, onlyUpdateList?: string[]): this;
|
|
202
201
|
addTo(router: QueryRouter | {
|
|
203
202
|
add: (route: Route) => void;
|
|
204
203
|
[key: string]: any;
|
|
@@ -238,7 +237,7 @@ declare class QueryRouter {
|
|
|
238
237
|
* remove route by id
|
|
239
238
|
* @param uniqueId
|
|
240
239
|
*/
|
|
241
|
-
removeById(
|
|
240
|
+
removeById(uniqueId: string): void;
|
|
242
241
|
/**
|
|
243
242
|
* 执行route
|
|
244
243
|
* @param path
|
|
@@ -356,7 +355,11 @@ declare class QueryRouter {
|
|
|
356
355
|
}): Route<{
|
|
357
356
|
[key: string]: any;
|
|
358
357
|
}, SimpleObject$1>;
|
|
359
|
-
createRouteList(
|
|
358
|
+
createRouteList(opts?: {
|
|
359
|
+
force?: boolean;
|
|
360
|
+
filter?: (route: Route) => boolean;
|
|
361
|
+
middleware?: string[];
|
|
362
|
+
}): void;
|
|
360
363
|
/**
|
|
361
364
|
* 等待程序运行, 获取到message的数据,就执行
|
|
362
365
|
* params 是预设参数
|
|
@@ -373,6 +376,7 @@ declare class QueryRouter {
|
|
|
373
376
|
getList?: boolean;
|
|
374
377
|
force?: boolean;
|
|
375
378
|
filter?: (route: Route) => boolean;
|
|
379
|
+
routeListMiddleware?: string[];
|
|
376
380
|
}): Promise<void>;
|
|
377
381
|
toJSONSchema: (route: RouteInfo) => Pick<RouteInfo, "path" | "key" | "id" | "description" | "type" | "middleware" | "metadata">;
|
|
378
382
|
fromJSONSchema: (route: RouteInfo) => RouteInfo;
|
|
@@ -495,20 +499,20 @@ declare class CustomError extends Error {
|
|
|
495
499
|
}
|
|
496
500
|
|
|
497
501
|
type RouteObject = {
|
|
498
|
-
[key: string]: RouteOpts
|
|
502
|
+
[key: string]: RouteOpts;
|
|
499
503
|
};
|
|
500
504
|
type SimpleObject = Record<string, any>;
|
|
501
|
-
declare function define<T extends Record<string, RouteOpts
|
|
502
|
-
[K in keyof T]: T[K] & RouteOpts
|
|
505
|
+
declare function define<T extends Record<string, RouteOpts>>(value: T): {
|
|
506
|
+
[K in keyof T]: T[K] & RouteOpts;
|
|
503
507
|
};
|
|
504
|
-
type RouteArray = RouteOpts
|
|
508
|
+
type RouteArray = RouteOpts[];
|
|
505
509
|
type ChainOptions = {
|
|
506
|
-
app: QueryRouterServer
|
|
510
|
+
app: QueryRouterServer;
|
|
507
511
|
};
|
|
508
512
|
declare class Chain {
|
|
509
|
-
object: RouteOpts
|
|
510
|
-
app?: QueryRouterServer
|
|
511
|
-
constructor(object: RouteOpts
|
|
513
|
+
object: RouteOpts;
|
|
514
|
+
app?: QueryRouterServer;
|
|
515
|
+
constructor(object: RouteOpts, opts?: ChainOptions);
|
|
512
516
|
get key(): string;
|
|
513
517
|
get path(): string;
|
|
514
518
|
setDescription(desc: string): this;
|
|
@@ -516,11 +520,11 @@ declare class Chain {
|
|
|
516
520
|
[key: string]: any;
|
|
517
521
|
}): this;
|
|
518
522
|
setPath(path: string): this;
|
|
519
|
-
setMiddleware(middleware: RouteMiddleware
|
|
523
|
+
setMiddleware(middleware: RouteMiddleware[]): this;
|
|
520
524
|
setKey(key: string): this;
|
|
521
525
|
setId(key: string): this;
|
|
522
|
-
setRun<U extends SimpleObject = {}>(run: Run
|
|
523
|
-
define<U extends SimpleObject = {}>(run: Run
|
|
526
|
+
setRun<U extends SimpleObject = {}>(run: Run<U>): this;
|
|
527
|
+
define<U extends SimpleObject = {}>(run: Run<U>): this;
|
|
524
528
|
createRoute(): this;
|
|
525
529
|
}
|
|
526
530
|
type QueryChainOptions = {
|
|
@@ -540,21 +544,21 @@ declare class QueryChain {
|
|
|
540
544
|
* @param queryData
|
|
541
545
|
* @returns
|
|
542
546
|
*/
|
|
543
|
-
getKey(queryData?: SimpleObject): Pick<RouteOpts
|
|
547
|
+
getKey(queryData?: SimpleObject): Pick<RouteOpts, 'path' | 'key' | 'metadata' | 'description'>;
|
|
544
548
|
post<R = SimpleObject, P = SimpleObject>(data: P, options?: DataOpts): Promise<Result<R>>;
|
|
545
549
|
get<R = SimpleObject, P = SimpleObject>(data: P, options?: DataOpts): Promise<Result<R>>;
|
|
546
550
|
}
|
|
547
551
|
declare const util: {
|
|
548
|
-
getChain: (obj: RouteOpts
|
|
552
|
+
getChain: (obj: RouteOpts, opts?: ChainOptions) => Chain;
|
|
549
553
|
};
|
|
550
554
|
declare class QueryUtil<T extends RouteObject = RouteObject> {
|
|
551
555
|
obj: T;
|
|
552
|
-
app: QueryRouterServer
|
|
556
|
+
app: QueryRouterServer;
|
|
553
557
|
query: Query;
|
|
554
558
|
constructor(object: T, opts?: ChainOptions & QueryChainOptions);
|
|
555
559
|
static createFormObj<U extends RouteObject>(object: U, opts?: ChainOptions): QueryUtil<U>;
|
|
556
|
-
static create<U extends Record<string, RouteOpts
|
|
557
|
-
get<K extends keyof T>(key: K): RouteOpts
|
|
560
|
+
static create<U extends Record<string, RouteOpts>>(value: U, opts?: ChainOptions): QueryUtil<U>;
|
|
561
|
+
get<K extends keyof T>(key: K): RouteOpts;
|
|
558
562
|
chain<K extends keyof T>(key: K, opts?: ChainOptions): Chain;
|
|
559
563
|
queryChain<K extends keyof T>(key: K, opts?: QueryChainOptions): QueryChain;
|
|
560
564
|
static Chain: typeof Chain;
|
|
@@ -565,4 +569,4 @@ declare class QueryUtil<T extends RouteObject = RouteObject> {
|
|
|
565
569
|
declare const App: typeof QueryRouterServer;
|
|
566
570
|
|
|
567
571
|
export { App, CustomError, Mini, MockProcess, QueryRouter, QueryRouterServer, QueryUtil, Route, createSchema, createSkill, define, fromJSONSchema, toJSONSchema, tool, util };
|
|
568
|
-
export type { ListenProcessParams, ListenProcessResponse, RouteArray, RouteContext, RouteMiddleware, RouteObject, RouteOpts, Rule, Run, Schema, Skill };
|
|
572
|
+
export type { ListenProcessParams, ListenProcessResponse, RouteArray, RouteContext, RouteInfo, RouteMiddleware, RouteObject, RouteOpts, Rule, Run, Schema, Skill };
|