@kevisual/router 0.0.70 → 0.0.72
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 +19504 -0
- package/dist/opencode.d.ts +5 -2
- package/dist/opencode.js +13381 -14322
- package/dist/router-browser.d.ts +22 -20
- package/dist/router-browser.js +14044 -15137
- package/dist/router-define.d.ts +394 -3
- package/dist/router-define.js +126 -124
- package/dist/router-simple.js +665 -759
- package/dist/router.d.ts +22 -20
- package/dist/router.js +17810 -21180
- package/dist/ws.d.ts +5 -2
- 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 +21 -17
- package/src/router-define.ts +1 -1
- package/src/utils/random.ts +8 -0
package/dist/router.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
|
import * as http from 'node:http';
|
|
6
5
|
import http__default, { IncomingMessage, ServerResponse } from 'node:http';
|
|
@@ -53,6 +52,9 @@ type RouteContext<T = {
|
|
|
53
52
|
query?: {
|
|
54
53
|
[key: string]: any;
|
|
55
54
|
};
|
|
55
|
+
args?: {
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
};
|
|
56
58
|
/** return body */
|
|
57
59
|
body?: number | string | Object;
|
|
58
60
|
forward?: (response: {
|
|
@@ -201,7 +203,7 @@ declare class Route<U = {
|
|
|
201
203
|
define<T extends {
|
|
202
204
|
[key: string]: any;
|
|
203
205
|
} = RouterContextT>(path: string, key: string, fn: Run<T & U>): this;
|
|
204
|
-
update(opts: DefineRouteOpts,
|
|
206
|
+
update(opts: DefineRouteOpts, onlyUpdateList?: string[]): this;
|
|
205
207
|
addTo(router: QueryRouter | {
|
|
206
208
|
add: (route: Route) => void;
|
|
207
209
|
[key: string]: any;
|
|
@@ -241,7 +243,7 @@ declare class QueryRouter {
|
|
|
241
243
|
* remove route by id
|
|
242
244
|
* @param uniqueId
|
|
243
245
|
*/
|
|
244
|
-
removeById(
|
|
246
|
+
removeById(uniqueId: string): void;
|
|
245
247
|
/**
|
|
246
248
|
* 执行route
|
|
247
249
|
* @param path
|
|
@@ -498,20 +500,20 @@ declare class CustomError extends Error {
|
|
|
498
500
|
}
|
|
499
501
|
|
|
500
502
|
type RouteObject = {
|
|
501
|
-
[key: string]: RouteOpts
|
|
503
|
+
[key: string]: RouteOpts;
|
|
502
504
|
};
|
|
503
505
|
type SimpleObject = Record<string, any>;
|
|
504
|
-
declare function define<T extends Record<string, RouteOpts
|
|
505
|
-
[K in keyof T]: T[K] & RouteOpts
|
|
506
|
+
declare function define<T extends Record<string, RouteOpts>>(value: T): {
|
|
507
|
+
[K in keyof T]: T[K] & RouteOpts;
|
|
506
508
|
};
|
|
507
|
-
type RouteArray = RouteOpts
|
|
509
|
+
type RouteArray = RouteOpts[];
|
|
508
510
|
type ChainOptions = {
|
|
509
|
-
app: QueryRouterServer
|
|
511
|
+
app: QueryRouterServer;
|
|
510
512
|
};
|
|
511
513
|
declare class Chain {
|
|
512
|
-
object: RouteOpts
|
|
513
|
-
app?: QueryRouterServer
|
|
514
|
-
constructor(object: RouteOpts
|
|
514
|
+
object: RouteOpts;
|
|
515
|
+
app?: QueryRouterServer;
|
|
516
|
+
constructor(object: RouteOpts, opts?: ChainOptions);
|
|
515
517
|
get key(): string;
|
|
516
518
|
get path(): string;
|
|
517
519
|
setDescription(desc: string): this;
|
|
@@ -519,11 +521,11 @@ declare class Chain {
|
|
|
519
521
|
[key: string]: any;
|
|
520
522
|
}): this;
|
|
521
523
|
setPath(path: string): this;
|
|
522
|
-
setMiddleware(middleware: RouteMiddleware
|
|
524
|
+
setMiddleware(middleware: RouteMiddleware[]): this;
|
|
523
525
|
setKey(key: string): this;
|
|
524
526
|
setId(key: string): this;
|
|
525
|
-
setRun<U extends SimpleObject = {}>(run: Run
|
|
526
|
-
define<U extends SimpleObject = {}>(run: Run
|
|
527
|
+
setRun<U extends SimpleObject = {}>(run: Run<U>): this;
|
|
528
|
+
define<U extends SimpleObject = {}>(run: Run<U>): this;
|
|
527
529
|
createRoute(): this;
|
|
528
530
|
}
|
|
529
531
|
type QueryChainOptions = {
|
|
@@ -543,21 +545,21 @@ declare class QueryChain {
|
|
|
543
545
|
* @param queryData
|
|
544
546
|
* @returns
|
|
545
547
|
*/
|
|
546
|
-
getKey(queryData?: SimpleObject): Pick<RouteOpts
|
|
548
|
+
getKey(queryData?: SimpleObject): Pick<RouteOpts, 'path' | 'key' | 'metadata' | 'description'>;
|
|
547
549
|
post<R = SimpleObject, P = SimpleObject>(data: P, options?: DataOpts): Promise<Result<R>>;
|
|
548
550
|
get<R = SimpleObject, P = SimpleObject>(data: P, options?: DataOpts): Promise<Result<R>>;
|
|
549
551
|
}
|
|
550
552
|
declare const util: {
|
|
551
|
-
getChain: (obj: RouteOpts
|
|
553
|
+
getChain: (obj: RouteOpts, opts?: ChainOptions) => Chain;
|
|
552
554
|
};
|
|
553
555
|
declare class QueryUtil<T extends RouteObject = RouteObject> {
|
|
554
556
|
obj: T;
|
|
555
|
-
app: QueryRouterServer
|
|
557
|
+
app: QueryRouterServer;
|
|
556
558
|
query: Query;
|
|
557
559
|
constructor(object: T, opts?: ChainOptions & QueryChainOptions);
|
|
558
560
|
static createFormObj<U extends RouteObject>(object: U, opts?: ChainOptions): QueryUtil<U>;
|
|
559
|
-
static create<U extends Record<string, RouteOpts
|
|
560
|
-
get<K extends keyof T>(key: K): RouteOpts
|
|
561
|
+
static create<U extends Record<string, RouteOpts>>(value: U, opts?: ChainOptions): QueryUtil<U>;
|
|
562
|
+
get<K extends keyof T>(key: K): RouteOpts;
|
|
561
563
|
chain<K extends keyof T>(key: K, opts?: ChainOptions): Chain;
|
|
562
564
|
queryChain<K extends keyof T>(key: K, opts?: QueryChainOptions): QueryChain;
|
|
563
565
|
static Chain: typeof Chain;
|
|
@@ -975,4 +977,4 @@ declare class App<U = {}> extends QueryRouter {
|
|
|
975
977
|
}
|
|
976
978
|
|
|
977
979
|
export { App, CustomError, Mini, MockProcess, QueryRouter, QueryRouterServer, QueryUtil, Route, ServerNode, createSchema, createSkill, define, fromJSONSchema, handleServer, toJSONSchema, tool, util };
|
|
978
|
-
export type { HttpListenerFun, ListenProcessParams, ListenProcessResponse, Listener, OnListener, OnWebSocketFn, RouteArray, RouteContext, RouteMiddleware, RouteObject, RouteOpts, RouterReq, RouterRes, Rule, Run, Schema, Skill, WS, WebSocketListenerFun, WebSocketReq, WebSocketRes };
|
|
980
|
+
export type { HttpListenerFun, ListenProcessParams, ListenProcessResponse, Listener, OnListener, OnWebSocketFn, RouteArray, RouteContext, RouteInfo, RouteMiddleware, RouteObject, RouteOpts, RouterReq, RouterRes, Rule, Run, Schema, Skill, WS, WebSocketListenerFun, WebSocketReq, WebSocketRes };
|