vona-module-a-web 5.0.37 → 5.0.38

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.
@@ -126,10 +126,12 @@ declare module 'vona-module-a-web' {
126
126
  /** filterTransform: end */
127
127
  /** hmr: begin */
128
128
  export * from '../bean/hmr.controller.ts';
129
+ export * from '../bean/hmr.dto.ts';
129
130
  import 'vona';
130
131
  declare module 'vona' {
131
132
  interface IHmrRecord {
132
133
  'a-web:controller': never;
134
+ 'a-web:dto': never;
133
135
  }
134
136
  }
135
137
  declare module 'vona-module-a-web' {
@@ -139,6 +141,12 @@ declare module 'vona-module-a-web' {
139
141
  get $beanFullName(): 'a-web.hmr.controller';
140
142
  get $onionName(): 'a-web:controller';
141
143
  }
144
+ interface HmrDto {
145
+ }
146
+ interface HmrDto {
147
+ get $beanFullName(): 'a-web.hmr.dto';
148
+ get $onionName(): 'a-web:dto';
149
+ }
142
150
  }
143
151
  /** hmr: end */
144
152
  /** config: begin */
@@ -0,0 +1,6 @@
1
+ import type { IDecoratorBeanOptionsBase } from 'vona';
2
+ import type { IHmrReload } from 'vona-module-a-hmr';
3
+ import { BeanBase } from 'vona';
4
+ export declare class HmrDto extends BeanBase implements IHmrReload {
5
+ reload(_beanOptions: IDecoratorBeanOptionsBase): Promise<void>;
6
+ }
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { BeanInfo, BeanBase, cast, beanFullNameFromOnionName, appMetadata, appResource, deepExtend, compose, createBeanDecorator, BeanSimple, BeanScopeBase, onionNameFromBeanFullName, useApp } from 'vona';
2
+ import { __decorate } from 'tslib';
2
3
  import { isNil, isNilOrEmptyString } from '@cabloy/utils';
3
4
  import { ZodMetadata } from '@cabloy/zod-openapi';
4
5
  import { Pipe, createArgumentPipe, SymbolCacheComposeGuards, SymbolCacheComposeInterceptors, SymbolCacheComposePipes, SymbolCacheComposeMiddlewares, clearCacheComposesRouter, SymbolCacheComposeMiddlewareSystems, setArgumentPipe } from 'vona-module-a-aspect';
@@ -15,17 +16,8 @@ import Router from 'find-my-way';
15
16
  import { SymbolRouterMiddleware } from 'vona-module-a-executor';
16
17
  import { z } from 'zod';
17
18
 
18
- var _dec$8, _dec2$8, _class$8;
19
19
  const __FieldsSystem = ['columns', 'where', 'orders', 'pageNo', 'pageSize'];
20
- let PipeFilter = (_dec$8 = Pipe({
21
- // ValidatorOptions
22
- disableErrorMessages: false,
23
- errorHttpStatusCode: 400,
24
- loose: false,
25
- strict: false
26
- }), _dec2$8 = BeanInfo({
27
- module: "a-web"
28
- }), _dec$8(_class$8 = _dec2$8(_class$8 = class PipeFilter extends BeanBase {
20
+ let PipeFilter = class PipeFilter extends BeanBase {
29
21
  async transform(value, metadata, options) {
30
22
  if (!options.schema) throw new Error(`should specify the schema of pipeFilter: ${metadata.controller.name}.${metadata.method}#${metadata.index}`);
31
23
  // validateSchema
@@ -45,7 +37,6 @@ let PipeFilter = (_dec$8 = Pipe({
45
37
  // ok
46
38
  return params;
47
39
  }
48
-
49
40
  // system: columns/where/orders/pageNo/pageSize
50
41
  _transformSystem(value) {
51
42
  const params = {};
@@ -164,19 +155,19 @@ let PipeFilter = (_dec$8 = Pipe({
164
155
  await this._transformField(key, value[key], params, value, options);
165
156
  }
166
157
  }
167
- }) || _class$8) || _class$8);
168
- const ArgFilterPro = createArgumentPipe('a-web:filter');
169
-
170
- var _dec$7, _dec2$7, _class$7;
171
- let PipeValid = (_dec$7 = Pipe({
158
+ };
159
+ PipeFilter = __decorate([Pipe({
172
160
  // ValidatorOptions
173
161
  disableErrorMessages: false,
174
162
  errorHttpStatusCode: 400,
175
163
  loose: false,
176
164
  strict: false
177
- }), _dec2$7 = BeanInfo({
165
+ }), BeanInfo({
178
166
  module: "a-web"
179
- }), _dec$7(_class$7 = _dec2$7(_class$7 = class PipeValid extends BeanBase {
167
+ })], PipeFilter);
168
+ const ArgFilterPro = createArgumentPipe('a-web:filter');
169
+
170
+ let PipeValid = class PipeValid extends BeanBase {
180
171
  async transform(value, metadata, options) {
181
172
  if (options.schema) {
182
173
  // validateSchema
@@ -184,7 +175,16 @@ let PipeValid = (_dec$7 = Pipe({
184
175
  }
185
176
  return value;
186
177
  }
187
- }) || _class$7) || _class$7);
178
+ };
179
+ PipeValid = __decorate([Pipe({
180
+ // ValidatorOptions
181
+ disableErrorMessages: false,
182
+ errorHttpStatusCode: 400,
183
+ loose: false,
184
+ strict: false
185
+ }), BeanInfo({
186
+ module: "a-web"
187
+ })], PipeValid);
188
188
  const ArgValid = createArgumentPipe('a-web:valid');
189
189
 
190
190
  const SymbolCacheControllerRoutes = Symbol('SymbolCacheControllerRoutes');
@@ -295,11 +295,9 @@ async function middlewarePipe(ctx, next) {
295
295
  async function _transformArguments(app, route) {
296
296
  const paramtypes = appMetadata.getMetadata('design:paramtypes', route.controller.prototype, route.action);
297
297
  if (!paramtypes) return;
298
-
299
298
  // meta
300
299
  const argsMeta = appMetadata.getMetadata(SymbolRouteHandlersArgumentsMeta, route.controller.prototype, route.action);
301
300
  if (!argsMeta) return;
302
-
303
301
  // args
304
302
  const args = Array.from({
305
303
  length: paramtypes.length
@@ -393,7 +391,6 @@ function _collectArgumentMiddlewares(onionPipe, argMeta) {
393
391
  }
394
392
 
395
393
  const SymbolRequestMappingHandler = Symbol('SymbolRequestMappingHandler');
396
-
397
394
  // export enum RequestMethod {
398
395
  // GET = 'get',
399
396
  // POST = 'post',
@@ -404,10 +401,7 @@ const SymbolRequestMappingHandler = Symbol('SymbolRequestMappingHandler');
404
401
  // HEAD = 'head',
405
402
  // }
406
403
 
407
- var _dec$6, _dec2$6, _class$6;
408
- let BeanRouter = (_dec$6 = Bean(), _dec2$6 = BeanInfo({
409
- module: "a-web"
410
- }), _dec$6(_class$6 = _dec2$6(_class$6 = class BeanRouter extends BeanBase {
404
+ let BeanRouter = class BeanRouter extends BeanBase {
411
405
  reRegisterController(beanFullName) {
412
406
  const app = this.app;
413
407
  // remove
@@ -458,7 +452,6 @@ let BeanRouter = (_dec$6 = Bean(), _dec2$6 = BeanInfo({
458
452
  _registerControllerAction(moduleName, controller, controllerBeanFullName, controllerPath, controllerMiddlewaresOptions, actionKey, desc) {
459
453
  // app
460
454
  const app = this.app;
461
-
462
455
  // actionPath/actionMethod
463
456
  if (!appMetadata.hasMetadata(SymbolRequestMappingHandler, controller.prototype, actionKey)) return;
464
457
  const handlerMetadata = appMetadata.getMetadata(SymbolRequestMappingHandler, controller.prototype, actionKey);
@@ -467,15 +460,12 @@ let BeanRouter = (_dec$6 = Bean(), _dec2$6 = BeanInfo({
467
460
  // routePath
468
461
  const routePath = app.util.combineApiPathControllerAndAction(moduleName, controllerPath, actionPath, true, true);
469
462
  const routePathRaw = app.util.combineApiPathControllerAndActionRaw(moduleName, controllerPath, actionPath, true);
470
-
471
463
  // middlewares options
472
464
  const actionMiddlewaresOptions = appMetadata.getMetadata(SymbolUseOnionOptions, controller.prototype, actionKey);
473
-
474
465
  // route
475
466
  const route = {
476
467
  meta: deepExtend({}, controllerMiddlewaresOptions, actionMiddlewaresOptions)
477
468
  };
478
-
479
469
  // route
480
470
  const _route = {
481
471
  controller,
@@ -487,7 +477,6 @@ let BeanRouter = (_dec$6 = Bean(), _dec2$6 = BeanInfo({
487
477
  routePath,
488
478
  routePathRaw
489
479
  };
490
-
491
480
  // fn
492
481
  const fn = function (_req, _res, params, _store, searchParams) {
493
482
  const ctx = this;
@@ -496,18 +485,19 @@ let BeanRouter = (_dec$6 = Bean(), _dec2$6 = BeanInfo({
496
485
  ctx.request.query = searchParams;
497
486
  return _composeMiddlewares(this.app, _route)(ctx);
498
487
  };
499
-
500
488
  // add
501
489
  const cacheControllerRoutes = getCacheControllerRoutes(this.app);
502
490
  if (!cacheControllerRoutes[controllerBeanFullName]) {
503
491
  cacheControllerRoutes[controllerBeanFullName] = [];
504
492
  }
505
493
  cacheControllerRoutes[controllerBeanFullName].push(_route);
506
-
507
494
  // register
508
495
  app.router.on(_route.routeMethod.toUpperCase(), _route.routePath, fn);
509
496
  }
510
- }) || _class$6) || _class$6);
497
+ };
498
+ BeanRouter = __decorate([Bean(), BeanInfo({
499
+ module: "a-web"
500
+ })], BeanRouter);
511
501
  function _composeMiddlewares(app, route) {
512
502
  // compose
513
503
  if (!app.meta[SymbolCacheComposeMiddlewares]) app.meta[SymbolCacheComposeMiddlewares] = {};
@@ -552,10 +542,7 @@ async function routeTailDoneMiddleware(ctx, next) {
552
542
  return res;
553
543
  }
554
544
 
555
- var _dec$5, _dec2$5, _class$5;
556
- let ServiceWeb = (_dec$5 = Service(), _dec2$5 = BeanInfo({
557
- module: "a-web"
558
- }), _dec$5(_class$5 = _dec2$5(_class$5 = class ServiceWeb extends BeanBase {
545
+ let ServiceWeb = class ServiceWeb extends BeanBase {
559
546
  combineControllerActionApiPath(controller, actionKey, prefix, simplify) {
560
547
  // beanOptions
561
548
  const beanOptions = appResource.getBean(controller);
@@ -569,14 +556,12 @@ let ServiceWeb = (_dec$5 = Service(), _dec2$5 = BeanInfo({
569
556
  // combine
570
557
  return this.app.util.combineApiPathControllerAndAction(beanOptions.module, controllerPath, actionPath, prefix, simplify);
571
558
  }
572
- }) || _class$5) || _class$5);
573
-
574
- var _dec$4, _dec2$4, _class$4;
575
- let StartupListen = (_dec$4 = Startup({
576
- after: true
577
- }), _dec2$4 = BeanInfo({
559
+ };
560
+ ServiceWeb = __decorate([Service(), BeanInfo({
578
561
  module: "a-web"
579
- }), _dec$4(_class$4 = _dec2$4(_class$4 = class StartupListen extends BeanBase {
562
+ })], ServiceWeb);
563
+
564
+ let StartupListen = class StartupListen extends BeanBase {
580
565
  async execute() {
581
566
  if (!this.app.config.server.listen.disable) {
582
567
  this.app.server = this._listen(this.app.config.server.listen.port, this.app.config.server.listen.hostname);
@@ -602,16 +587,18 @@ let StartupListen = (_dec$4 = Startup({
602
587
  }); // not set instanceName
603
588
  };
604
589
  }
605
- }) || _class$4) || _class$4);
590
+ };
591
+ StartupListen = __decorate([Startup({
592
+ after: true
593
+ }), BeanInfo({
594
+ module: "a-web"
595
+ })], StartupListen);
606
596
 
607
597
  function FilterTransform(options) {
608
598
  return createBeanDecorator('filterTransform', options);
609
599
  }
610
600
 
611
- var _dec$3, _dec2$3, _class$3;
612
- let FilterTransformBase = (_dec$3 = FilterTransform(), _dec2$3 = BeanInfo({
613
- module: "a-web"
614
- }), _dec$3(_class$3 = _dec2$3(_class$3 = class FilterTransformBase extends BeanBase {
601
+ let FilterTransformBase = class FilterTransformBase extends BeanBase {
615
602
  async where(info, _options) {
616
603
  const {
617
604
  value,
@@ -636,14 +623,12 @@ let FilterTransformBase = (_dec$3 = FilterTransform(), _dec2$3 = BeanInfo({
636
623
  }
637
624
  return where;
638
625
  }
639
- }) || _class$3) || _class$3);
640
-
641
- var _dec$2, _dec2$2, _class$2;
642
- let FilterTransformDateRange = (_dec$2 = FilterTransform({
643
- separator: '~'
644
- }), _dec2$2 = BeanInfo({
626
+ };
627
+ FilterTransformBase = __decorate([FilterTransform(), BeanInfo({
645
628
  module: "a-web"
646
- }), _dec$2(_class$2 = _dec2$2(_class$2 = class FilterTransformDateRange extends BeanBase {
629
+ })], FilterTransformBase);
630
+
631
+ let FilterTransformDateRange = class FilterTransformDateRange extends BeanBase {
647
632
  async where(info, options) {
648
633
  const {
649
634
  value
@@ -668,18 +653,32 @@ let FilterTransformDateRange = (_dec$2 = FilterTransform({
668
653
  }
669
654
  return where;
670
655
  }
671
- }) || _class$2) || _class$2);
672
-
673
- var _dec$1, _dec2$1, _class$1;
674
- let HmrController = (_dec$1 = Hmr(), _dec2$1 = BeanInfo({
656
+ };
657
+ FilterTransformDateRange = __decorate([FilterTransform({
658
+ separator: '~'
659
+ }), BeanInfo({
675
660
  module: "a-web"
676
- }), _dec$1(_class$1 = _dec2$1(_class$1 = class HmrController extends BeanBase {
661
+ })], FilterTransformDateRange);
662
+
663
+ let HmrController = class HmrController extends BeanBase {
677
664
  async reload(beanOptions) {
678
665
  clearCacheComposesRouter(this.app);
679
666
  this.bean.router.reRegisterController(beanOptions.beanFullName);
680
667
  await this.$scope.openapi.service.openapi.clearAllCaches();
681
668
  }
682
- }) || _class$1) || _class$1);
669
+ };
670
+ HmrController = __decorate([Hmr(), BeanInfo({
671
+ module: "a-web"
672
+ })], HmrController);
673
+
674
+ let HmrDto = class HmrDto extends BeanBase {
675
+ async reload(_beanOptions) {
676
+ this.app.bean.worker.reload();
677
+ }
678
+ };
679
+ HmrDto = __decorate([Hmr(), BeanInfo({
680
+ module: "a-web"
681
+ })], HmrDto);
683
682
 
684
683
  function config(_app) {
685
684
  return {
@@ -763,11 +762,10 @@ function _wrapOnion(app, item) {
763
762
  return fn;
764
763
  }
765
764
 
766
- var _dec, _dec2, _class;
767
- let ScopeModuleAWeb = (_dec = Scope(), _dec2 = BeanInfo({
765
+ let ScopeModuleAWeb = class ScopeModuleAWeb extends BeanScopeBase {};
766
+ ScopeModuleAWeb = __decorate([Scope(), BeanInfo({
768
767
  module: "a-web"
769
- }), _dec(_class = _dec2(_class = class ScopeModuleAWeb extends BeanScopeBase {}) || _class) || _class);
770
-
768
+ })], ScopeModuleAWeb);
771
769
  /** scope: end */
772
770
 
773
771
  function createPipesArgumentDecorator(paramType, extractValue) {
@@ -954,4 +952,4 @@ const Web = {
954
952
  head: Head
955
953
  };
956
954
 
957
- export { Arg, ArgFilterPro, ArgValid, BeanRouter, Controller, Dto, FilterTransform, FilterTransformBase, FilterTransformDateRange, HmrController, Main, PipeFilter, PipeValid, RequestMapping, ScopeModuleAWeb, ServiceWeb, StartupListen, SymbolCacheControllerRoutes, SymbolControllerOptionsResource, SymbolRequestMappingHandler, Web, config, createPipesArgumentDecorator, getCacheControllerRoutes, mergeActionsOpenapiMetadata, recordResourceNameToRoutePath };
955
+ export { Arg, ArgFilterPro, ArgValid, BeanRouter, Controller, Dto, FilterTransform, FilterTransformBase, FilterTransformDateRange, HmrController, HmrDto, Main, PipeFilter, PipeValid, RequestMapping, ScopeModuleAWeb, ServiceWeb, StartupListen, SymbolCacheControllerRoutes, SymbolControllerOptionsResource, SymbolRequestMappingHandler, Web, config, createPipesArgumentDecorator, getCacheControllerRoutes, mergeActionsOpenapiMetadata, recordResourceNameToRoutePath };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-web",
3
3
  "type": "module",
4
- "version": "5.0.37",
4
+ "version": "5.0.38",
5
5
  "title": "a-web",
6
6
  "vonaModule": {
7
7
  "capabilities": {