vona-module-a-web 5.0.38 → 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.
@@ -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;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { ZodMetadata } from '@cabloy/zod-openapi';
5
5
  import { Pipe, createArgumentPipe, SymbolCacheComposeGuards, SymbolCacheComposeInterceptors, SymbolCacheComposePipes, SymbolCacheComposeMiddlewares, clearCacheComposesRouter, SymbolCacheComposeMiddlewareSystems, setArgumentPipe } from 'vona-module-a-aspect';
6
6
  import { Bean, Service, Scope } from 'vona-module-a-bean';
7
7
  import { SymbolUseOnionOptions } from 'vona-module-a-onion';
8
- 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';
9
9
  import { SymbolUploadValue } from 'vona-module-a-upload';
10
10
  import http from 'node:http';
11
11
  import { Startup } from 'vona-module-a-startup';
@@ -188,7 +188,6 @@ PipeValid = __decorate([Pipe({
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] = {};
@@ -475,7 +474,8 @@ let BeanRouter = class BeanRouter extends BeanBase {
475
474
  route,
476
475
  routeMethod: actionMethod,
477
476
  routePath,
478
- routePathRaw
477
+ routePathRaw,
478
+ routePathOriginal: actionPath
479
479
  };
480
480
  // fn
481
481
  const fn = function (_req, _res, params, _store, searchParams) {
@@ -858,24 +858,25 @@ function Controller(path, options) {
858
858
  return createBeanDecorator('controller', options, false, target => {
859
859
  // beanOptions
860
860
  const beanOptions = appResource.getBean(target);
861
- // IOpenApiOptions
861
+ // IOpenapiOptions
862
862
  const optionsMeta = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target);
863
- for (const key of ['exclude', 'tags']) {
864
- const option = cast(beanOptions.options)[key];
865
- if (option !== undefined) optionsMeta[key] = option;
863
+ for (const key in cast(beanOptions.options)) {
864
+ if (key === 'path') continue;
865
+ optionsMeta[key] = cast(beanOptions.options)[key];
866
866
  }
867
- // IOpenApiOptions
867
+ // IOpenapiOptions
868
868
  mergeActionsOpenapiMetadata(target);
869
869
  // map: resourceName->api path
870
870
  const onionName = onionNameFromBeanFullName(beanOptions.beanFullName);
871
- const optionsResource = appMetadata.getOwnMetadata(SymbolControllerOptionsResource, target);
872
- if (optionsResource) {
871
+ const controllerResource = appMetadata.getOwnMetadata(SymbolControllerResource, target);
872
+ if (controllerResource) {
873
873
  const app = useApp();
874
874
  const apiPath = app.util.combineApiPathControllerAndAction(beanOptions.module, cast(beanOptions.options).path, undefined, true, true);
875
875
  const routePathRaw = app.util.combineApiPathControllerAndActionRaw(beanOptions.module, cast(beanOptions.options).path, undefined, true);
876
876
  recordResourceNameToRoutePath[onionName] = {
877
877
  apiPath,
878
- routePathRaw
878
+ routePathRaw,
879
+ target
879
880
  };
880
881
  } else {
881
882
  // for hmr
@@ -952,4 +953,4 @@ const Web = {
952
953
  head: Head
953
954
  };
954
955
 
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 };
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 };
@@ -1,11 +1,11 @@
1
- import type { VonaApplication } from 'vona';
2
- import type { IControllerRecord } from '../types/controller.ts';
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 SymbolControllerOptionsResource: unique symbol;
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 { IOpenApiOptions } from 'vona-module-a-openapiutils';
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?: IOpenApiOptions;
6
+ options?: IOpenapiOptions;
7
7
  }
8
8
  export declare function RequestMapping(metadata?: RequestMappingMetadata): MethodDecorator;
9
9
  export declare const Web: {
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;
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 {
@@ -13,6 +13,7 @@ export interface ContextRoute {
13
13
  routeMethod: TypeRequestMethod;
14
14
  routePath: string;
15
15
  routePathRaw: string;
16
+ routePathOriginal: string;
16
17
  }
17
18
  declare module 'vona' {
18
19
  interface VonaApplication {
@@ -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;
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.38",
4
+ "version": "5.0.39",
5
5
  "title": "a-web",
6
6
  "vonaModule": {
7
7
  "capabilities": {