vona-module-a-openapi 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.
@@ -55,17 +55,26 @@ export interface IModuleSummerCache {
55
55
  /** config: begin */
56
56
  export * from '../config/config.ts';
57
57
  import type { config } from '../config/config.ts';
58
- /** config: end */
58
+ export declare const locales: {
59
+ 'en-us': {
60
+ ZodErrorRequired: string;
61
+ };
62
+ 'zh-cn': {
63
+ ZodErrorRequired: string;
64
+ };
65
+ };
66
+ /** locale: end */
59
67
  /** main: begin */
60
68
  export * from '../main.ts';
61
69
  /** main: end */
62
70
  /** scope: begin */
63
- import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig } from 'vona';
71
+ import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig, type TypeModuleLocales, type TypeLocaleBase } from 'vona';
64
72
  export declare class ScopeModuleAOpenapi extends BeanScopeBase {
65
73
  }
66
74
  export interface ScopeModuleAOpenapi {
67
75
  util: BeanScopeUtil;
68
76
  config: TypeModuleConfig<typeof config>;
77
+ locale: TypeModuleLocales<(typeof locales)[TypeLocaleBase]>;
69
78
  service: IModuleService;
70
79
  summerCache: IModuleSummerCache;
71
80
  }
@@ -80,5 +89,9 @@ declare module 'vona' {
80
89
  interface IBeanScopeConfig {
81
90
  'a-openapi': ReturnType<typeof config>;
82
91
  }
92
+ interface IBeanScopeLocale {
93
+ 'a-openapi': (typeof locales)[TypeLocaleBase];
94
+ }
83
95
  }
96
+ export declare function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): `a-openapi::${K}`;
84
97
  /** scope: end */
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ ZodErrorRequired: string;
3
+ };
4
+ export default _default;
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ ZodErrorRequired: string;
3
+ };
4
+ export default _default;
package/dist/index.js CHANGED
@@ -604,6 +604,14 @@ function config(_app) {
604
604
  };
605
605
  }
606
606
 
