vona-module-a-openapi 5.0.36 → 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
|
-
|
|
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 */
|
package/dist/index.js
CHANGED
|
@@ -535,11 +535,6 @@ let ServiceOpenapi = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
|
535
535
|
let argsMeta = appMetadata.getMetadata(SymbolRouteHandlersArgumentsMeta, controller.prototype, actionKey);
|
|
536
536
|
// headers
|
|
537
537
|
const objHeaders = Object.assign({}, this._combineArgHeaders(controllerOpenApiOptions?.headers), this._combineArgHeaders(actionOpenApiOptions?.headers));
|
|
538
|
-
// public
|
|
539
|
-
const _public = actionOpenApiOptions?.public ?? controllerOpenApiOptions?.public;
|
|
540
|
-
if (!_public && !objHeaders.Authorization) {
|
|
541
|
-
objHeaders.Authorization = z.string().optional();
|
|
542
|
-
}
|
|
543
538
|
if (isEmptyObject(objHeaders)) return argsMeta;
|
|
544
539
|
// merge
|
|
545
540
|
if (!argsMeta) argsMeta = [];
|
|
@@ -609,6 +604,14 @@ function config(_app) {
|
|
|
609
604
|
};
|
|
610
605
|
}
|
|
611
606
|
|
|
607
|
+
var locale_en_us = {
|
|
608
|
+
ZodErrorRequired: 'Required'
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
var locale_zh_cn = {
|
|
612
|
+
ZodErrorRequired: '必填项'
|
|
613
|
+
};
|
|
614
|
+
|
|
612
615
|
function schemaRefCustomAdapter(_app) {
|
|
613
616
|
const registry = new OpenAPIRegistry();
|
|
614
617
|
const generator31 = new OpenApiGeneratorV31(registry.definitions);
|
|
@@ -643,12 +646,25 @@ class Main extends BeanSimple {
|
|
|
643
646
|
}
|
|
644
647
|
|
|
645
648
|
var _dec, _dec2, _class;
|
|
649
|
+
const locales = {
|
|
650
|
+
'en-us': locale_en_us,
|
|
651
|
+
'zh-cn': locale_zh_cn
|
|
652
|
+
};
|
|
646
653
|
let ScopeModuleAOpenapi = (_dec = Scope(), _dec2 = BeanInfo({
|
|
647
654
|
module: "a-openapi"
|
|
648
655
|
}), _dec(_class = _dec2(_class = class ScopeModuleAOpenapi extends BeanScopeBase {}) || _class) || _class);
|
|
649
|
-
|
|
656
|
+
function $locale(key) {
|
|
657
|
+
return `a-openapi::${key}`;
|
|
658
|
+
}
|
|
650
659
|
/** scope: end */
|
|
651
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
|
+
}
|
|
652
668
|
function schemaEmail(params) {
|
|
653
669
|
return function (_schema) {
|
|
654
670
|
return z.email(params);
|
|
@@ -895,6 +911,7 @@ const v = {
|
|
|
895
911
|
strictObject: schemaStrictObject,
|
|
896
912
|
looseObject: schemaLooseObject,
|
|
897
913
|
// helpers
|
|
914
|
+
required: schemaRequired,
|
|
898
915
|
email: schemaEmail,
|
|
899
916
|
url: schemaUrl,
|
|
900
917
|
uuid: schemaUuid,
|
|
@@ -1033,4 +1050,4 @@ const OrderBusinessBase = 1000;
|
|
|
1033
1050
|
const OrderUnknownBase = 10000;
|
|
1034
1051
|
const OrderMaxBase = 100000;
|
|
1035
1052
|
|
|
1036
|
-
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;
|
package/dist/lib/schema/v.d.ts
CHANGED
|
@@ -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;
|