@kevisual/router 0.0.88 → 0.0.90

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.js CHANGED
@@ -17020,6 +17020,9 @@ var toJSONSchemaRoute = (route) => {
17020
17020
  if (pickValues?.metadata?.args) {
17021
17021
  pickValues.metadata.args = toJSONSchema3(pickValues?.metadata?.args, { mergeObject: false });
17022
17022
  }
17023
+ if (pickValues?.metadata?.returns) {
17024
+ pickValues.metadata.returns = toJSONSchema3(pickValues?.metadata?.returns, { mergeObject: false });
17025
+ }
17023
17026
  return pickValues;
17024
17027
  };
17025
17028
  var toJSONSchema3 = toJSONSchema2;
@@ -19579,7 +19582,7 @@ app
19579
19582
  10. **中间件找不到会返回 404**,错误信息中会包含找不到的中间件列表。
19580
19583
  `;
19581
19584
  // package.json
19582
- var version2 = "0.0.88";
19585
+ var version2 = "0.0.90";
19583
19586
 
19584
19587
  // agent/routes/route-create.ts
19585
19588
  app.route({
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { z } from 'zod';
3
- import { program } from 'commander';
3
+ import { Command } from 'commander';
4
4
  import * as http from 'node:http';
5
5
  import { IncomingMessage, ServerResponse } from 'node:http';
6
6
  import { IncomingMessage as IncomingMessage$1, ServerResponse as ServerResponse$1 } from 'http';
@@ -804,12 +804,13 @@ declare const parseArgs: (args: string) => any;
804
804
  declare const parseDescription: (route: App["routes"][number]) => string;
805
805
  declare const createCommand: (opts: {
806
806
  app: App;
807
- program: typeof program;
807
+ program: Command;
808
808
  }) => void;
809
809
  declare const parse: (opts: {
810
810
  app: QueryRouterServer;
811
811
  description?: string;
812
812
  parse?: boolean;
813
+ program?: Command;
813
814
  }) => void;
814
815
 
815
816
  export { createCommand, groupByPath, parse, parseArgs, parseDescription };
package/dist/commander.js CHANGED
@@ -2195,7 +2195,7 @@ var createCommand2 = (opts) => {
2195
2195
  for (const path in groupRoutes) {
2196
2196
  const routeList = groupRoutes[path];
2197
2197
  const keys = routeList.map((route) => route.key).filter(Boolean);
2198
- const subProgram = program2.command(path).description(`路由《${path} ${keys.length > 0 ? ": " + keys.join(", ") : ""}`);
2198
+ const subProgram = program2.command(path).description(`路由[${path}] ${keys.length > 0 ? ": " + keys.join(", ") : ""}`);
2199
2199
  routeList.forEach((route) => {
2200
2200
  if (!route.key)
2201
2201
  return;
@@ -2227,10 +2227,11 @@ var createCommand2 = (opts) => {
2227
2227
  };
2228
2228
  var parse = (opts) => {
2229
2229
  const { app, description, parse: parse2 = true } = opts;
2230
- program.description(description || "Router 命令行工具");
2231
- createCommand2({ app, program });
2230
+ const _program = opts.program || program;
2231
+ _program.description(description || "Router 命令行工具");
2232
+ createCommand2({ app, program: _program });
2232
2233
  if (parse2) {
2233
- program.parse(process.argv);
2234
+ _program.parse(process.argv);
2234
2235
  }
2235
2236
  };
2236
2237
  export {
@@ -14184,6 +14184,9 @@ var toJSONSchemaRoute = (route) => {
14184
14184
  if (pickValues?.metadata?.args) {
14185
14185
  pickValues.metadata.args = toJSONSchema3(pickValues?.metadata?.args, { mergeObject: false });
14186
14186
  }
14187
+ if (pickValues?.metadata?.returns) {
14188
+ pickValues.metadata.returns = toJSONSchema3(pickValues?.metadata?.returns, { mergeObject: false });
14189
+ }
14187
14190
  return pickValues;
14188
14191
  };
14189
14192
  var toJSONSchema3 = toJSONSchema2;
package/dist/router.js CHANGED
@@ -17017,6 +17017,9 @@ var toJSONSchemaRoute = (route) => {
17017
17017
  if (pickValues?.metadata?.args) {
17018
17018
  pickValues.metadata.args = toJSONSchema3(pickValues?.metadata?.args, { mergeObject: false });
17019
17019
  }
17020
+ if (pickValues?.metadata?.returns) {
17021
+ pickValues.metadata.returns = toJSONSchema3(pickValues?.metadata?.returns, { mergeObject: false });
17022
+ }
17020
17023
  return pickValues;
17021
17024
  };
17022
17025
  var toJSONSchema3 = toJSONSchema2;
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.0.88",
4
+ "version": "0.0.90",
5
5
  "description": "",
6
6
  "type": "module",
7
7
  "main": "./dist/router.js",
@@ -29,7 +29,7 @@
29
29
  "@kevisual/local-proxy": "^0.0.8",
30
30
  "@kevisual/query": "^0.0.53",
31
31
  "@kevisual/use-config": "^1.0.30",
32
- "@opencode-ai/plugin": "^1.2.20",
32
+ "@opencode-ai/plugin": "^1.2.21",
33
33
  "@types/bun": "^1.3.10",
34
34
  "@types/node": "^25.3.5",
35
35
  "@types/send": "^1.2.1",
package/src/commander.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { program } from 'commander';
1
+ import { Command, program } from 'commander';
2
2
  import { App, QueryRouterServer } from './app.ts';
3
3
 
4
4
  export const groupByPath = (routes: App['routes']) => {
@@ -62,7 +62,7 @@ export const parseDescription = (route: App['routes'][number]) => {
62
62
  }
63
63
  return desc;
64
64
  }
65
- export const createCommand = (opts: { app: App, program: typeof program }) => {
65
+ export const createCommand = (opts: { app: App, program: Command }) => {
66
66
  const { app, program } = opts;
67
67
  const routes = app.routes;
68
68
 
@@ -71,7 +71,7 @@ export const createCommand = (opts: { app: App, program: typeof program }) => {
71
71
  for (const path in groupRoutes) {
72
72
  const routeList = groupRoutes[path];
73
73
  const keys = routeList.map(route => route.key).filter(Boolean);
74
- const subProgram = program.command(path).description(`路由《${path} ${keys.length > 0 ? ': ' + keys.join(', ') : ''}`);
74
+ const subProgram = program.command(path).description(`路由[${path}] ${keys.length > 0 ? ': ' + keys.join(', ') : ''}`);
75
75
  routeList.forEach(route => {
76
76
  if (!route.key) return;
77
77
  const description = parseDescription(route);
@@ -103,11 +103,12 @@ export const createCommand = (opts: { app: App, program: typeof program }) => {
103
103
  }
104
104
  }
105
105
 
106
- export const parse = (opts: { app: QueryRouterServer, description?: string, parse?: boolean }) => {
107
- const { app, description, parse = true } = opts;
108
- program.description(description || 'Router 命令行工具');
109
- createCommand({ app: app as App, program });
106
+ export const parse = (opts: { app: QueryRouterServer, description?: string, parse?: boolean, program?: Command }) => {
107
+ const { app, description, parse = true, } = opts;
108
+ const _program = opts.program || program;
109
+ _program.description(description || 'Router 命令行工具');
110
+ createCommand({ app: app as App, program: _program });
110
111
  if (parse) {
111
- program.parse(process.argv);
112
+ _program.parse(process.argv);
112
113
  }
113
114
  }
package/src/route.ts CHANGED
@@ -271,6 +271,9 @@ const toJSONSchemaRoute = (route: RouteInfo) => {
271
271
  if (pickValues?.metadata?.args) {
272
272
  pickValues.metadata.args = toJSONSchema(pickValues?.metadata?.args, { mergeObject: false });
273
273
  }
274
+ if (pickValues?.metadata?.returns) {
275
+ pickValues.metadata.returns = toJSONSchema(pickValues?.metadata?.returns, { mergeObject: false });
276
+ }
274
277
  return pickValues;
275
278
  }
276
279