vona-module-a-web 5.0.37 → 5.0.39
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/cli/controller/metadata/generate.ts +12 -0
- package/dist/.metadata/index.d.ts +8 -0
- package/dist/bean/hmr.dto.d.ts +6 -0
- package/dist/index.js +78 -79
- package/dist/lib/const.d.ts +4 -4
- package/dist/lib/decorator/request.d.ts +9 -9
- package/dist/types/controller.d.ts +2 -0
- package/dist/types/router.d.ts +1 -0
- package/dist-cli/controller/metadata/generate.js +12 -0
- package/package.json +1 -1
|
@@ -4,12 +4,16 @@ import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
|
4
4
|
|
|
5
5
|
export default async function (options: IMetadataCustomGenerateOptions): Promise<string> {
|
|
6
6
|
const { sceneName, moduleName, globFiles } = options;
|
|
7
|
+
const contentResources: string[] = [];
|
|
7
8
|
const contentImports: string[] = [];
|
|
8
9
|
const contentActions: string[] = [];
|
|
9
10
|
const contentPaths: Record<string, string[]> = {};
|
|
10
11
|
for (const globFile of globFiles) {
|
|
11
12
|
const { className, beanName, fileNameJSRelative, fileContent } = globFile;
|
|
12
13
|
const opionsName = `IControllerOptions${toUpperCaseFirstChar(beanName)}`;
|
|
14
|
+
if (fileContent.includes('@Resource()')) {
|
|
15
|
+
contentResources.push(`'${moduleName}:${beanName}': never;`);
|
|
16
|
+
}
|
|
13
17
|
contentImports.push(`// @ts-ignore ignore\nimport type { ${className} } from '${fileNameJSRelative}';`);
|
|
14
18
|
contentActions.push(`
|
|
15
19
|
export interface ${opionsName} {
|
|
@@ -51,6 +55,13 @@ export default async function (options: IMetadataCustomGenerateOptions): Promise
|
|
|
51
55
|
${contentRecord}
|
|
52
56
|
}`
|
|
53
57
|
: '';
|
|
58
|
+
let contentResources2 = contentResources.length > 0 ? `import 'vona-module-a-openapi';
|
|
59
|
+
declare module 'vona-module-a-openapi' {
|
|
60
|
+
export interface IResourceRecord {
|
|
61
|
+
${contentResources.join('\n')}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`: '';
|
|
54
65
|
// combine
|
|
55
66
|
const content = `/** ${sceneName}: begin */
|
|
56
67
|
${contentImports.join('\n')}
|
|
@@ -58,6 +69,7 @@ declare module 'vona-module-${moduleName}' {
|
|
|
58
69
|
${contentActions.join('\n')}
|
|
59
70
|
}
|
|
60
71
|
${contentRecord2}
|
|
72
|
+
${contentResources2}
|
|
61
73
|
/** ${sceneName}: end */
|
|
62
74
|
`;
|
|
63
75
|
return content;
|
|
@@ -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,10 +1,11 @@
|
|
|
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';
|
|
5
6
|
import { Bean, Service, Scope } from 'vona-module-a-bean';
|
|
6
7
|
import { SymbolUseOnionOptions } from 'vona-module-a-onion';
|
|
7
|
-
import { SymbolRouteHandlersArgumentsValue, SymbolRouteHandlersArgumentsMeta, makeSchemaLikes, $schema, SymbolOpenApiOptions, mergeFieldsOpenapiMetadata } from 'vona-module-a-openapiutils';
|
|
8
|
+
import { SymbolRouteHandlersArgumentsValue, SymbolRouteHandlersArgumentsMeta, makeSchemaLikes, $schema, SymbolOpenApiOptions, SymbolControllerResource, mergeFieldsOpenapiMetadata } from 'vona-module-a-openapiutils';
|
|
8
9
|
import { SymbolUploadValue } from 'vona-module-a-upload';
|
|
9
10
|
import http from 'node:http';
|
|
10
11
|
import { Startup } from 'vona-module-a-startup';
|
|
@@ -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 =
|
|
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
|
-
}
|
|
168
|
-
|
|
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
|
-
}),
|
|
165
|
+
}), BeanInfo({
|
|
178
166
|
module: "a-web"
|
|
179
|
-
}),
|
|
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,11 +175,19 @@ let PipeValid = (_dec$7 = Pipe({
|
|
|
184
175
|
}
|
|
185
176
|
return value;
|
|
186
177
|
}
|
|
187
|
-
}
|
|
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');
|
|
191
|
-
const SymbolControllerOptionsResource = Symbol('SymbolControllerOptionsResource');
|
|
192
191
|
const recordResourceNameToRoutePath = {};
|
|
193
192
|
function getCacheControllerRoutes(app) {
|
|
194
193
|
if (!app.meta[SymbolCacheControllerRoutes]) app.meta[SymbolCacheControllerRoutes] = {};
|
|
@@ -295,11 +294,9 @@ async function middlewarePipe(ctx, next) {
|
|
|
295
294
|
async function _transformArguments(app, route) {
|
|
296
295
|
const paramtypes = appMetadata.getMetadata('design:paramtypes', route.controller.prototype, route.action);
|
|
297
296
|
if (!paramtypes) return;
|
|
298
|
-
|
|
299
297
|
// meta
|
|
300
298
|
const argsMeta = appMetadata.getMetadata(SymbolRouteHandlersArgumentsMeta, route.controller.prototype, route.action);
|
|
301
299
|
if (!argsMeta) return;
|
|
302
|
-
|
|
303
300
|
// args
|
|
304
301
|
const args = Array.from({
|
|
305
302
|
length: paramtypes.length
|
|
@@ -393,7 +390,6 @@ function _collectArgumentMiddlewares(onionPipe, argMeta) {
|
|
|
393
390
|
}
|
|
394
391
|
|
|
395
392
|
const SymbolRequestMappingHandler = Symbol('SymbolRequestMappingHandler');
|
|
396
|
-
|
|
397
393
|
// export enum RequestMethod {
|
|
398
394
|
// GET = 'get',
|
|
399
395
|
// POST = 'post',
|
|
@@ -404,10 +400,7 @@ const SymbolRequestMappingHandler = Symbol('SymbolRequestMappingHandler');
|
|
|
404
400
|
// HEAD = 'head',
|
|
405
401
|
// }
|
|
406
402
|
|
|
407
|
-
|
|
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 {
|
|
403
|
+
let BeanRouter = class BeanRouter extends BeanBase {
|
|
411
404
|
reRegisterController(beanFullName) {
|
|
412
405
|
const app = this.app;
|
|
413
406
|
// remove
|
|
@@ -458,7 +451,6 @@ let BeanRouter = (_dec$6 = Bean(), _dec2$6 = BeanInfo({
|
|
|
458
451
|
_registerControllerAction(moduleName, controller, controllerBeanFullName, controllerPath, controllerMiddlewaresOptions, actionKey, desc) {
|
|
459
452
|
// app
|
|
460
453
|
const app = this.app;
|
|
461
|
-
|
|
462
454
|
// actionPath/actionMethod
|
|
463
455
|
if (!appMetadata.hasMetadata(SymbolRequestMappingHandler, controller.prototype, actionKey)) return;
|
|
464
456
|
const handlerMetadata = appMetadata.getMetadata(SymbolRequestMappingHandler, controller.prototype, actionKey);
|
|
@@ -467,15 +459,12 @@ let BeanRouter = (_dec$6 = Bean(), _dec2$6 = BeanInfo({
|
|
|
467
459
|
// routePath
|
|
468
460
|
const routePath = app.util.combineApiPathControllerAndAction(moduleName, controllerPath, actionPath, true, true);
|
|
469
461
|
const routePathRaw = app.util.combineApiPathControllerAndActionRaw(moduleName, controllerPath, actionPath, true);
|
|
470
|
-
|
|
471
462
|
// middlewares options
|
|
472
463
|
const actionMiddlewaresOptions = appMetadata.getMetadata(SymbolUseOnionOptions, controller.prototype, actionKey);
|
|
473
|
-
|
|
474
464
|
// route
|
|
475
465
|
const route = {
|
|
476
466
|
meta: deepExtend({}, controllerMiddlewaresOptions, actionMiddlewaresOptions)
|
|
477
467
|
};
|
|
478
|
-
|
|
479
468
|
// route
|
|
480
469
|
const _route = {
|
|
481
470
|
controller,
|
|
@@ -485,9 +474,9 @@ let BeanRouter = (_dec$6 = Bean(), _dec2$6 = BeanInfo({
|
|
|
485
474
|
route,
|
|
486
475
|
routeMethod: actionMethod,
|
|
487
476
|
routePath,
|
|
488
|
-
routePathRaw
|
|
477
|
+
routePathRaw,
|
|
478
|
+
routePathOriginal: actionPath
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
}),
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
}),
|
|
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
|
-
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
656
|
+
};
|
|
657
|
+
FilterTransformDateRange = __decorate([FilterTransform({
|
|
658
|
+
separator: '~'
|
|
659
|
+
}), BeanInfo({
|
|
675
660
|
module: "a-web"
|
|
676
|
-
}),
|
|
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
|
-
}
|
|
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
|
-
|
|
767
|
-
|
|
765
|
+
let ScopeModuleAWeb = class ScopeModuleAWeb extends BeanScopeBase {};
|
|
766
|
+
ScopeModuleAWeb = __decorate([Scope(), BeanInfo({
|
|
768
767
|
module: "a-web"
|
|
769
|
-
}),
|
|
770
|
-
|
|
768
|
+
})], ScopeModuleAWeb);
|
|
771
769
|
/** scope: end */
|
|
772
770
|
|
|
773
771
|
function createPipesArgumentDecorator(paramType, extractValue) {
|
|
@@ -860,24 +858,25 @@ function Controller(path, options) {
|
|
|
860
858
|
return createBeanDecorator('controller', options, false, target => {
|
|
861
859
|
// beanOptions
|
|
862
860
|
const beanOptions = appResource.getBean(target);
|
|
863
|
-
//
|
|
861
|
+
// IOpenapiOptions
|
|
864
862
|
const optionsMeta = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target);
|
|
865
|
-
for (const key
|
|
866
|
-
|
|
867
|
-
|
|
863
|
+
for (const key in cast(beanOptions.options)) {
|
|
864
|
+
if (key === 'path') continue;
|
|
865
|
+
optionsMeta[key] = cast(beanOptions.options)[key];
|
|
868
866
|
}
|
|
869
|
-
//
|
|
867
|
+
// IOpenapiOptions
|
|
870
868
|
mergeActionsOpenapiMetadata(target);
|
|
871
869
|
// map: resourceName->api path
|
|
872
870
|
const onionName = onionNameFromBeanFullName(beanOptions.beanFullName);
|
|
873
|
-
const
|
|
874
|
-
if (
|
|
871
|
+
const controllerResource = appMetadata.getOwnMetadata(SymbolControllerResource, target);
|
|
872
|
+
if (controllerResource) {
|
|
875
873
|
const app = useApp();
|
|
876
874
|
const apiPath = app.util.combineApiPathControllerAndAction(beanOptions.module, cast(beanOptions.options).path, undefined, true, true);
|
|
877
875
|
const routePathRaw = app.util.combineApiPathControllerAndActionRaw(beanOptions.module, cast(beanOptions.options).path, undefined, true);
|
|
878
876
|
recordResourceNameToRoutePath[onionName] = {
|
|
879
877
|
apiPath,
|
|
880
|
-
routePathRaw
|
|
878
|
+
routePathRaw,
|
|
879
|
+
target
|
|
881
880
|
};
|
|
882
881
|
} else {
|
|
883
882
|
// for hmr
|
|
@@ -954,4 +953,4 @@ const Web = {
|
|
|
954
953
|
head: Head
|
|
955
954
|
};
|
|
956
955
|
|
|
957
|
-
export { Arg, ArgFilterPro, ArgValid, BeanRouter, Controller, Dto, FilterTransform, FilterTransformBase, FilterTransformDateRange, HmrController, Main, PipeFilter, PipeValid, RequestMapping, ScopeModuleAWeb, ServiceWeb, StartupListen, SymbolCacheControllerRoutes,
|
|
956
|
+
export { Arg, ArgFilterPro, ArgValid, BeanRouter, Controller, Dto, FilterTransform, FilterTransformBase, FilterTransformDateRange, HmrController, HmrDto, Main, PipeFilter, PipeValid, RequestMapping, ScopeModuleAWeb, ServiceWeb, StartupListen, SymbolCacheControllerRoutes, SymbolRequestMappingHandler, Web, config, createPipesArgumentDecorator, getCacheControllerRoutes, mergeActionsOpenapiMetadata, recordResourceNameToRoutePath };
|
package/dist/lib/const.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { VonaApplication } from 'vona';
|
|
2
|
-
import type {
|
|
1
|
+
import type { Constructable, VonaApplication } from 'vona';
|
|
2
|
+
import type { IResourceRecord } from 'vona-module-a-openapi';
|
|
3
3
|
import type { ContextRoute } from '../types/router.ts';
|
|
4
4
|
export interface IRecordResourceNameToRoutePathItem {
|
|
5
5
|
apiPath: string;
|
|
6
6
|
routePathRaw: string;
|
|
7
|
+
target: Constructable;
|
|
7
8
|
}
|
|
8
9
|
export declare const SymbolCacheControllerRoutes: unique symbol;
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const recordResourceNameToRoutePath: Record<keyof IControllerRecord, IRecordResourceNameToRoutePathItem>;
|
|
10
|
+
export declare const recordResourceNameToRoutePath: Record<keyof IResourceRecord, IRecordResourceNameToRoutePathItem>;
|
|
11
11
|
export declare function getCacheControllerRoutes(app: VonaApplication): Record<string, ContextRoute[]>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IOpenapiOptions } from 'vona-module-a-openapiutils';
|
|
2
2
|
import type { TypeRequestMethod } from '../../types/request.ts';
|
|
3
3
|
export interface RequestMappingMetadata {
|
|
4
4
|
path?: string;
|
|
5
5
|
method?: TypeRequestMethod;
|
|
6
|
-
options?:
|
|
6
|
+
options?: IOpenapiOptions;
|
|
7
7
|
}
|
|
8
8
|
export declare function RequestMapping(metadata?: RequestMappingMetadata): MethodDecorator;
|
|
9
9
|
export declare const Web: {
|
|
10
|
-
post: (path?:
|
|
11
|
-
get: (path?:
|
|
12
|
-
delete: (path?:
|
|
13
|
-
put: (path?:
|
|
14
|
-
patch: (path?:
|
|
15
|
-
options: (path?:
|
|
16
|
-
head: (path?:
|
|
10
|
+
post: (path?: IOpenapiOptions | string, options?: IOpenapiOptions) => MethodDecorator;
|
|
11
|
+
get: (path?: IOpenapiOptions | string, options?: IOpenapiOptions) => MethodDecorator;
|
|
12
|
+
delete: (path?: IOpenapiOptions | string, options?: IOpenapiOptions) => MethodDecorator;
|
|
13
|
+
put: (path?: IOpenapiOptions | string, options?: IOpenapiOptions) => MethodDecorator;
|
|
14
|
+
patch: (path?: IOpenapiOptions | string, options?: IOpenapiOptions) => MethodDecorator;
|
|
15
|
+
options: (path?: IOpenapiOptions | string, options?: IOpenapiOptions) => MethodDecorator;
|
|
16
|
+
head: (path?: IOpenapiOptions | string, options?: IOpenapiOptions) => MethodDecorator;
|
|
17
17
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { OmitNever } from 'vona';
|
|
2
2
|
import type { ServiceOnion, TypeOnionOptionsEnableSimple } from 'vona-module-a-onion';
|
|
3
|
+
import type { IOpenapiOptionsResourceMeta } from 'vona-module-a-openapi';
|
|
3
4
|
export interface IApiPathRecordMethodMap {
|
|
4
5
|
get: IApiPathGetRecord;
|
|
5
6
|
post: IApiPathPostRecord;
|
|
@@ -25,6 +26,7 @@ export interface IDecoratorControllerOptions extends TypeOnionOptionsEnableSimpl
|
|
|
25
26
|
path?: string;
|
|
26
27
|
exclude?: boolean;
|
|
27
28
|
tags?: string[];
|
|
29
|
+
resourceMeta?: IOpenapiOptionsResourceMeta;
|
|
28
30
|
}
|
|
29
31
|
declare module 'vona-module-a-onion' {
|
|
30
32
|
interface BeanOnion {
|
package/dist/types/router.d.ts
CHANGED
|
@@ -2,12 +2,16 @@ import { combineApiPathControllerAndActionRaw } from '@cabloy/utils';
|
|
|
2
2
|
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
3
3
|
export default async function (options) {
|
|
4
4
|
const { sceneName, moduleName, globFiles } = options;
|
|
5
|
+
const contentResources = [];
|
|
5
6
|
const contentImports = [];
|
|
6
7
|
const contentActions = [];
|
|
7
8
|
const contentPaths = {};
|
|
8
9
|
for (const globFile of globFiles) {
|
|
9
10
|
const { className, beanName, fileNameJSRelative, fileContent } = globFile;
|
|
10
11
|
const opionsName = `IControllerOptions${toUpperCaseFirstChar(beanName)}`;
|
|
12
|
+
if (fileContent.includes('@Resource()')) {
|
|
13
|
+
contentResources.push(`'${moduleName}:${beanName}': never;`);
|
|
14
|
+
}
|
|
11
15
|
contentImports.push(`// @ts-ignore ignore\nimport type { ${className} } from '${fileNameJSRelative}';`);
|
|
12
16
|
contentActions.push(`
|
|
13
17
|
export interface ${opionsName} {
|
|
@@ -52,6 +56,13 @@ export default async function (options) {
|
|
|
52
56
|
${contentRecord}
|
|
53
57
|
}`
|
|
54
58
|
: '';
|
|
59
|
+
let contentResources2 = contentResources.length > 0 ? `import 'vona-module-a-openapi';
|
|
60
|
+
declare module 'vona-module-a-openapi' {
|
|
61
|
+
export interface IResourceRecord {
|
|
62
|
+
${contentResources.join('\n')}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
` : '';
|
|
55
66
|
// combine
|
|
56
67
|
const content = `/** ${sceneName}: begin */
|
|
57
68
|
${contentImports.join('\n')}
|
|
@@ -59,6 +70,7 @@ declare module 'vona-module-${moduleName}' {
|
|
|
59
70
|
${contentActions.join('\n')}
|
|
60
71
|
}
|
|
61
72
|
${contentRecord2}
|
|
73
|
+
${contentResources2}
|
|
62
74
|
/** ${sceneName}: end */
|
|
63
75
|
`;
|
|
64
76
|
return content;
|