@kevisual/api 0.0.43 → 0.0.44

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.
@@ -150,6 +150,7 @@ declare class QueryProxy {
150
150
  initRouterView(item: RouterViewItem): RouterViewItem<{}>;
151
151
  /**
152
152
  * 初始化路由
153
+ * main
153
154
  * @returns
154
155
  */
155
156
  init(): Promise<void>;
@@ -164,6 +165,7 @@ declare class QueryProxy {
164
165
  callWorker(msg: any, viewItem: RouterViewWorker['worker']): Promise<Result>;
165
166
  initWorker(item?: RouterViewWorker, initRoutes?: boolean): Promise<void>;
166
167
  initPage(item?: RouteViewPage): Promise<void>;
168
+ getQueryByViewId(viewId: string): string | undefined;
167
169
  /**
168
170
  * 列出路由
169
171
  * @param filter
@@ -10387,16 +10387,17 @@ class QueryProxy {
10387
10387
  return;
10388
10388
  }
10389
10389
  }
10390
+ getQueryByViewId(viewId) {
10391
+ const view = this.views.find((v) => v.id === viewId);
10392
+ if (view) {
10393
+ return view.query;
10394
+ }
10395
+ return;
10396
+ }
10390
10397
  async listRoutes(filterFn, opts) {
10391
10398
  let query = opts?.query;
10392
- if (opts?.viewId) {
10393
- const view = this.views.find((v) => v.id === opts.viewId);
10394
- if (view) {
10395
- query = view.query;
10396
- }
10397
- }
10398
- if (opts?.query) {
10399
- query = opts.query;
10399
+ if (opts?.viewId && !query) {
10400
+ query = this.getQueryByViewId(opts.viewId);
10400
10401
  }
10401
10402
  const routes = this.router.routes.filter(filterFn || (() => true));
10402
10403
  if (query) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/api",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "",
5
5
  "main": "mod.ts",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  import { QueryClient as Query, Result } from '@kevisual/query';
2
- import { QueryRouterServer, type App, type Route } from '@kevisual/router/browser';
2
+ import { QueryRouterServer, type App, type Route, fromJSONSchema, toJSONSchema } from '@kevisual/router/browser';
3
3
  import { filter } from '@kevisual/js-filter'
4
4
  import { EventEmitter } from 'eventemitter3';
5
5
  import { initApi } from './router-api-proxy.ts';
@@ -190,6 +190,7 @@ export class QueryProxy {
190
190
 
191
191
  /**
192
192
  * 初始化路由
193
+ * main
193
194
  * @returns
194
195
  */
195
196
  async init() {
@@ -246,6 +247,8 @@ export class QueryProxy {
246
247
  return
247
248
  }
248
249
  const routes = router.getList();
250
+ // TODO: args
251
+ // const args = fromJSONSchema(r);
249
252
  for (const r of routes) {
250
253
  console.debug(`注册路由: [${r.path}] ${r?.key}`, 'Context');
251
254
  let metadata = r.metadata || {};
@@ -378,6 +381,13 @@ export class QueryProxy {
378
381
  return;
379
382
  }
380
383
  }
384
+ getQueryByViewId(viewId: string): string | undefined {
385
+ const view = this.views.find(v => v.id === viewId);
386
+ if (view) {
387
+ return view.query;
388
+ }
389
+ return undefined;
390
+ }
381
391
  /**
382
392
  * 列出路由
383
393
  * @param filter
@@ -386,14 +396,10 @@ export class QueryProxy {
386
396
  */
387
397
  async listRoutes(filterFn?: (item: Route) => boolean, opts?: { viewId?: string, query?: string }) {
388
398
  let query = opts?.query;
389
- if (opts?.viewId) {
390
- const view = this.views.find(v => v.id === opts.viewId);
391
- if (view) {
392
- query = view.query;
393
- }
394
- } if (opts?.query) {
395
- query = opts.query;
399
+ if (opts?.viewId && !query) {
400
+ query = this.getQueryByViewId(opts.viewId);
396
401
  }
402
+
397
403
  const routes = this.router.routes.filter(filterFn || (() => true));
398
404
  if (query) {
399
405
  if (query.toLocaleUpperCase().startsWith('WHERE')) {