vona-module-a-openapi 5.0.49 → 5.0.51
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
CHANGED
|
@@ -93,6 +93,9 @@ function prepareClassType(classType) {
|
|
|
93
93
|
return isClass(classType) ? classType : cast(classType)();
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
function $makeSchema(...schemaLikes) {
|
|
97
|
+
return makeSchemaLikes(schemaLikes, undefined);
|
|
98
|
+
}
|
|
96
99
|
function makeSchemaLikes(schemaLikes, typeInit) {
|
|
97
100
|
if (!Array.isArray(schemaLikes)) schemaLikes = [schemaLikes];
|
|
98
101
|
// default schema
|
|
@@ -776,66 +779,100 @@ function schemaCaptcha(options) {
|
|
|
776
779
|
});
|
|
777
780
|
};
|
|
778
781
|
}
|
|
779
|
-
|
|
782
|
+
|
|
783
|
+
function schemaOpenapi(refId, metadata) {
|
|
784
|
+
return function (schema) {
|
|
785
|
+
return schema.openapi(refId, metadata);
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function schemaTitle(title) {
|
|
780
789
|
return function (schema) {
|
|
781
790
|
return schema.openapi({
|
|
782
|
-
|
|
791
|
+
title
|
|
783
792
|
});
|
|
784
793
|
};
|
|
785
794
|
}
|
|
786
|
-
function
|
|
795
|
+
function schemaDescription(description) {
|
|
787
796
|
return function (schema) {
|
|
788
797
|
return schema.openapi({
|
|
789
|
-
|
|
790
|
-
[serializerTransformName]: options
|
|
791
|
-
}
|
|
798
|
+
description
|
|
792
799
|
});
|
|
793
800
|
};
|
|
794
801
|
}
|
|
795
|
-
function
|
|
802
|
+
function schemaExample(example) {
|
|
796
803
|
return function (schema) {
|
|
797
804
|
return schema.openapi({
|
|
798
|
-
|
|
799
|
-
'a-serialization:sensitive': options
|
|
800
|
-
}
|
|
805
|
+
example
|
|
801
806
|
});
|
|
802
807
|
};
|
|
803
808
|
}
|
|
804
|
-
|
|
809
|
+
|
|
810
|
+
function schemaSerializerTransform(serializerTransformName, options) {
|
|
805
811
|
return function (schema) {
|
|
806
812
|
return schema.openapi({
|
|
807
813
|
serializerTransforms: {
|
|
808
|
-
|
|
809
|
-
getter
|
|
810
|
-
}
|
|
814
|
+
[serializerTransformName]: options
|
|
811
815
|
}
|
|
812
816
|
});
|
|
813
817
|
};
|
|
814
818
|
}
|
|
815
|
-
|
|
816
|
-
|
|
819
|
+
function schemaSerializerExclude(param) {
|
|
820
|
+
let options;
|
|
821
|
+
if (!param || typeof param === 'boolean') {
|
|
822
|
+
options = {
|
|
823
|
+
exclude: param
|
|
824
|
+
};
|
|
825
|
+
} else {
|
|
826
|
+
options = param;
|
|
827
|
+
}
|
|
817
828
|
return function (schema) {
|
|
818
|
-
return schema.openapi(
|
|
829
|
+
return schema.openapi({
|
|
830
|
+
serializerTransforms: {
|
|
831
|
+
'a-serialization:exclude': options
|
|
832
|
+
}
|
|
833
|
+
});
|
|
819
834
|
};
|
|
820
835
|
}
|
|
821
|
-
function
|
|
836
|
+
function schemaSerializerSensitive(options) {
|
|
822
837
|
return function (schema) {
|
|
823
838
|
return schema.openapi({
|
|
824
|
-
|
|
839
|
+
serializerTransforms: {
|
|
840
|
+
'a-serialization:sensitive': options
|
|
841
|
+
}
|
|
825
842
|
});
|
|
826
843
|
};
|
|
827
844
|
}
|
|
828
|
-
function
|
|
845
|
+
function schemaSerializerGetter(param) {
|
|
846
|
+
let options;
|
|
847
|
+
if (typeof param === 'function') {
|
|
848
|
+
options = {
|
|
849
|
+
getter: param
|
|
850
|
+
};
|
|
851
|
+
} else {
|
|
852
|
+
options = param;
|
|
853
|
+
}
|
|
829
854
|
return function (schema) {
|
|
830
855
|
return schema.openapi({
|
|
831
|
-
|
|
856
|
+
serializerTransforms: {
|
|
857
|
+
'a-serialization:getter': options
|
|
858
|
+
}
|
|
832
859
|
});
|
|
833
860
|
};
|
|
834
861
|
}
|
|
835
|
-
function
|
|
862
|
+
function schemaSerializerCustom(param) {
|
|
863
|
+
let options;
|
|
864
|
+
if (typeof param === 'function') {
|
|
865
|
+
options = {
|
|
866
|
+
custom: param
|
|
867
|
+
};
|
|
868
|
+
} else {
|
|
869
|
+
options = param;
|
|
870
|
+
}
|
|
836
871
|
return function (schema) {
|
|
837
872
|
return schema.openapi({
|
|
838
|
-
|
|
873
|
+
serializerTransforms: {
|
|
874
|
+
'a-serialization:custom': options
|
|
875
|
+
}
|
|
839
876
|
});
|
|
840
877
|
};
|
|
841
878
|
}
|
|
@@ -951,6 +988,7 @@ const v = {
|
|
|
951
988
|
serializerTransform: schemaSerializerTransform,
|
|
952
989
|
serializerSensitive: schemaSerializerSensitive,
|
|
953
990
|
serializerGetter: schemaSerializerGetter,
|
|
991
|
+
serializerCustom: schemaSerializerCustom,
|
|
954
992
|
// openapi
|
|
955
993
|
openapi: schemaOpenapi,
|
|
956
994
|
title: schemaTitle,
|
|
@@ -1069,4 +1107,4 @@ const OrderBusinessBase = 1000;
|
|
|
1069
1107
|
const OrderUnknownBase = 10000;
|
|
1070
1108
|
const OrderMaxBase = 100000;
|
|
1071
1109
|
|
|
1072
|
-
export { $locale, $schema, $schemaLazy, Api, BeanOpenapi, 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 };
|
|
1110
|
+
export { $locale, $makeSchema, $schema, $schemaLazy, Api, BeanOpenapi, 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,4 +1,5 @@
|
|
|
1
1
|
import type { SchemaLike } from 'vona-module-a-openapiutils';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
|
+
export declare function $makeSchema(...schemaLikes: SchemaLike[]): z.ZodType;
|
|
3
4
|
export declare function makeSchemaLikes<T>(schemaLikes: SchemaLike<T> | SchemaLike<T>[], typeInit: any): z.ZodType<T>;
|
|
4
5
|
export declare function makeSchemaLike<T>(schemaLike: SchemaLike<T> | undefined, schemaPrevious: z.ZodType<T>): z.ZodType<T>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ISerializerTransformRecord, TypeSerializerTransformGetter } from 'vona-module-a-serialization';
|
|
2
1
|
import type { ISchemaObjectExtensionFieldCaptcha } from '../../../types/captcha.ts';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
export declare function schemaEmail(params?: string | z.core.$ZodEmailParams): (_schema: z.ZodString) => z.ZodEmail;
|
|
@@ -16,7 +15,3 @@ export declare function schemaUppercase(params?: string | z.core.$ZodCheckUpperC
|
|
|
16
15
|
export declare function schemaRegex(regex: RegExp, params?: string | z.core.$ZodCheckRegexParams): (schema: z.ZodString) => z.ZodString;
|
|
17
16
|
export declare function schemaTableIdentity(): (_schema?: any) => z.ZodString | z.ZodNumber;
|
|
18
17
|
export declare function schemaCaptcha(options: ISchemaObjectExtensionFieldCaptcha): (schema: z.ZodType) => z.ZodType;
|
|
19
|
-
export declare function schemaSerializerExclude(): (schema: z.ZodType) => z.ZodType;
|
|
20
|
-
export declare function schemaSerializerTransform<T extends keyof ISerializerTransformRecord>(serializerTransformName: T, options?: Partial<ISerializerTransformRecord[T]>): (schema: z.ZodType) => z.ZodType;
|
|
21
|
-
export declare function schemaSerializerSensitive(options: ISerializerTransformRecord['a-serialization:sensitive']): (schema: z.ZodType) => z.ZodType;
|
|
22
|
-
export declare function schemaSerializerGetter(getter: TypeSerializerTransformGetter): (schema: z.ZodType) => z.ZodType;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ISerializerTransformOptionsCustom, ISerializerTransformOptionsExclude, ISerializerTransformOptionsGetter, ISerializerTransformRecord, TypeSerializerTransformCustom, TypeSerializerTransformGetter } from 'vona-module-a-serialization';
|
|
2
|
+
import type z from 'zod';
|
|
3
|
+
export declare function schemaSerializerTransform<T extends keyof ISerializerTransformRecord>(serializerTransformName: T, options?: Partial<ISerializerTransformRecord[T]>): (schema: z.ZodType) => z.ZodType;
|
|
4
|
+
export declare function schemaSerializerExclude(options: Partial<ISerializerTransformOptionsExclude>): any;
|
|
5
|
+
export declare function schemaSerializerExclude(exclude?: boolean): any;
|
|
6
|
+
export declare function schemaSerializerSensitive(options: ISerializerTransformRecord['a-serialization:sensitive']): (schema: z.ZodType) => z.ZodType;
|
|
7
|
+
export declare function schemaSerializerGetter(options: Partial<ISerializerTransformOptionsGetter>): any;
|
|
8
|
+
export declare function schemaSerializerGetter(getter: TypeSerializerTransformGetter): any;
|
|
9
|
+
export declare function schemaSerializerCustom(options: Partial<ISerializerTransformOptionsCustom>): any;
|
|
10
|
+
export declare function schemaSerializerCustom(getter: TypeSerializerTransformCustom): any;
|
package/dist/lib/schema/v.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { schemaCaptcha, schemaEmail, schemaIPv4, schemaIPv6, schemaLowercase, schemaMax, schemaMin, schemaRegex,
|
|
1
|
+
import { schemaCaptcha, schemaEmail, schemaIPv4, schemaIPv6, schemaLowercase, schemaMax, schemaMin, schemaRegex, schemaTableIdentity, schemaToLowerCase, schemaToUpperCase, schemaTrim, schemaUppercase, schemaUrl, schemaUuid } from './v/helpers.ts';
|
|
2
2
|
import { schemaDescription, schemaExample, schemaOpenapi, schemaTitle } from './v/openapi.ts';
|
|
3
|
+
import { schemaSerializerCustom, schemaSerializerExclude, schemaSerializerGetter, schemaSerializerSensitive, schemaSerializerTransform } from './v/serializer.ts';
|
|
3
4
|
import { schemaArray, schemaDefault, schemaLazy, schemaLooseObject, schemaObject, schemaOptional, schemaRequired, schemaStrictObject } from './v/system.ts';
|
|
4
5
|
import { schemaZodRefine, schemaZodTransform } from './v/zod.ts';
|
|
5
6
|
export declare const v: {
|
|
@@ -30,6 +31,7 @@ export declare const v: {
|
|
|
30
31
|
serializerTransform: typeof schemaSerializerTransform;
|
|
31
32
|
serializerSensitive: typeof schemaSerializerSensitive;
|
|
32
33
|
serializerGetter: typeof schemaSerializerGetter;
|
|
34
|
+
serializerCustom: typeof schemaSerializerCustom;
|
|
33
35
|
openapi: typeof schemaOpenapi;
|
|
34
36
|
title: typeof schemaTitle;
|
|
35
37
|
description: typeof schemaDescription;
|