vona-module-a-web 5.0.35 → 5.0.36
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/index.js +25 -7
- package/dist/lib/const.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BeanInfo, BeanBase, cast, beanFullNameFromOnionName, appMetadata, appResource, deepExtend, compose, createBeanDecorator, BeanSimple, BeanScopeBase } from 'vona';
|
|
1
|
+
import { BeanInfo, BeanBase, cast, beanFullNameFromOnionName, appMetadata, appResource, deepExtend, compose, createBeanDecorator, BeanSimple, BeanScopeBase, onionNameFromBeanFullName, useApp } from 'vona';
|
|
2
2
|
import { isNil, isNilOrEmptyString } from '@cabloy/utils';
|
|
3
3
|
import { ZodMetadata } from '@cabloy/zod-openapi';
|
|
4
4
|
import { Pipe, createArgumentPipe, SymbolCacheComposeGuards, SymbolCacheComposeInterceptors, SymbolCacheComposePipes, SymbolCacheComposeMiddlewares, clearCacheComposesRouter, SymbolCacheComposeMiddlewareSystems, setArgumentPipe } from 'vona-module-a-aspect';
|
|
@@ -188,6 +188,8 @@ let PipeValid = (_dec$7 = Pipe({
|
|
|
188
188
|
const ArgValid = createArgumentPipe('a-web:valid');
|
|
189
189
|
|
|
190
190
|
const SymbolCacheControllerRoutes = Symbol('SymbolCacheControllerRoutes');
|
|
191
|
+
const SymbolControllerOptionsResource = Symbol('SymbolControllerOptionsResource');
|
|
192
|
+
const recordResourceNameToRoutePath = {};
|
|
191
193
|
function getCacheControllerRoutes(app) {
|
|
192
194
|
if (!app.meta[SymbolCacheControllerRoutes]) app.meta[SymbolCacheControllerRoutes] = {};
|
|
193
195
|
return app.meta[SymbolCacheControllerRoutes];
|
|
@@ -411,10 +413,11 @@ let BeanRouter = (_dec$6 = Bean(), _dec2$6 = BeanInfo({
|
|
|
411
413
|
// remove
|
|
412
414
|
const cacheControllerRoutes = getCacheControllerRoutes(this.app);
|
|
413
415
|
const routes = cacheControllerRoutes[beanFullName];
|
|
414
|
-
if (
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
if (routes) {
|
|
417
|
+
delete cacheControllerRoutes[beanFullName];
|
|
418
|
+
for (const route of routes) {
|
|
419
|
+
app.router.off(route.routeMethod.toUpperCase(), route.routePath);
|
|
420
|
+
}
|
|
418
421
|
}
|
|
419
422
|
// register
|
|
420
423
|
this.registerController(beanFullName);
|
|
@@ -860,11 +863,26 @@ function Controller(path, options) {
|
|
|
860
863
|
// IOpenApiOptions
|
|
861
864
|
const optionsMeta = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target);
|
|
862
865
|
for (const key of ['exclude', 'tags']) {
|
|
863
|
-
const option = cast(beanOptions
|
|
866
|
+
const option = cast(beanOptions.options)[key];
|
|
864
867
|
if (option !== undefined) optionsMeta[key] = option;
|
|
865
868
|
}
|
|
866
869
|
// IOpenApiOptions
|
|
867
870
|
mergeActionsOpenapiMetadata(target);
|
|
871
|
+
// map: resourceName->api path
|
|
872
|
+
const onionName = onionNameFromBeanFullName(beanOptions.beanFullName);
|
|
873
|
+
const optionsResource = appMetadata.getOwnMetadata(SymbolControllerOptionsResource, target);
|
|
874
|
+
if (optionsResource) {
|
|
875
|
+
const app = useApp();
|
|
876
|
+
const apiPath = app.util.combineApiPathControllerAndAction(beanOptions.module, cast(beanOptions.options).path, undefined, true, true);
|
|
877
|
+
const routePathRaw = app.util.combineApiPathControllerAndActionRaw(beanOptions.module, cast(beanOptions.options).path, undefined, true);
|
|
878
|
+
recordResourceNameToRoutePath[onionName] = {
|
|
879
|
+
apiPath,
|
|
880
|
+
routePathRaw
|
|
881
|
+
};
|
|
882
|
+
} else {
|
|
883
|
+
// for hmr
|
|
884
|
+
delete recordResourceNameToRoutePath[onionName];
|
|
885
|
+
}
|
|
868
886
|
});
|
|
869
887
|
}
|
|
870
888
|
function Dto(options) {
|
|
@@ -936,4 +954,4 @@ const Web = {
|
|
|
936
954
|
head: Head
|
|
937
955
|
};
|
|
938
956
|
|
|
939
|
-
export { Arg, ArgFilterPro, ArgValid, BeanRouter, Controller, Dto, FilterTransform, FilterTransformBase, FilterTransformDateRange, HmrController, Main, PipeFilter, PipeValid, RequestMapping, ScopeModuleAWeb, ServiceWeb, StartupListen, SymbolCacheControllerRoutes, SymbolRequestMappingHandler, Web, config, createPipesArgumentDecorator, getCacheControllerRoutes, mergeActionsOpenapiMetadata };
|
|
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 };
|
package/dist/lib/const.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { VonaApplication } from 'vona';
|
|
2
|
+
import type { IControllerRecord } from '../types/controller.ts';
|
|
2
3
|
import type { ContextRoute } from '../types/router.ts';
|
|
4
|
+
export interface IRecordResourceNameToRoutePathItem {
|
|
5
|
+
apiPath: string;
|
|
6
|
+
routePathRaw: string;
|
|
7
|
+
}
|
|
3
8
|
export declare const SymbolCacheControllerRoutes: unique symbol;
|
|
9
|
+
export declare const SymbolControllerOptionsResource: unique symbol;
|
|
10
|
+
export declare const recordResourceNameToRoutePath: Record<keyof IControllerRecord, IRecordResourceNameToRoutePathItem>;
|
|
4
11
|
export declare function getCacheControllerRoutes(app: VonaApplication): Record<string, ContextRoute[]>;
|