vona-module-a-openapi 5.0.20 → 5.0.22

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.
@@ -1,20 +1,7 @@
1
- import type { BeanScopeUtil, TypeLocaleBase, TypeModuleConfig, TypeModuleLocales } from 'vona';
2
- import type { config } from '../config/config.ts';
3
- /** service: end */
4
1
  /** service: begin */
5
- /** service: end */
6
- /** service: begin */
7
- import type { ServiceOpenapi } from '../service/openapi.ts';
8
- /** main: end */
9
- /** scope: begin */
10
- import { BeanScopeBase } from 'vona';
11
- /** service: end */
12
- /** config: begin */
13
- import 'vona';
14
- import 'vona';
2
+ export * from '../service/openapi.ts';
15
3
  import 'vona';
16
- export * from '../config/config.ts';
17
- declare module 'vona-module-a-web' {
4
+ declare module 'vona-module-a-bean' {
18
5
  interface IServiceRecord {
19
6
  'a-openapi:openapi': never;
20
7
  }
@@ -23,17 +10,24 @@ declare module 'vona-module-a-openapi' {
23
10
  interface ServiceOpenapi {
24
11
  }
25
12
  }
13
+ /** service: end */
14
+ /** service: begin */
15
+ import type { ServiceOpenapi } from '../service/openapi.ts';
26
16
  export interface IModuleService {
27
- openapi: ServiceOpenapi;
17
+ 'openapi': ServiceOpenapi;
28
18
  }
19
+ /** service: end */
20
+ /** service: begin */
21
+ import 'vona';
29
22
  declare module 'vona' {
30
23
  interface IBeanRecordGeneral {
31
24
  'a-openapi.service.openapi': ServiceOpenapi;
32
25
  }
33
26
  }
34
- /** locale: end */
35
- /** main: begin */
36
- export * from '../main.ts';
27
+ /** service: end */
28
+ /** config: begin */
29
+ export * from '../config/config.ts';
30
+ import type { config } from '../config/config.ts';
37
31
  export declare const locales: {
38
32
  'en-us': {
39
33
  ZodError_invalid_input: string;
@@ -194,8 +188,12 @@ export declare const locales: {
194
188
  ZodError_types_set: string;
195
189
  };
196
190
  };
197
- /** service: begin */
198
- export * from '../service/openapi.ts';
191
+ /** locale: end */
192
+ /** main: begin */
193
+ export * from '../main.ts';
194
+ /** main: end */
195
+ /** scope: begin */
196
+ import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig, type TypeModuleLocales, type TypeLocaleBase } from 'vona';
199
197
  export declare class ScopeModuleAOpenapi extends BeanScopeBase {
200
198
  }
201
199
  export interface ScopeModuleAOpenapi {
@@ -204,6 +202,7 @@ export interface ScopeModuleAOpenapi {
204
202
  locale: TypeModuleLocales<(typeof locales)[TypeLocaleBase]>;
205
203
  service: IModuleService;
206
204
  }
205
+ import 'vona';
207
206
  declare module 'vona' {
208
207
  interface IBeanScopeRecord {
209
208
  'a-openapi': ScopeModuleAOpenapi;
@@ -1,7 +1,7 @@
1
1
  import type { OpenAPIObjectConfig as OpenAPIObjectConfigV30 } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator.ts';
2
2
  import type { OpenAPIObjectConfigV31 } from '@asteasolutions/zod-to-openapi/dist/v3.1/openapi-generator.ts';
3
3
  import type { VonaApplication } from 'vona';
4
- import type { TypeOpenApiVersion, TypeSecuritySchemes } from '../types/api.ts';
4
+ import type { TypeOpenApiVersion, TypeSecuritySchemes } from 'vona-module-a-openapiutils';
5
5
  export declare function config(_app: VonaApplication): {
6
6
  defaultVersion: TypeOpenApiVersion;
7
7
  generateDocument: {
package/dist/index.js CHANGED
@@ -1,68 +1,17 @@
1
- import { BeanSimple, appMetadata, appResource, cast, BeanInfo, BeanBase, LocaleModuleNameSeparator, HttpStatus, BeanScopeBase, isClassStrict, registerMappedClassMetadataKey, deepExtend } from 'vona';
2
- import { Scope } from 'vona-module-a-bean';
3
- import { locales as locales$1, setErrorMapDefault, setErrorMapSchema } from '@cabloy/zod-errors-custom';
1
+ import { appMetadata, appResource, cast, BeanInfo, BeanBase, LocaleModuleNameSeparator, HttpStatus, BeanSimple, BeanScopeBase, isClassStrict, registerMappedClassMetadataKey, deepExtend } from 'vona';
4
2
  import { OpenApiGeneratorV3, OpenApiGeneratorV31, OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
5
3
  import * as ModuleInfo from '@cabloy/module-info';
6
4
  import { isEmptyObject, isNil } from '@cabloy/utils';
7
5
  import { toUpperCaseFirstChar } from '@cabloy/word-utils';
8
6
  import { getTypeName, coerceWithNil } from '@cabloy/zod-query';
9
- import { Service, SymbolRequestMappingHandler } from 'vona-module-a-web';
7
+ import { Service, Scope } from 'vona-module-a-bean';
8
+ import { SymbolDecoratorRule, SymbolOpenApiOptions, SymbolDecoratorRuleColumn } from 'vona-module-a-openapiutils';
9
+ import { SymbolRequestMappingHandler } from 'vona-module-a-web';
10
10
  import { z } from 'zod';
11
+ import { locales as locales$1, setErrorMapDefault, setErrorMapSchema } from '@cabloy/zod-errors-custom';
11
12
  import 'openapi3-ts/oas30';
12
13
  import 'openapi3-ts/oas31';
13
14
 
14
- var locale_en_us = locales$1['en-us'];
15
-
16
- var locale_zh_cn = locales$1['zh-cn'];
17
-
18
- function config(_app) {
19
- return {
20
- defaultVersion: 'V31',
21
- generateDocument: {
22
- V30: {
23
- openapi: '3.0.0',
24
- info: {
25
- version: '5.0.0',
26
- title: 'Vona',
27
- description: 'Vona API'
28
- }
29
- },
30
- V31: {
31
- openapi: '3.1.0',
32
- info: {
33
- version: '5.0.0',
34
- title: 'Vona',
35
- description: 'Vona API'
36
- }
37
- }
38
- },
39
- securitySchemes: {
40
- bearerAuth: {
41
- type: 'http',
42
- scheme: 'bearer',
43
- bearerFormat: 'JWT'
44
- }
45
- }
46
- };
47
- }
48
-
49
- function errorsAdapter(app) {
50
- setErrorMapDefault((text, ...args) => {
51
- return app.meta.text(text, ...args);
52
- });
53
- setErrorMapSchema((text, ...args) => {
54
- return app.meta.text(text, ...args);
55
- });
56
- }
57
-
58
- class Main extends BeanSimple {
59
- async moduleLoading() {}
60
- async moduleLoaded() {
61
- errorsAdapter(this.app);
62
- }
63
- async configLoaded(_config) {}
64
- }
65
-
66
15
  function bodySchemaWrapperDefault(bodySchema) {
67
16
  return z.object({
68
17
  code: z.string(),
@@ -71,14 +20,6 @@ function bodySchemaWrapperDefault(bodySchema) {
71
20
  });
72
21
  }
73
22
 
74
- const SymbolDecoratorRule = Symbol('SymbolDecoratorRule');
75
- const SymbolDecoratorRuleColumn = Symbol('SymbolDecoratorRuleColumn');
76
-
77
- // not use z.ZodSchema
78
-
79
- const SymbolRouteHandlersArgumentsMeta = Symbol('SymbolRouteHandlersArgumentsMeta');
80
- const SymbolRouteHandlersArgumentsValue = Symbol('SymbolRouteHandlersArgumentsValue');
81
-
82
23
  function $schema(classType, options) {
83
24
  if (!classType) return z.any();
84
25
  if (classType.parseAsync) return classType;
@@ -107,7 +48,8 @@ function $schema(classType, options) {
107
48
  return schema;
108
49
  }
109
50
 
110
- const SymbolOpenApiOptions = Symbol('SymbolOpenApiOptions');
51
+ const SymbolRouteHandlersArgumentsMeta = Symbol('SymbolRouteHandlersArgumentsMeta');
52
+ const SymbolRouteHandlersArgumentsValue = Symbol('SymbolRouteHandlersArgumentsValue');
111
53
 
112
54
  var _dec$1, _dec2$1, _class$1;
113
55
  const __ArgumentTypes = ['param', 'query', 'body', 'headers', 'fields', 'field', 'files', 'file'];
@@ -432,6 +374,58 @@ let ServiceOpenapi = (_dec$1 = Service(), _dec2$1 = BeanInfo({
432
374
  }
433
375
  }) || _class$1) || _class$1);
434
376
 
377
+ function config(_app) {
378
+ return {
379
+ defaultVersion: 'V31',
380
+ generateDocument: {
381
+ V30: {
382
+ openapi: '3.0.0',
383
+ info: {
384
+ version: '5.0.0',
385
+ title: 'Vona',
386
+ description: 'Vona API'
387
+ }
388
+ },
389
+ V31: {
390
+ openapi: '3.1.0',
391
+ info: {
392
+ version: '5.0.0',
393
+ title: 'Vona',
394
+ description: 'Vona API'
395
+ }
396
+ }
397
+ },
398
+ securitySchemes: {
399
+ bearerAuth: {
400
+ type: 'http',
401
+ scheme: 'bearer',
402
+ bearerFormat: 'JWT'
403
+ }
404
+ }
405
+ };
406
+ }
407
+
408
+ var locale_en_us = locales$1['en-us'];
409
+
410
+ var locale_zh_cn = locales$1['zh-cn'];
411
+
412
+ function errorsAdapter(app) {
413
+ setErrorMapDefault((text, ...args) => {
414
+ return app.meta.text(text, ...args);
415
+ });
416
+ setErrorMapSchema((text, ...args) => {
417
+ return app.meta.text(text, ...args);
418
+ });
419
+ }
420
+
421
+ class Main extends BeanSimple {
422
+ async moduleLoading() {}
423
+ async moduleLoaded() {
424
+ errorsAdapter(this.app);
425
+ }
426
+ async configLoaded(_config) {}
427
+ }
428
+
435
429
  var _dec, _dec2, _class;
436
430
  const locales = {
437
431
  'en-us': locale_en_us,
@@ -519,10 +513,6 @@ function Field$1(...schemaLikes) {
519
513
  };
520
514
  }
521
515
 
522
- function setPublic(target, prop, _descriptor, value) {
523
- const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
524
- options.public = value;
525
- }
526
516
  function httpCode(httpCode) {
527
517
  return function (target, prop, descriptor) {
528
518
  const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
@@ -805,4 +795,4 @@ const OrderBusinessBase = 1000;
805
795
  const OrderUnknownBase = 10000;
806
796
  const OrderMaxBase = 100000;
807
797
 
808
- export { $locale, $schema, Api, Arg, Main, OrderBusinessBase, OrderCoreBase, OrderMaxBase, OrderUnknownBase, ScopeModuleAOpenapi, ServiceOpenapi, SymbolDecoratorRule, SymbolDecoratorRuleColumn, SymbolOpenApiOptions, SymbolRouteHandlersArgumentsMeta, SymbolRouteHandlersArgumentsValue, bodySchemaWrapperDefault, config, createPipesArgumentDecorator, errorsAdapter, getTargetDecoratorRuleColumns, getTargetDecoratorRules, locales, makeSchemaLike, makeSchemaLikes, mergeFieldsOpenAPIMetadata, setPublic, v };
798
+ export { $locale, $schema, Api, Arg, Main, OrderBusinessBase, OrderCoreBase, OrderMaxBase, OrderUnknownBase, ScopeModuleAOpenapi, ServiceOpenapi, SymbolRouteHandlersArgumentsMeta, SymbolRouteHandlersArgumentsValue, bodySchemaWrapperDefault, config, createPipesArgumentDecorator, errorsAdapter, getTargetDecoratorRuleColumns, getTargetDecoratorRules, locales, makeSchemaLike, makeSchemaLikes, mergeFieldsOpenAPIMetadata, v };
@@ -1,8 +1,5 @@
1
- import type { MetadataKey } from 'vona';
2
- import type { IOpenApiHeader, TypeResponseContentType } from '../../types/api.ts';
3
- import type { SchemaLike, SchemaLikeCreate } from '../../types/decorator.ts';
1
+ import type { IOpenApiHeader, SchemaLike, SchemaLikeCreate, TypeResponseContentType } from 'vona-module-a-openapiutils';
4
2
  import { Field } from './field.ts';
5
- export declare function setPublic(target: object, prop?: MetadataKey, _descriptor?: PropertyDescriptor, value?: boolean): void;
6
3
  declare function httpCode(httpCode: number): MethodDecorator;
7
4
  declare function contentType(contentType: TypeResponseContentType): MethodDecorator;
8
5
  declare function body(...schemaLikes: SchemaLike[]): MethodDecorator;
@@ -1,4 +1,4 @@
1
- import type { SchemaLike } from '../../types/decorator.ts';
1
+ import type { SchemaLike } from 'vona-module-a-openapiutils';
2
2
  declare function Param(): ParameterDecorator;
3
3
  declare function Param(...schemaLikes: SchemaLike[]): ParameterDecorator;
4
4
  declare function Param(property: string, ...schemaLikes: SchemaLike[]): ParameterDecorator;
@@ -1,2 +1,2 @@
1
- import type { SchemaLike } from '../../types/decorator.ts';
1
+ import type { SchemaLike } from 'vona-module-a-openapiutils';
2
2
  export declare function Field(...schemaLikes: SchemaLike[]): PropertyDecorator;
@@ -1,2 +1,3 @@
1
- import type { RouteHandlerArgumentType, SchemaLike, TypeExtractValue } from '../../types/decorator.ts';
1
+ import type { SchemaLike } from 'vona-module-a-openapiutils';
2
+ import type { RouteHandlerArgumentType, TypeExtractValue } from '../../types/decorator.ts';
2
3
  export declare function createPipesArgumentDecorator(paramType: RouteHandlerArgumentType, extractValue?: TypeExtractValue): (field?: string | SchemaLike, ...schemaLikes: SchemaLike[]) => ParameterDecorator;
@@ -1,4 +1,4 @@
1
+ import type { SchemaLike } from 'vona-module-a-openapiutils';
1
2
  import type { z } from 'zod';
2
- import type { SchemaLike } from '../../types/decorator.ts';
3
3
  export declare function makeSchemaLikes(schemaLikes: SchemaLike[], typeInit: any): z.ZodSchema;
4
4
  export declare function makeSchemaLike(schemaLike: SchemaLike | undefined, schemaPrevious: z.ZodSchema): z.ZodSchema;
@@ -1,5 +1,6 @@
1
1
  import type { Constructable } from 'vona';
2
- import type { ISchemaObjectOptions, SchemaLike } from '../../../types/decorator.ts';
2
+ import type { SchemaLike } from 'vona-module-a-openapiutils';
3
+ import type { ISchemaObjectOptions } from '../../../types/decorator.ts';
3
4
  import { z } from 'zod';
4
5
  export declare function schemaDefault<T>(defaultValue: T): (schema: z.ZodSchema) => z.ZodSchema;
5
6
  export declare function schemaOptional(): (schema: z.ZodSchema) => z.ZodSchema;
@@ -1,5 +1,5 @@
1
1
  import type { Constructable } from 'vona';
2
- import type { IOpenAPIObject } from '../types/api.ts';
2
+ import type { IOpenAPIObject } from 'vona-module-a-openapiutils';
3
3
  import { BeanBase } from 'vona';
4
4
  export declare class ServiceOpenapi extends BeanBase {
5
5
  generateJson<K extends keyof IOpenAPIObject>(version?: K): IOpenAPIObject[K];
@@ -1,9 +1,5 @@
1
1
  import type { Constructable, Type, VonaContext } from 'vona';
2
2
  import type { z } from 'zod';
3
- export declare const SymbolDecoratorRule: unique symbol;
4
- export declare const SymbolDecoratorRuleColumn: unique symbol;
5
- export type SchemaLikeCreate = (schema: any) => any;
6
- export type SchemaLike = SchemaLikeCreate | z.ZodSchema | Constructable;
7
3
  export interface ISchemaObjectOptions {
8
4
  passthrough?: boolean;
9
5
  strict?: boolean;
@@ -1,6 +1,5 @@
1
1
  import '@cabloy/zod-query';
2
2
  export * from './actions.ts';
3
- export * from './api.ts';
4
3
  export * from './behavior.ts';
5
4
  export * from './component.ts';
6
5
  export * from './database.ts';
@@ -1,8 +1,8 @@
1
1
  import type { ZodOpenAPIMetadata } from '@asteasolutions/zod-to-openapi';
2
2
  import type { CurrencyOptions } from '@zhennann/currency';
3
+ import type { IOpenApiOptions } from 'vona-module-a-openapiutils';
3
4
  import type { z, ZodTypeAny } from 'zod';
4
5
  import type { TypeResourceActionRowRecordRender } from './actions.ts';
5
- import type { IOpenApiOptions } from './api.ts';
6
6
  import type { IComponentRecord } from './component.ts';
7
7
  import 'openapi3-ts/oas30';
8
8
  import 'openapi3-ts/oas31';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-openapi",
3
3
  "type": "module",
4
- "version": "5.0.20",
4
+ "version": "5.0.22",
5
5
  "title": "a-openapi",
6
6
  "vonaModule": {
7
7
  "capabilities": {
@@ -1,39 +0,0 @@
1
- import type { OpenAPIObject as OpenAPIObject30, SchemaObject as SchemaObject30 } from 'openapi3-ts/oas30';
2
- import type { OpenAPIObject as OpenAPIObject31, SchemaObject as SchemaObject31 } from 'openapi3-ts/oas31';
3
- import type { VonaApplication } from 'vona';
4
- import type { z } from 'zod';
5
- import type { SchemaLikeCreate } from './decorator.ts';
6
- export declare const SymbolOpenApiOptions: unique symbol;
7
- export interface IOpenApiHeader {
8
- name: string;
9
- description?: string;
10
- }
11
- export interface IResponseHeaders {
12
- [key: string]: string | string[];
13
- }
14
- export interface IOpenApiOptions {
15
- public?: boolean;
16
- description?: string;
17
- summary?: string;
18
- httpCode?: number;
19
- contentType?: TypeResponseContentType;
20
- bodySchema?: z.ZodSchema;
21
- bodySchemaWrapper?: SchemaLikeCreate | false;
22
- exclude?: boolean;
23
- tags?: string[];
24
- operationId?: string;
25
- headers?: IOpenApiHeader[];
26
- setHeaders?: IResponseHeaders;
27
- }
28
- export type TypeGenerateJsonScene = 'api' | 'rest';
29
- export type TypeOpenApiVersion = 'V30' | 'V31';
30
- export interface IOpenAPIObject {
31
- V30: OpenAPIObject30;
32
- V31: OpenAPIObject31;
33
- }
34
- export interface IOpenAPISchemaObject {
35
- V30: SchemaObject30;
36
- V31: SchemaObject31;
37
- }
38
- export type TypeSecuritySchemes = Record<string, ((this: VonaApplication) => object) | object>;
39
- export type TypeResponseContentType = 'application/json' | 'application/xml' | 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain' | 'text/html' | 'application/octet-stream' | 'application/pdf' | 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp' | 'image/svg+xml' | 'image/bmp' | 'image/tiff' | 'image/vnd.microsoft.icon' | 'image/vnd.wap.wbmp' | 'image/x-icon' | 'image/x-jng' | 'image/x-ms-bmp' | 'image/x-portable-bitmap' | 'image/x-portable-graymap' | 'image/x-portable-pixmap' | 'image/x-xbitmap' | 'image/x-xpixmap' | 'image/x-xwindowdump' | 'image/bmp' | 'image/x-bmp' | 'image/x-xbitmap' | 'image/x-win-bitmap' | 'image/x-windows-bmp' | 'image/ms-bmp' | 'image/x-ms-bmp' | 'image/x-icon' | 'image/x-ico' | 'image/vnd.microsoft.icon' | 'image/ico' | 'image/icon' | 'text/css' | 'text/csv' | 'text/html' | 'text/javascript' | 'text/plain' | 'text/xml' | 'application/javascript' | 'application/ecmascript' | 'application/json' | 'application/ld+json' | 'application/manifest+json' | 'application/javascript' | 'application/x-javascript' | 'application/x-json' | 'application/x-ms-application';