@kevisual/router 0.1.7 → 0.2.2

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.
@@ -32651,7 +32651,7 @@ var fromJSONSchema2 = (args = {}, opts) => {
32651
32651
  };
32652
32652
 
32653
32653
  // src/route.ts
32654
- var pickValue = ["path", "key", "id", "description", "type", "middleware", "metadata"];
32654
+ var pickValue = ["path", "key", "rid", "description", "type", "middleware", "metadata"];
32655
32655
  var tool = {
32656
32656
  schema: exports_external
32657
32657
  };
@@ -32671,7 +32671,7 @@ var createSkill = (skill) => {
32671
32671
  class Route {
32672
32672
  path;
32673
32673
  key;
32674
- id;
32674
+ rid;
32675
32675
  run;
32676
32676
  nextRoute;
32677
32677
  description;
@@ -32689,7 +32689,7 @@ class Route {
32689
32689
  this.key = key;
32690
32690
  const pathKey = `${path}$$${key}`;
32691
32691
  if (opts) {
32692
- this.id = opts.id || hashIdMd5Sync(pathKey);
32692
+ this.rid = opts.rid || hashIdMd5Sync(pathKey);
32693
32693
  this.run = opts.run;
32694
32694
  this.nextRoute = opts.nextRoute;
32695
32695
  this.description = opts.description;
@@ -32701,8 +32701,8 @@ class Route {
32701
32701
  } else {
32702
32702
  this.middleware = [];
32703
32703
  }
32704
- if (!this.id) {
32705
- this.id = hashIdMd5Sync(pathKey);
32704
+ if (!this.rid) {
32705
+ this.rid = hashIdMd5Sync(pathKey);
32706
32706
  }
32707
32707
  this.isDebug = opts?.isDebug ?? false;
32708
32708
  }
@@ -32808,14 +32808,14 @@ class QueryRouter {
32808
32808
  this.routes = this.routes.filter((r) => r.path === route.path && r.key == route.key);
32809
32809
  }
32810
32810
  removeById(uniqueId) {
32811
- this.routes = this.routes.filter((r) => r.id !== uniqueId);
32811
+ this.routes = this.routes.filter((r) => r.rid !== uniqueId);
32812
32812
  }
32813
32813
  async runRoute(path, key, ctx) {
32814
32814
  const route = this.routes.find((r) => r.path === path && r.key === key);
32815
32815
  const maxNextRoute = this.maxNextRoute;
32816
32816
  ctx = ctx || {};
32817
32817
  ctx.currentPath = path;
32818
- ctx.currentId = route?.id;
32818
+ ctx.currentId = route?.rid;
32819
32819
  ctx.currentKey = key;
32820
32820
  ctx.currentRoute = route;
32821
32821
  ctx.index = (ctx.index || 0) + 1;
@@ -32842,11 +32842,11 @@ class QueryRouter {
32842
32842
  let route2;
32843
32843
  const isString3 = typeof item === "string";
32844
32844
  if (isString3) {
32845
- route2 = this.routes.find((r) => r.id === item);
32845
+ route2 = this.routes.find((r) => r.rid === item);
32846
32846
  } else {
32847
32847
  route2 = this.routes.find((r) => {
32848
- if (item.id) {
32849
- return r.id === item.id;
32848
+ if (item.rid) {
32849
+ return r.rid === item.rid;
32850
32850
  } else {
32851
32851
  return r.path === item.path && r.key == item.key;
32852
32852
  }
@@ -32895,8 +32895,8 @@ class QueryRouter {
32895
32895
  ctx.message = e.message;
32896
32896
  ctx.body = null;
32897
32897
  } else {
32898
- console.error(`[router error] fn:${route.path}-${route.key}:${route.id}`);
32899
- console.error(`[router error] middleware:${middleware.path}-${middleware.key}:${middleware.id}`);
32898
+ console.error(`[router error] fn:${route.path}-${route.key}:${route.rid}`);
32899
+ console.error(`[router error] middleware:${middleware.path}-${middleware.key}:${middleware.rid}`);
32900
32900
  console.error(e);
32901
32901
  ctx.code = 500;
32902
32902
  ctx.message = "Internal Server Error";
@@ -32924,7 +32924,7 @@ class QueryRouter {
32924
32924
  ctx.code = e.code;
32925
32925
  ctx.message = e.message;
32926
32926
  } else {
32927
- console.error(`[router error] fn:${route.path}-${route.key}:${route.id}`);
32927
+ console.error(`[router error] fn:${route.path}-${route.key}:${route.rid}`);
32928
32928
  console.error(`[router error] error`, e);
32929
32929
  ctx.code = 500;
32930
32930
  ctx.message = "Internal Server Error";
@@ -32940,8 +32940,8 @@ class QueryRouter {
32940
32940
  if (route.nextRoute.path || route.nextRoute.key) {
32941
32941
  path2 = route.nextRoute.path;
32942
32942
  key2 = route.nextRoute.key;
32943
- } else if (route.nextRoute.id) {
32944
- const nextRoute = this.routes.find((r) => r.id === route.nextRoute.id);
32943
+ } else if (route.nextRoute.rid) {
32944
+ const nextRoute = this.routes.find((r) => r.rid === route.nextRoute.rid);
32945
32945
  if (nextRoute) {
32946
32946
  path2 = nextRoute.path;
32947
32947
  key2 = nextRoute.key;
@@ -33005,8 +33005,8 @@ class QueryRouter {
33005
33005
  let key = message.key;
33006
33006
  if (path) {
33007
33007
  return await this.parse({ ...message, path, key }, { ...this.context, ...ctx });
33008
- } else if (message.id) {
33009
- const route = this.routes.find((r) => r.id === message.id);
33008
+ } else if (message.rid) {
33009
+ const route = this.routes.find((r) => r.rid === message.rid);
33010
33010
  if (route) {
33011
33011
  path = route.path;
33012
33012
  key = route.key;
@@ -33079,10 +33079,10 @@ class QueryRouter {
33079
33079
  return this.routes.find((r) => r.path === path && r.key === key);
33080
33080
  }
33081
33081
  findRoute(opts) {
33082
- const { path, key, id } = opts || {};
33082
+ const { path, key, rid } = opts || {};
33083
33083
  return this.routes.find((r) => {
33084
- if (id) {
33085
- return r.id === id;
33084
+ if (rid) {
33085
+ return r.rid === rid;
33086
33086
  }
33087
33087
  if (path) {
33088
33088
  if (key !== undefined) {
@@ -33103,14 +33103,14 @@ class QueryRouter {
33103
33103
  const tokenUser = ctx.state;
33104
33104
  let isUser = !!tokenUser;
33105
33105
  const list = this.getList(opts?.filter).filter((item) => {
33106
- if (item.id === "auth" || item.id === "auth-can" || item.id === "check-auth-admin" || item.id === "auth-admin") {
33106
+ if (item.rid === "auth" || item.rid === "auth-can" || item.rid === "check-auth-admin" || item.rid === "auth-admin") {
33107
33107
  return false;
33108
33108
  }
33109
33109
  return true;
33110
33110
  });
33111
33111
  ctx.body = {
33112
33112
  list: list.map((item) => {
33113
- const route = pick(item, ["id", "path", "key", "description", "middleware", "metadata"]);
33113
+ const route = pick(item, ["rid", "path", "key", "description", "middleware", "metadata"]);
33114
33114
  return toJSONSchemaRoute(route);
33115
33115
  }),
33116
33116
  isUser
@@ -33180,14 +33180,14 @@ class QueryRouterServer extends QueryRouter {
33180
33180
  return super.run(msg, ctx);
33181
33181
  }
33182
33182
  async runAction(api2, payload, ctx) {
33183
- const { path, key, id } = api2;
33184
- return this.run({ path, key, id, payload }, ctx);
33183
+ const { path, key, rid } = api2;
33184
+ return this.run({ path, key, rid, payload }, ctx);
33185
33185
  }
33186
33186
  async createAuth(fun) {
33187
33187
  this.route({
33188
33188
  path: "auth",
33189
33189
  key: "auth",
33190
- id: "auth",
33190
+ rid: "auth",
33191
33191
  description: "token验证"
33192
33192
  }).define(async (ctx) => {
33193
33193
  if (fun) {
@@ -33197,7 +33197,7 @@ class QueryRouterServer extends QueryRouter {
33197
33197
  this.route({
33198
33198
  path: "auth-admin",
33199
33199
  key: "auth-admin",
33200
- id: "auth-admin",
33200
+ rid: "auth-admin",
33201
33201
  description: "admin token验证",
33202
33202
  middleware: ["auth"]
33203
33203
  }).define(async (ctx) => {
@@ -33208,7 +33208,7 @@ class QueryRouterServer extends QueryRouter {
33208
33208
  this.route({
33209
33209
  path: "auth-can",
33210
33210
  key: "auth-can",
33211
- id: "auth-can",
33211
+ rid: "auth-can",
33212
33212
  description: "权限验证"
33213
33213
  }).define(async (ctx) => {
33214
33214
  if (fun) {
@@ -33303,8 +33303,8 @@ class Chain {
33303
33303
  this.object.key = key;
33304
33304
  return this;
33305
33305
  }
33306
- setId(key) {
33307
- this.object.id = key;
33306
+ setRid(key) {
33307
+ this.object.rid = key;
33308
33308
  return this;
33309
33309
  }
33310
33310
  setRun(run) {
@@ -128,16 +128,16 @@ type RunMessage = {
128
128
  id?: string;
129
129
  payload?: any;
130
130
  };
131
- type NextRoute = Pick<Route, 'id' | 'path' | 'key'>;
131
+ type NextRoute = Pick<Route, 'rid' | 'path' | 'key'>;
132
132
  type RouteMiddleware = {
133
133
  path?: string;
134
134
  key?: string;
135
- id?: string;
135
+ rid?: string;
136
136
  } | string;
137
137
  type RouteOpts<U = {}, T = SimpleObject$1> = {
138
138
  path?: string;
139
139
  key?: string;
140
- id?: string;
140
+ rid?: string;
141
141
  run?: Run<U>;
142
142
  nextRoute?: NextRoute;
143
143
  description?: string;
@@ -147,7 +147,7 @@ type RouteOpts<U = {}, T = SimpleObject$1> = {
147
147
  isDebug?: boolean;
148
148
  };
149
149
  type DefineRouteOpts = Omit<RouteOpts, 'idUsePath' | 'nextRoute'>;
150
- declare const pickValue: readonly ["path", "key", "id", "description", "type", "middleware", "metadata"];
150
+ declare const pickValue: readonly ["path", "key", "rid", "description", "type", "middleware", "metadata"];
151
151
  type RouteInfo = Pick<Route, (typeof pickValue)[number]>;
152
152
  /**
153
153
  * @M 是 route的 metadate的类型,默认是 SimpleObject
@@ -162,7 +162,7 @@ declare class Route<M extends SimpleObject$1 = SimpleObject$1, U extends SimpleO
162
162
  * 二级路径
163
163
  */
164
164
  key?: string;
165
- id?: string;
165
+ rid?: string;
166
166
  run?: Run<BuildRouteContext<M, U>>;
167
167
  nextRoute?: NextRoute;
168
168
  description?: string;
@@ -256,7 +256,7 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
256
256
  * @returns
257
257
  */
258
258
  call(message: {
259
- id?: string;
259
+ rid?: string;
260
260
  path?: string;
261
261
  key?: string;
262
262
  payload?: any;
@@ -343,7 +343,7 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
343
343
  findRoute(opts?: {
344
344
  path?: string;
345
345
  key?: string;
346
- id?: string;
346
+ rid?: string;
347
347
  }): Route<SimpleObject$1, SimpleObject$1>;
348
348
  createRouteList(opts?: {
349
349
  force?: boolean;
@@ -434,7 +434,7 @@ declare class QueryRouterServer<C extends SimpleObject$1 = SimpleObject$1> exten
434
434
  * @returns
435
435
  */
436
436
  run(msg: {
437
- id?: string;
437
+ rid?: string;
438
438
  path?: string;
439
439
  key?: string;
440
440
  payload?: any;
@@ -442,7 +442,7 @@ declare class QueryRouterServer<C extends SimpleObject$1 = SimpleObject$1> exten
442
442
  data?: any;
443
443
  }, ctx?: Partial<RouteContext<C>>): Promise<any>;
444
444
  runAction<T extends {
445
- id?: string;
445
+ rid?: string;
446
446
  path?: string;
447
447
  key?: string;
448
448
  metadata?: {
@@ -517,7 +517,7 @@ declare class Chain {
517
517
  setPath(path: string): this;
518
518
  setMiddleware(middleware: RouteMiddleware[]): this;
519
519
  setKey(key: string): this;
520
- setId(key: string): this;
520
+ setRid(key: string): this;
521
521
  setRun<U extends SimpleObject = {}>(run: Run<U>): this;
522
522
  define<U extends SimpleObject = {}>(run: Run<U>): this;
523
523
  createRoute(): this;
@@ -36,8 +36,8 @@ class Chain {
36
36
  this.object.key = key;
37
37
  return this;
38
38
  }
39
- setId(key) {
40
- this.object.id = key;
39
+ setRid(key) {
40
+ this.object.rid = key;
41
41
  return this;
42
42
  }
43
43
  setRun(run) {
package/dist/router.d.ts CHANGED
@@ -178,16 +178,16 @@ type RunMessage = {
178
178
  id?: string;
179
179
  payload?: any;
180
180
  };
181
- type NextRoute = Pick<Route, 'id' | 'path' | 'key'>;
181
+ type NextRoute = Pick<Route, 'rid' | 'path' | 'key'>;
182
182
  type RouteMiddleware = {
183
183
  path?: string;
184
184
  key?: string;
185
- id?: string;
185
+ rid?: string;
186
186
  } | string;
187
187
  type RouteOpts<U = {}, T = SimpleObject$1> = {
188
188
  path?: string;
189
189
  key?: string;
190
- id?: string;
190
+ rid?: string;
191
191
  run?: Run<U>;
192
192
  nextRoute?: NextRoute;
193
193
  description?: string;
@@ -197,7 +197,7 @@ type RouteOpts<U = {}, T = SimpleObject$1> = {
197
197
  isDebug?: boolean;
198
198
  };
199
199
  type DefineRouteOpts = Omit<RouteOpts, 'idUsePath' | 'nextRoute'>;
200
- declare const pickValue: readonly ["path", "key", "id", "description", "type", "middleware", "metadata"];
200
+ declare const pickValue: readonly ["path", "key", "rid", "description", "type", "middleware", "metadata"];
201
201
  type Skill<T = SimpleObject$1> = {
202
202
  skill: string;
203
203
  title: string;
@@ -226,7 +226,7 @@ declare class Route<M extends SimpleObject$1 = SimpleObject$1, U extends SimpleO
226
226
  * 二级路径
227
227
  */
228
228
  key?: string;
229
- id?: string;
229
+ rid?: string;
230
230
  run?: Run<BuildRouteContext<M, U>>;
231
231
  nextRoute?: NextRoute;
232
232
  description?: string;
@@ -337,7 +337,7 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
337
337
  * @returns
338
338
  */
339
339
  call(message: {
340
- id?: string;
340
+ rid?: string;
341
341
  path?: string;
342
342
  key?: string;
343
343
  payload?: any;
@@ -424,7 +424,7 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
424
424
  findRoute(opts?: {
425
425
  path?: string;
426
426
  key?: string;
427
- id?: string;
427
+ rid?: string;
428
428
  }): Route<SimpleObject$1, SimpleObject$1>;
429
429
  createRouteList(opts?: {
430
430
  force?: boolean;
@@ -515,7 +515,7 @@ declare class QueryRouterServer<C extends SimpleObject$1 = SimpleObject$1> exten
515
515
  * @returns
516
516
  */
517
517
  run(msg: {
518
- id?: string;
518
+ rid?: string;
519
519
  path?: string;
520
520
  key?: string;
521
521
  payload?: any;
@@ -523,7 +523,7 @@ declare class QueryRouterServer<C extends SimpleObject$1 = SimpleObject$1> exten
523
523
  data?: any;
524
524
  }, ctx?: Partial<RouteContext<C>>): Promise<any>;
525
525
  runAction<T extends {
526
- id?: string;
526
+ rid?: string;
527
527
  path?: string;
528
528
  key?: string;
529
529
  metadata?: {
@@ -637,7 +637,7 @@ declare class Chain {
637
637
  setPath(path: string): this;
638
638
  setMiddleware(middleware: RouteMiddleware[]): this;
639
639
  setKey(key: string): this;
640
- setId(key: string): this;
640
+ setRid(key: string): this;
641
641
  setRun<U extends SimpleObject = {}>(run: Run<U>): this;
642
642
  define<U extends SimpleObject = {}>(run: Run<U>): this;
643
643
  createRoute(): this;
package/dist/router.js CHANGED
@@ -17384,7 +17384,7 @@ var fromJSONSchema2 = (args = {}, opts) => {
17384
17384
  };
17385
17385
 
17386
17386
  // src/route.ts
17387
- var pickValue = ["path", "key", "id", "description", "type", "middleware", "metadata"];
17387
+ var pickValue = ["path", "key", "rid", "description", "type", "middleware", "metadata"];
17388
17388
  var tool = {
17389
17389
  schema: exports_external
17390
17390
  };
@@ -17404,7 +17404,7 @@ var createSkill = (skill) => {
17404
17404
  class Route {
17405
17405
  path;
17406
17406
  key;
17407
- id;
17407
+ rid;
17408
17408
  run;
17409
17409
  nextRoute;
17410
17410
  description;
@@ -17422,7 +17422,7 @@ class Route {
17422
17422
  this.key = key;
17423
17423
  const pathKey = `${path}$$${key}`;
17424
17424
  if (opts) {
17425
- this.id = opts.id || hashIdMd5Sync(pathKey);
17425
+ this.rid = opts.rid || hashIdMd5Sync(pathKey);
17426
17426
  this.run = opts.run;
17427
17427
  this.nextRoute = opts.nextRoute;
17428
17428
  this.description = opts.description;
@@ -17434,8 +17434,8 @@ class Route {
17434
17434
  } else {
17435
17435
  this.middleware = [];
17436
17436
  }
17437
- if (!this.id) {
17438
- this.id = hashIdMd5Sync(pathKey);
17437
+ if (!this.rid) {
17438
+ this.rid = hashIdMd5Sync(pathKey);
17439
17439
  }
17440
17440
  this.isDebug = opts?.isDebug ?? false;
17441
17441
  }
@@ -17541,14 +17541,14 @@ class QueryRouter {
17541
17541
  this.routes = this.routes.filter((r) => r.path === route.path && r.key == route.key);
17542
17542
  }
17543
17543
  removeById(uniqueId) {
17544
- this.routes = this.routes.filter((r) => r.id !== uniqueId);
17544
+ this.routes = this.routes.filter((r) => r.rid !== uniqueId);
17545
17545
  }
17546
17546
  async runRoute(path, key, ctx) {
17547
17547
  const route = this.routes.find((r) => r.path === path && r.key === key);
17548
17548
  const maxNextRoute = this.maxNextRoute;
17549
17549
  ctx = ctx || {};
17550
17550
  ctx.currentPath = path;
17551
- ctx.currentId = route?.id;
17551
+ ctx.currentId = route?.rid;
17552
17552
  ctx.currentKey = key;
17553
17553
  ctx.currentRoute = route;
17554
17554
  ctx.index = (ctx.index || 0) + 1;
@@ -17575,11 +17575,11 @@ class QueryRouter {
17575
17575
  let route2;
17576
17576
  const isString2 = typeof item === "string";
17577
17577
  if (isString2) {
17578
- route2 = this.routes.find((r) => r.id === item);
17578
+ route2 = this.routes.find((r) => r.rid === item);
17579
17579
  } else {
17580
17580
  route2 = this.routes.find((r) => {
17581
- if (item.id) {
17582
- return r.id === item.id;
17581
+ if (item.rid) {
17582
+ return r.rid === item.rid;
17583
17583
  } else {
17584
17584
  return r.path === item.path && r.key == item.key;
17585
17585
  }
@@ -17628,8 +17628,8 @@ class QueryRouter {
17628
17628
  ctx.message = e.message;
17629
17629
  ctx.body = null;
17630
17630
  } else {
17631
- console.error(`[router error] fn:${route.path}-${route.key}:${route.id}`);
17632
- console.error(`[router error] middleware:${middleware.path}-${middleware.key}:${middleware.id}`);
17631
+ console.error(`[router error] fn:${route.path}-${route.key}:${route.rid}`);
17632
+ console.error(`[router error] middleware:${middleware.path}-${middleware.key}:${middleware.rid}`);
17633
17633
  console.error(e);
17634
17634
  ctx.code = 500;
17635
17635
  ctx.message = "Internal Server Error";
@@ -17657,7 +17657,7 @@ class QueryRouter {
17657
17657
  ctx.code = e.code;
17658
17658
  ctx.message = e.message;
17659
17659
  } else {
17660
- console.error(`[router error] fn:${route.path}-${route.key}:${route.id}`);
17660
+ console.error(`[router error] fn:${route.path}-${route.key}:${route.rid}`);
17661
17661
  console.error(`[router error] error`, e);
17662
17662
  ctx.code = 500;
17663
17663
  ctx.message = "Internal Server Error";
@@ -17673,8 +17673,8 @@ class QueryRouter {
17673
17673
  if (route.nextRoute.path || route.nextRoute.key) {
17674
17674
  path2 = route.nextRoute.path;
17675
17675
  key2 = route.nextRoute.key;
17676
- } else if (route.nextRoute.id) {
17677
- const nextRoute = this.routes.find((r) => r.id === route.nextRoute.id);
17676
+ } else if (route.nextRoute.rid) {
17677
+ const nextRoute = this.routes.find((r) => r.rid === route.nextRoute.rid);
17678
17678
  if (nextRoute) {
17679
17679
  path2 = nextRoute.path;
17680
17680
  key2 = nextRoute.key;
@@ -17738,8 +17738,8 @@ class QueryRouter {
17738
17738
  let key = message.key;
17739
17739
  if (path) {
17740
17740
  return await this.parse({ ...message, path, key }, { ...this.context, ...ctx });
17741
- } else if (message.id) {
17742
- const route = this.routes.find((r) => r.id === message.id);
17741
+ } else if (message.rid) {
17742
+ const route = this.routes.find((r) => r.rid === message.rid);
17743
17743
  if (route) {
17744
17744
  path = route.path;
17745
17745
  key = route.key;
@@ -17812,10 +17812,10 @@ class QueryRouter {
17812
17812
  return this.routes.find((r) => r.path === path && r.key === key);
17813
17813
  }
17814
17814
  findRoute(opts) {
17815
- const { path, key, id } = opts || {};
17815
+ const { path, key, rid } = opts || {};
17816
17816
  return this.routes.find((r) => {
17817
- if (id) {
17818
- return r.id === id;
17817
+ if (rid) {
17818
+ return r.rid === rid;
17819
17819
  }
17820
17820
  if (path) {
17821
17821
  if (key !== undefined) {
@@ -17836,14 +17836,14 @@ class QueryRouter {
17836
17836
  const tokenUser = ctx.state;
17837
17837
  let isUser = !!tokenUser;
17838
17838
  const list = this.getList(opts?.filter).filter((item) => {
17839
- if (item.id === "auth" || item.id === "auth-can" || item.id === "check-auth-admin" || item.id === "auth-admin") {
17839
+ if (item.rid === "auth" || item.rid === "auth-can" || item.rid === "check-auth-admin" || item.rid === "auth-admin") {
17840
17840
  return false;
17841
17841
  }
17842
17842
  return true;
17843
17843
  });
17844
17844
  ctx.body = {
17845
17845
  list: list.map((item) => {
17846
- const route = pick(item, ["id", "path", "key", "description", "middleware", "metadata"]);
17846
+ const route = pick(item, ["rid", "path", "key", "description", "middleware", "metadata"]);
17847
17847
  return toJSONSchemaRoute(route);
17848
17848
  }),
17849
17849
  isUser
@@ -17913,14 +17913,14 @@ class QueryRouterServer extends QueryRouter {
17913
17913
  return super.run(msg, ctx);
17914
17914
  }
17915
17915
  async runAction(api2, payload, ctx) {
17916
- const { path, key, id } = api2;
17917
- return this.run({ path, key, id, payload }, ctx);
17916
+ const { path, key, rid } = api2;
17917
+ return this.run({ path, key, rid, payload }, ctx);
17918
17918
  }
17919
17919
  async createAuth(fun) {
17920
17920
  this.route({
17921
17921
  path: "auth",
17922
17922
  key: "auth",
17923
- id: "auth",
17923
+ rid: "auth",
17924
17924
  description: "token验证"
17925
17925
  }).define(async (ctx) => {
17926
17926
  if (fun) {
@@ -17930,7 +17930,7 @@ class QueryRouterServer extends QueryRouter {
17930
17930
  this.route({
17931
17931
  path: "auth-admin",
17932
17932
  key: "auth-admin",
17933
- id: "auth-admin",
17933
+ rid: "auth-admin",
17934
17934
  description: "admin token验证",
17935
17935
  middleware: ["auth"]
17936
17936
  }).define(async (ctx) => {
@@ -17941,7 +17941,7 @@ class QueryRouterServer extends QueryRouter {
17941
17941
  this.route({
17942
17942
  path: "auth-can",
17943
17943
  key: "auth-can",
17944
- id: "auth-can",
17944
+ rid: "auth-can",
17945
17945
  description: "权限验证"
17946
17946
  }).define(async (ctx) => {
17947
17947
  if (fun) {
@@ -18036,8 +18036,8 @@ class Chain {
18036
18036
  this.object.key = key;
18037
18037
  return this;
18038
18038
  }
18039
- setId(key) {
18040
- this.object.id = key;
18039
+ setRid(key) {
18040
+ this.object.rid = key;
18041
18041
  return this;
18042
18042
  }
18043
18043
  setRun(run) {
package/dist/ws.d.ts CHANGED
@@ -178,16 +178,16 @@ type RunMessage = {
178
178
  id?: string;
179
179
  payload?: any;
180
180
  };
181
- type NextRoute = Pick<Route, 'id' | 'path' | 'key'>;
181
+ type NextRoute = Pick<Route, 'rid' | 'path' | 'key'>;
182
182
  type RouteMiddleware = {
183
183
  path?: string;
184
184
  key?: string;
185
- id?: string;
185
+ rid?: string;
186
186
  } | string;
187
187
  type RouteOpts<U = {}, T = SimpleObject> = {
188
188
  path?: string;
189
189
  key?: string;
190
- id?: string;
190
+ rid?: string;
191
191
  run?: Run<U>;
192
192
  nextRoute?: NextRoute;
193
193
  description?: string;
@@ -197,7 +197,7 @@ type RouteOpts<U = {}, T = SimpleObject> = {
197
197
  isDebug?: boolean;
198
198
  };
199
199
  type DefineRouteOpts = Omit<RouteOpts, 'idUsePath' | 'nextRoute'>;
200
- declare const pickValue: readonly ["path", "key", "id", "description", "type", "middleware", "metadata"];
200
+ declare const pickValue: readonly ["path", "key", "rid", "description", "type", "middleware", "metadata"];
201
201
  type RouteInfo = Pick<Route, (typeof pickValue)[number]>;
202
202
  /**
203
203
  * @M 是 route的 metadate的类型,默认是 SimpleObject
@@ -212,7 +212,7 @@ declare class Route<M extends SimpleObject = SimpleObject, U extends SimpleObjec
212
212
  * 二级路径
213
213
  */
214
214
  key?: string;
215
- id?: string;
215
+ rid?: string;
216
216
  run?: Run<BuildRouteContext<M, U>>;
217
217
  nextRoute?: NextRoute;
218
218
  description?: string;
@@ -306,7 +306,7 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
306
306
  * @returns
307
307
  */
308
308
  call(message: {
309
- id?: string;
309
+ rid?: string;
310
310
  path?: string;
311
311
  key?: string;
312
312
  payload?: any;
@@ -393,7 +393,7 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
393
393
  findRoute(opts?: {
394
394
  path?: string;
395
395
  key?: string;
396
- id?: string;
396
+ rid?: string;
397
397
  }): Route<SimpleObject, SimpleObject>;
398
398
  createRouteList(opts?: {
399
399
  force?: boolean;
@@ -484,7 +484,7 @@ declare class QueryRouterServer<C extends SimpleObject = SimpleObject> extends Q
484
484
  * @returns
485
485
  */
486
486
  run(msg: {
487
- id?: string;
487
+ rid?: string;
488
488
  path?: string;
489
489
  key?: string;
490
490
  payload?: any;
@@ -492,7 +492,7 @@ declare class QueryRouterServer<C extends SimpleObject = SimpleObject> extends Q
492
492
  data?: any;
493
493
  }, ctx?: Partial<RouteContext<C>>): Promise<any>;
494
494
  runAction<T extends {
495
- id?: string;
495
+ rid?: string;
496
496
  path?: string;
497
497
  key?: string;
498
498
  metadata?: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@kevisual/router",
4
- "version": "0.1.7",
4
+ "version": "0.2.2",
5
5
  "description": "",
6
6
  "type": "module",
7
7
  "main": "./dist/router.js",
@@ -30,7 +30,7 @@
30
30
  "@kevisual/query": "^0.0.55",
31
31
  "@kevisual/remote-app": "^0.0.7",
32
32
  "@kevisual/use-config": "^1.0.30",
33
- "@opencode-ai/plugin": "^1.2.27",
33
+ "@opencode-ai/plugin": "^1.3.0",
34
34
  "@types/bun": "^1.3.11",
35
35
  "@types/crypto-js": "^4.2.2",
36
36
  "@types/node": "^25.5.0",
package/src/opencode.ts CHANGED
@@ -60,11 +60,11 @@ export const createRouterAgentPluginFn = (opts?: {
60
60
  addCallFn(router as App)
61
61
  }
62
62
  if (router) {
63
- (router as any).route({ path: 'auth', key: '', id: 'auth', description: '认证' }).define(async (ctx) => { }).addTo(router as App, {
63
+ (router as any).route({ path: 'auth', key: '', rid: 'auth', description: '认证' }).define(async (ctx) => { }).addTo(router as App, {
64
64
  overwrite: false
65
65
  });
66
66
 
67
- (router as any).route({ path: 'auth-admin', key: '', id: 'auth-admin', description: '认证' }).define(async (ctx) => { }).addTo(router as App, {
67
+ (router as any).route({ path: 'auth-admin', key: '', rid: 'auth-admin', description: '认证' }).define(async (ctx) => { }).addTo(router as App, {
68
68
  overwrite: false
69
69
  })
70
70
  }