@kevisual/router 0.0.71 → 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 +2 -2
- package/dist/opencode.js +13380 -14323
- package/dist/router-browser.d.ts +19 -20
- package/dist/router-browser.js +14046 -15099
- 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 +19 -20
- package/dist/router.js +17822 -21151
- package/dist/ws.d.ts +2 -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 +10 -10
- 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';
|
|
@@ -204,7 +203,7 @@ declare class Route<U = {
|
|
|
204
203
|
define<T extends {
|
|
205
204
|
[key: string]: any;
|
|
206
205
|
} = RouterContextT>(path: string, key: string, fn: Run<T & U>): this;
|
|
207
|
-
update(opts: DefineRouteOpts,
|
|
206
|
+
update(opts: DefineRouteOpts, onlyUpdateList?: string[]): this;
|
|
208
207
|
addTo(router: QueryRouter | {
|
|
209
208
|
add: (route: Route) => void;
|
|
210
209
|
[key: string]: any;
|
|
@@ -244,7 +243,7 @@ declare class QueryRouter {
|
|
|
244
243
|
* remove route by id
|
|
245
244
|
* @param uniqueId
|
|
246
245
|
*/
|
|
247
|
-
removeById(
|
|
246
|
+
removeById(uniqueId: string): void;
|
|
248
247
|
/**
|
|
249
248
|
* 执行route
|
|
250
249
|
* @param path
|
|
@@ -501,20 +500,20 @@ declare class CustomError extends Error {
|
|
|
501
500
|
}
|
|
502
501
|
|
|
503
502
|
type RouteObject = {
|
|
504
|
-
[key: string]: RouteOpts
|
|
503
|
+
[key: string]: RouteOpts;
|
|
505
504
|
};
|
|
506
505
|
type SimpleObject = Record<string, any>;
|
|
507
|
-
declare function define<T extends Record<string, RouteOpts
|
|
508
|
-
[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;
|
|
509
508
|
};
|
|
510
|
-
type RouteArray = RouteOpts
|
|
509
|
+
type RouteArray = RouteOpts[];
|
|
511
510
|
type ChainOptions = {
|
|
512
|
-
app: QueryRouterServer
|
|
511
|
+
app: QueryRouterServer;
|
|
513
512
|
};
|
|
514
513
|
declare class Chain {
|
|
515
|
-
object: RouteOpts
|
|
516
|
-
app?: QueryRouterServer
|
|
517
|
-
constructor(object: RouteOpts
|
|
514
|
+
object: RouteOpts;
|
|
515
|
+
app?: QueryRouterServer;
|
|
516
|
+
constructor(object: RouteOpts, opts?: ChainOptions);
|
|
518
517
|
get key(): string;
|
|
519
518
|
get path(): string;
|
|
520
519
|
setDescription(desc: string): this;
|
|
@@ -522,11 +521,11 @@ declare class Chain {
|
|
|
522
521
|
[key: string]: any;
|
|
523
522
|
}): this;
|
|
524
523
|
setPath(path: string): this;
|
|
525
|
-
setMiddleware(middleware: RouteMiddleware
|
|
524
|
+
setMiddleware(middleware: RouteMiddleware[]): this;
|
|
526
525
|
setKey(key: string): this;
|
|
527
526
|
setId(key: string): this;
|
|
528
|
-
setRun<U extends SimpleObject = {}>(run: Run
|
|
529
|
-
define<U extends SimpleObject = {}>(run: Run
|
|
527
|
+
setRun<U extends SimpleObject = {}>(run: Run<U>): this;
|
|
528
|
+
define<U extends SimpleObject = {}>(run: Run<U>): this;
|
|
530
529
|
createRoute(): this;
|
|
531
530
|
}
|
|
532
531
|
type QueryChainOptions = {
|
|
@@ -546,21 +545,21 @@ declare class QueryChain {
|
|
|
546
545
|
* @param queryData
|
|
547
546
|
* @returns
|
|
548
547
|
*/
|
|
549
|
-
getKey(queryData?: SimpleObject): Pick<RouteOpts
|
|
548
|
+
getKey(queryData?: SimpleObject): Pick<RouteOpts, 'path' | 'key' | 'metadata' | 'description'>;
|
|
550
549
|
post<R = SimpleObject, P = SimpleObject>(data: P, options?: DataOpts): Promise<Result<R>>;
|
|
551
550
|
get<R = SimpleObject, P = SimpleObject>(data: P, options?: DataOpts): Promise<Result<R>>;
|
|
552
551
|
}
|
|
553
552
|
declare const util: {
|
|
554
|
-
getChain: (obj: RouteOpts
|
|
553
|
+
getChain: (obj: RouteOpts, opts?: ChainOptions) => Chain;
|
|
555
554
|
};
|
|
556
555
|
declare class QueryUtil<T extends RouteObject = RouteObject> {
|
|
557
556
|
obj: T;
|
|
558
|
-
app: QueryRouterServer
|
|
557
|
+
app: QueryRouterServer;
|
|
559
558
|
query: Query;
|
|
560
559
|
constructor(object: T, opts?: ChainOptions & QueryChainOptions);
|
|
561
560
|
static createFormObj<U extends RouteObject>(object: U, opts?: ChainOptions): QueryUtil<U>;
|
|
562
|
-
static create<U extends Record<string, RouteOpts
|
|
563
|
-
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;
|
|
564
563
|
chain<K extends keyof T>(key: K, opts?: ChainOptions): Chain;
|
|
565
564
|
queryChain<K extends keyof T>(key: K, opts?: QueryChainOptions): QueryChain;
|
|
566
565
|
static Chain: typeof Chain;
|
|
@@ -978,4 +977,4 @@ declare class App<U = {}> extends QueryRouter {
|
|
|
978
977
|
}
|
|
979
978
|
|
|
980
979
|
export { App, CustomError, Mini, MockProcess, QueryRouter, QueryRouterServer, QueryUtil, Route, ServerNode, createSchema, createSkill, define, fromJSONSchema, handleServer, toJSONSchema, tool, util };
|
|
981
|
-
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 };
|