607
+ var locale_en_us = {
608
+ ZodErrorRequired: 'Required'
609
+ };
610
+
611
+ var locale_zh_cn = {
612
+ ZodErrorRequired: '必填项'
613
+ };
614
+
607
615
  function schemaRefCustomAdapter(_app) {
608
616
  const registry = new OpenAPIRegistry();
609
617
  const generator31 = new OpenApiGeneratorV31(registry.definitions);
@@ -638,12 +646,25 @@ class Main extends BeanSimple {
638
646
  }
639
647
 
640
648
  var _dec, _dec2, _class;
649
+ const locales = {
650
+ 'en-us': locale_en_us,
651
+ 'zh-cn': locale_zh_cn
652
+ };
641
653
  let ScopeModuleAOpenapi = (_dec = Scope(), _dec2 = BeanInfo({
642
654
  module: "a-openapi"
643
655
  }), _dec(_class = _dec2(_class = class ScopeModuleAOpenapi extends BeanScopeBase {}) || _class) || _class);
644
-
656
+ function $locale(key) {
657
+ return `a-openapi::${key}`;
658
+ }
645
659
  /** scope: end */
646
660
 
661
+ function schemaRequired(params) {
662
+ params = params || $locale('ZodErrorRequired');
663
+ return function (schema) {
664
+ schema._zod.def.error = z.util.normalizeParams(params).error;
665
+ return schema;
666
+ };
667
+ }
647
668
  function schemaEmail(params) {
648
669
  return function (_schema) {
649
670
  return z.email(params);
@@ -890,6 +911,7 @@ const v = {
890
911
  strictObject: schemaStrictObject,
891
912
  looseObject: schemaLooseObject,
892
913
  // helpers
914
+ required: schemaRequired,
893
915
  email: schemaEmail,
894
916
  url: schemaUrl,
895
917
  uuid: schemaUuid,
@@ -1028,4 +1050,4 @@ const OrderBusinessBase = 1000;
1028
1050
  const OrderUnknownBase = 10000;
1029
1051
  const OrderMaxBase = 100000;
1030
1052
 
1031
- export { $schema, $schemaLazy, Api, Main, OrderBusinessBase, OrderCoreBase, OrderMaxBase, OrderUnknownBase, ScopeModuleAOpenapi, ServiceOpenapi, SummerCacheJson, SymbolRouteHandlersArgumentsMeta, SymbolRouteHandlersArgumentsValue, SymbolSchemaDynamicRefId, addSchemaDynamic, bodySchemaWrapperDefault, config, getSchemaDynamic, getSchemasDynamic, getTargetDecoratorRuleColumns, getTargetDecoratorRuleColumnsMap, getTargetDecoratorRules, makeSchemaLike, makeSchemaLikes, mergeFieldOpenapiMetadata, mergeFieldsOpenapiMetadata, prepareClassType, schemaRefCustomAdapter, v };
1053
+ export { $locale, $schema, $schemaLazy, Api, Main, OrderBusinessBase, OrderCoreBase, OrderMaxBase, OrderUnknownBase, ScopeModuleAOpenapi, ServiceOpenapi, SummerCacheJson, SymbolRouteHandlersArgumentsMeta, SymbolRouteHandlersArgumentsValue, SymbolSchemaDynamicRefId, addSchemaDynamic, bodySchemaWrapperDefault, config, getSchemaDynamic, getSchemasDynamic, getTargetDecoratorRuleColumns, getTargetDecoratorRuleColumnsMap, getTargetDecoratorRules, locales, makeSchemaLike, makeSchemaLikes, mergeFieldOpenapiMetadata, mergeFieldsOpenapiMetadata, prepareClassType, schemaRefCustomAdapter, v };
@@ -1,6 +1,7 @@
1
1
  import type { ISerializerTransformRecord, TypeSerializerTransformGetter } from 'vona-module-a-serialization';
2
2
  import type { ISchemaObjectExtensionFieldCaptcha } from '../../../types/captcha.ts';
3
3
  import { z } from 'zod';
4
+ export declare function schemaRequired(params?: string | z.core.$ZodStringParams): (schema: z.ZodType) => z.ZodType;
4
5
  export declare function schemaEmail(params?: string | z.core.$ZodEmailParams): (_schema: z.ZodString) => z.ZodEmail;
5
6
  export declare function schemaUrl(params?: string | z.core.$ZodURLParams): (_schema: z.ZodString) => z.ZodURL;
6
7
  export declare function schemaUuid(params?: string | z.core.$ZodUUIDParams): (_schema: z.ZodString) => z.ZodUUID;
@@ -1,4 +1,4 @@
1
- import { schemaBigNumber, schemaCaptcha, schemaEmail, schemaIPv4, schemaIPv6, schemaLowercase, schemaMax, schemaMin, schemaRegex, schemaSerializerExclude, schemaSerializerGetter, schemaSerializerSensitive, schemaSerializerTransform, schemaTableIdentity, schemaToLowerCase, schemaToUpperCase, schemaTrim, schemaUppercase, schemaUrl, schemaUuid } from './v/helpers.ts';
1
+ import { schemaBigNumber, schemaCaptcha, schemaEmail, schemaIPv4, schemaIPv6, schemaLowercase, schemaMax, schemaMin, schemaRegex, schemaRequired, schemaSerializerExclude, schemaSerializerGetter, schemaSerializerSensitive, schemaSerializerTransform, schemaTableIdentity, schemaToLowerCase, schemaToUpperCase, schemaTrim, schemaUppercase, schemaUrl, schemaUuid } from './v/helpers.ts';
2
2
  import { schemaDescription, schemaExample, schemaOpenapi, schemaTitle } from './v/openapi.ts';
3
3
  import { schemaArray, schemaDefault, schemaLazy, schemaLooseObject, schemaObject, schemaOptional, schemaStrictObject } from './v/system.ts';
4
4
  import { schemaZodRefine, schemaZodTransform } from './v/zod.ts';
@@ -10,6 +10,7 @@ export declare const v: {
10
10
  optional: typeof schemaOptional;
11
11
  strictObject: typeof schemaStrictObject;
12
12
  looseObject: typeof schemaLooseObject;
13
+ required: typeof schemaRequired;
13
14
  email: typeof schemaEmail;
14
15
  url: typeof schemaUrl;
15
16
  uuid: typeof schemaUuid;
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.37",
4
+ "version": "5.0.38",
5
5
  "title": "a-openapi",
6
6
  "vonaModule": {
7
7
  "capabilities": {