@kevisual/router 0.0.52 → 0.0.54
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/router-browser.d.ts +25 -14
- package/dist/router-browser.js +330 -166
- package/dist/router.d.ts +167 -166
- package/dist/router.js +10680 -10369
- package/package.json +18 -20
- package/src/app.ts +9 -0
- package/src/auto/index.ts +19 -0
- package/src/browser.ts +3 -3
- package/src/index.ts +13 -13
- package/src/modules/chat.ts +57 -0
- package/src/{connect.ts → modules/connect.ts} +1 -1
- package/src/route.ts +46 -0
- package/src/test/chat.ts +1 -1
- package/auto.ts +0 -19
- package/dist/router-sign.d.ts +0 -16
- package/dist/router-sign.js +0 -14052
- package/src/chat.ts +0 -40
- package/src/io.ts +0 -6
- package/src/router-simple-lib.ts +0 -3
- package/src/sign.ts +0 -59
- package/src/static.ts +0 -97
package/dist/router-browser.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import * as node_querystring from 'node:querystring';
|
|
3
|
-
import { IncomingMessage } from 'node:http';
|
|
4
2
|
import { RouteOpts as RouteOpts$1, QueryRouterServer as QueryRouterServer$1, RouteMiddleware as RouteMiddleware$1, Run as Run$1 } from '@kevisual/router';
|
|
5
3
|
import { Query, DataOpts, Result } from '@kevisual/query/query';
|
|
6
4
|
|
|
@@ -11,6 +9,11 @@ type RouterContextT = {
|
|
|
11
9
|
type RouteContext<T = {
|
|
12
10
|
code?: number;
|
|
13
11
|
}, S = any> = {
|
|
12
|
+
/**
|
|
13
|
+
* 本地自己调用的时候使用,可以标识为当前自调用,那么 auth 就不许重复的校验
|
|
14
|
+
* 或者不需要登录的,直接调用
|
|
15
|
+
*/
|
|
16
|
+
appId?: string;
|
|
14
17
|
query?: {
|
|
15
18
|
[key: string]: any;
|
|
16
19
|
};
|
|
@@ -104,6 +107,14 @@ type RouteOpts<U = {}, T = SimpleObject$1> = {
|
|
|
104
107
|
};
|
|
105
108
|
type DefineRouteOpts = Omit<RouteOpts, 'idUsePath' | 'nextRoute'>;
|
|
106
109
|
declare const pickValue: readonly ["path", "key", "id", "description", "type", "middleware", "metadata"];
|
|
110
|
+
type Skill<T = SimpleObject$1> = {
|
|
111
|
+
skill: string;
|
|
112
|
+
title: string;
|
|
113
|
+
summary?: string;
|
|
114
|
+
args?: z.ZodTypeAny;
|
|
115
|
+
} & T;
|
|
116
|
+
/** */
|
|
117
|
+
declare const createSkill: <T = SimpleObject$1>(skill: Skill<T>) => Skill<T>;
|
|
107
118
|
type RouteInfo = Pick<Route, (typeof pickValue)[number]>;
|
|
108
119
|
declare class Route<U = {
|
|
109
120
|
[key: string]: any;
|
|
@@ -152,6 +163,7 @@ declare class Route<U = {
|
|
|
152
163
|
throw(code?: number | string, message?: string, tips?: string): void;
|
|
153
164
|
}
|
|
154
165
|
declare class QueryRouter {
|
|
166
|
+
appId: string;
|
|
155
167
|
routes: Route[];
|
|
156
168
|
maxNextRoute: number;
|
|
157
169
|
context?: RouteContext;
|
|
@@ -280,6 +292,13 @@ declare class QueryRouter {
|
|
|
280
292
|
hasRoute(path: string, key?: string): Route<{
|
|
281
293
|
[key: string]: any;
|
|
282
294
|
}, SimpleObject$1>;
|
|
295
|
+
findRoute(opts?: {
|
|
296
|
+
path?: string;
|
|
297
|
+
key?: string;
|
|
298
|
+
id?: string;
|
|
299
|
+
}): Route<{
|
|
300
|
+
[key: string]: any;
|
|
301
|
+
}, SimpleObject$1>;
|
|
283
302
|
createRouteList(force?: boolean, filter?: (route: Route) => boolean): void;
|
|
284
303
|
/**
|
|
285
304
|
* 等待程序运行, 获取到message的数据,就执行
|
|
@@ -304,6 +323,7 @@ declare class QueryRouter {
|
|
|
304
323
|
type QueryRouterServerOpts = {
|
|
305
324
|
handleFn?: HandleFn;
|
|
306
325
|
context?: RouteContext;
|
|
326
|
+
appId?: string;
|
|
307
327
|
};
|
|
308
328
|
interface HandleFn<T = any> {
|
|
309
329
|
(msg: {
|
|
@@ -322,6 +342,7 @@ interface HandleFn<T = any> {
|
|
|
322
342
|
* @description 移除server相关的功能,只保留router相关的功能,和http.createServer不相关,独立
|
|
323
343
|
*/
|
|
324
344
|
declare class QueryRouterServer extends QueryRouter {
|
|
345
|
+
appId: string;
|
|
325
346
|
handle: any;
|
|
326
347
|
constructor(opts?: QueryRouterServerOpts);
|
|
327
348
|
setHandle(wrapperFn?: HandleFn, ctx?: RouteContext): void;
|
|
@@ -417,16 +438,6 @@ declare class CustomError extends Error {
|
|
|
417
438
|
};
|
|
418
439
|
}
|
|
419
440
|
|
|
420
|
-
declare const parseBody: <T = Record<string, any>>(req: IncomingMessage) => Promise<T>;
|
|
421
|
-
declare const parseSearch: (req: IncomingMessage) => node_querystring.ParsedUrlQuery;
|
|
422
|
-
/**
|
|
423
|
-
* 把url当个key 的 value 的字符串转成json
|
|
424
|
-
* @param value
|
|
425
|
-
*/
|
|
426
|
-
declare const parseSearchValue: (value?: string, opts?: {
|
|
427
|
-
decode?: boolean;
|
|
428
|
-
}) => any;
|
|
429
|
-
|
|
430
441
|
type RouteObject = {
|
|
431
442
|
[key: string]: RouteOpts$1;
|
|
432
443
|
};
|
|
@@ -497,5 +508,5 @@ declare class QueryUtil<T extends RouteObject = RouteObject> {
|
|
|
497
508
|
|
|
498
509
|
declare const App: typeof QueryRouterServer;
|
|
499
510
|
|
|
500
|
-
export { App, CustomError, Mini, QueryRouter, QueryRouterServer, QueryUtil, Route, createSchema,
|
|
501
|
-
export type { RouteArray, RouteContext, RouteObject, RouteOpts, Rule, Run, Schema };
|
|
511
|
+
export { App, CustomError, Mini, QueryRouter, QueryRouterServer, QueryUtil, Route, createSchema, createSkill, define, util };
|
|
512
|
+
export type { RouteArray, RouteContext, RouteObject, RouteOpts, Rule, Run, Schema, Skill };
|