vona-module-a-openapiutils 5.1.4 → 5.1.6
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/.metadata/locales.d.ts.map +1 -1
- package/dist/index.js +58 -183
- package/dist/index.js.map +1 -1
- package/dist/lib/decorator/api.d.ts.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/resource.d.ts +3 -0
- package/dist/lib/resource.d.ts.map +1 -0
- package/dist/lib/schema/index.d.ts +1 -0
- package/dist/lib/schema/index.d.ts.map +1 -1
- package/dist/lib/schema/makeMetadata.d.ts +2 -2
- package/dist/lib/schema/makeMetadata.d.ts.map +1 -1
- package/dist/lib/schema/makeSchemaLikes.d.ts.map +1 -1
- package/dist/lib/schema/v/filter.d.ts +1 -2
- package/dist/lib/schema/v/filter.d.ts.map +1 -1
- package/dist/lib/schema/v/helpers.d.ts.map +1 -1
- package/dist/lib/schema/v/openapi.d.ts +3 -3
- package/dist/lib/schema/v/openapi.d.ts.map +1 -1
- package/dist/lib/schema/v/serializer.d.ts.map +1 -1
- package/dist/lib/schema/v/system.d.ts +1 -1
- package/dist/lib/schema/v/system.d.ts.map +1 -1
- package/dist/lib/schema/v/utils.d.ts.map +1 -1
- package/dist/lib/schema/v/zod.d.ts.map +1 -1
- package/dist/lib/schema/v.d.ts +3 -12
- package/dist/lib/schema/v.d.ts.map +1 -1
- package/dist/lib/schema/visible.d.ts +4 -0
- package/dist/lib/schema/visible.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +3 -4
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/web.d.ts.map +1 -1
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -5
- package/src/.metadata/locales.ts +6 -1
- package/src/lib/decorator/api.ts +82 -13
- package/src/lib/index.ts +1 -0
- package/src/lib/resource.ts +5 -0
- package/src/lib/schema/index.ts +1 -0
- package/src/lib/schema/makeMetadata.ts +5 -3
- package/src/lib/schema/makeSchemaLikes.ts +23 -7
- package/src/lib/schema/v/filter.ts +36 -0
- package/src/lib/schema/v/helpers.ts +32 -7
- package/src/lib/schema/v/openapi.ts +6 -3
- package/src/lib/schema/v/serializer.ts +12 -4
- package/src/lib/schema/v/system.ts +16 -10
- package/src/lib/schema/v/utils.ts +5 -1
- package/src/lib/schema/v/zod.ts +18 -4
- package/src/lib/schema/v.ts +5 -14
- package/src/lib/schema/visible.ts +14 -0
- package/src/lib/utils.ts +15 -7
- package/src/lib/web.ts +4 -1
- package/src/types/api.ts +8 -2
- package/src/types/index.ts +0 -2
- package/dist/lib/schema/v/component.d.ts +0 -5
- package/dist/lib/schema/v/component.d.ts.map +0 -1
- package/dist/lib/schema/v/rest.d.ts +0 -9
- package/dist/lib/schema/v/rest.d.ts.map +0 -1
- package/dist/types/component.d.ts +0 -12
- package/dist/types/component.d.ts.map +0 -1
- package/dist/types/order.d.ts +0 -8
- package/dist/types/order.d.ts.map +0 -1
- package/src/lib/schema/v/component.ts +0 -78
- package/src/lib/schema/v/filter.tsx +0 -40
- package/src/lib/schema/v/rest.ts +0 -50
- package/src/types/component.ts +0 -19
- package/src/types/order.ts +0 -9
|
@@ -10,6 +10,7 @@ import type { SchemaLike } from '../../../types/decorator.ts';
|
|
|
10
10
|
import { $locale } from '../../../.metadata/locales.ts';
|
|
11
11
|
import { normalizeErrorParams } from '../../utils.ts';
|
|
12
12
|
import { $schema, $schemaLazy, makeSchemaLike } from '../makeSchemaLikes.ts';
|
|
13
|
+
import { _generalSchemaRest } from './utils.ts';
|
|
13
14
|
|
|
14
15
|
export function schemaDefault(defaultValue: any | Function) {
|
|
15
16
|
return function (schema: z.ZodType): z.ZodType {
|
|
@@ -19,7 +20,17 @@ export function schemaDefault(defaultValue: any | Function) {
|
|
|
19
20
|
|
|
20
21
|
export function schemaOptional() {
|
|
21
22
|
return function (schema: z.ZodType): z.ZodType {
|
|
22
|
-
|
|
23
|
+
const options = { required: false };
|
|
24
|
+
return _generalSchemaRest(schema.optional(), options, 'form');
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function schemaRequired(params?: string | ILocaleMagic | z.core.$ZodStringParams) {
|
|
29
|
+
const errorDefault = { error: () => $locale('ZodErrorRequired') };
|
|
30
|
+
return function (schema: z.ZodType): z.ZodType {
|
|
31
|
+
schema._zod.def.error = normalizeErrorParams(params, errorDefault).error;
|
|
32
|
+
const options = { required: true };
|
|
33
|
+
return _generalSchemaRest(schema, options, 'form');
|
|
23
34
|
};
|
|
24
35
|
}
|
|
25
36
|
|
|
@@ -35,7 +46,10 @@ export function schemaObject<T>(classType: Constructable<T>, options?: ISchemaOb
|
|
|
35
46
|
};
|
|
36
47
|
}
|
|
37
48
|
|
|
38
|
-
export function schemaArray(
|
|
49
|
+
export function schemaArray(
|
|
50
|
+
schemaLike?: SchemaLike,
|
|
51
|
+
params?: z.core.$ZodArrayParams & { separator?: string },
|
|
52
|
+
) {
|
|
39
53
|
return function (schema: z.ZodType): z.ZodType {
|
|
40
54
|
return z.preprocess(
|
|
41
55
|
val => {
|
|
@@ -62,11 +76,3 @@ export function schemaLooseObject() {
|
|
|
62
76
|
return z.looseObject(schema.shape);
|
|
63
77
|
};
|
|
64
78
|
}
|
|
65
|
-
|
|
66
|
-
export function schemaRequired(params?: string | ILocaleMagic | z.core.$ZodStringParams) {
|
|
67
|
-
const errorDefault = { error: () => $locale('ZodErrorRequired') };
|
|
68
|
-
return function (schema: z.ZodType): z.ZodType {
|
|
69
|
-
schema._zod.def.error = normalizeErrorParams(params, errorDefault).error;
|
|
70
|
-
return schema;
|
|
71
|
-
};
|
|
72
|
-
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { TypeSchemaScene } from 'vona-module-a-openapi';
|
|
2
2
|
import type z from 'zod';
|
|
3
3
|
|
|
4
|
-
export function _generalSchemaRest<T extends z.ZodType>(
|
|
4
|
+
export function _generalSchemaRest<T extends z.ZodType>(
|
|
5
|
+
schema: T,
|
|
6
|
+
options: any,
|
|
7
|
+
scene?: TypeSchemaScene,
|
|
8
|
+
) {
|
|
5
9
|
return schema.openapi(scene ? { rest: { [scene]: options } } : { rest: options });
|
|
6
10
|
}
|
package/src/lib/schema/v/zod.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
IZodRefineExecute,
|
|
3
|
+
IZodRefineRecord,
|
|
4
|
+
IZodTransformExecute,
|
|
5
|
+
IZodTransformRecord,
|
|
6
|
+
} from 'vona-module-a-zod';
|
|
2
7
|
import type z from 'zod';
|
|
3
8
|
|
|
4
9
|
import { beanFullNameFromOnionName, useApp } from 'vona';
|
|
5
10
|
|
|
6
|
-
export function schemaZodRefine<T extends keyof IZodRefineRecord>(
|
|
11
|
+
export function schemaZodRefine<T extends keyof IZodRefineRecord>(
|
|
12
|
+
zodRefineName: T,
|
|
13
|
+
options?: Partial<IZodRefineRecord[T]>,
|
|
14
|
+
) {
|
|
7
15
|
return function (schema: z.ZodType): z.ZodType {
|
|
8
16
|
return schema.superRefine(async (value, refinementCtx) => {
|
|
9
17
|
const app = useApp();
|
|
@@ -19,11 +27,17 @@ export function schemaZodRefine<T extends keyof IZodRefineRecord>(zodRefineName:
|
|
|
19
27
|
};
|
|
20
28
|
}
|
|
21
29
|
|
|
22
|
-
export function schemaZodTransform<T extends keyof IZodTransformRecord>(
|
|
30
|
+
export function schemaZodTransform<T extends keyof IZodTransformRecord>(
|
|
31
|
+
zodTransformName: T,
|
|
32
|
+
options?: Partial<IZodTransformRecord[T]>,
|
|
33
|
+
) {
|
|
23
34
|
return function (schema: z.ZodType): z.ZodType {
|
|
24
35
|
return schema.transform(async value => {
|
|
25
36
|
const app = useApp();
|
|
26
|
-
const options2 = app.bean.onion.zodTransform.getOnionOptionsDynamic(
|
|
37
|
+
const options2 = app.bean.onion.zodTransform.getOnionOptionsDynamic(
|
|
38
|
+
zodTransformName,
|
|
39
|
+
options,
|
|
40
|
+
);
|
|
27
41
|
// execute
|
|
28
42
|
const beanFullName = beanFullNameFromOnionName(zodTransformName, 'zodTransform');
|
|
29
43
|
const beanInstance = app.bean._getBean(beanFullName) as IZodTransformExecute;
|
package/src/lib/schema/v.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { schemaFilter, schemaFilterDateRange, schemaFilterTransform } from './v/filter.tsx';
|
|
1
|
+
import { schemaFilter, schemaFilterTransform } from './v/filter.ts';
|
|
3
2
|
import {
|
|
4
3
|
schemaEmail,
|
|
5
4
|
schemaIPv4,
|
|
@@ -17,7 +16,6 @@ import {
|
|
|
17
16
|
schemaUuid,
|
|
18
17
|
} from './v/helpers.ts';
|
|
19
18
|
import { schemaDescription, schemaExample, schemaOpenapi, schemaTitle } from './v/openapi.ts';
|
|
20
|
-
import { schemaCustomKey, schemaOrder, schemaRender, schemaRest, schemaVisible } from './v/rest.ts';
|
|
21
19
|
import {
|
|
22
20
|
schemaSerializerCustom,
|
|
23
21
|
schemaSerializerExclude,
|
|
@@ -61,28 +59,21 @@ export const v = {
|
|
|
61
59
|
uppercase: schemaUppercase,
|
|
62
60
|
regex: schemaRegex,
|
|
63
61
|
tableIdentity: schemaTableIdentity,
|
|
62
|
+
// serializer
|
|
64
63
|
serializerExclude: schemaSerializerExclude,
|
|
65
64
|
serializerTransform: schemaSerializerTransform,
|
|
66
65
|
serializerReplace: schemaSerializerReplace,
|
|
67
66
|
serializerGetter: schemaSerializerGetter,
|
|
68
67
|
serializerCustom: schemaSerializerCustom,
|
|
68
|
+
// filter
|
|
69
69
|
filter: schemaFilter,
|
|
70
70
|
filterTransform: schemaFilterTransform,
|
|
71
|
-
filterDateRange: schemaFilterDateRange,
|
|
72
71
|
// openapi
|
|
73
72
|
openapi: schemaOpenapi,
|
|
74
73
|
title: schemaTitle,
|
|
75
74
|
description: schemaDescription,
|
|
76
75
|
example: schemaExample,
|
|
77
|
-
// rest
|
|
78
|
-
rest: schemaRest,
|
|
79
|
-
customKey: schemaCustomKey,
|
|
80
|
-
order: schemaOrder,
|
|
81
|
-
render: schemaRender,
|
|
82
|
-
visible: schemaVisible,
|
|
83
|
-
// component
|
|
84
|
-
component: schemaComponent,
|
|
85
76
|
// zod
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
zodRefine: schemaZodRefine,
|
|
78
|
+
zodTransform: schemaZodTransform,
|
|
88
79
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TypeSchemaScene } from 'vona-module-a-openapi';
|
|
2
|
+
import type z from 'zod';
|
|
3
|
+
|
|
4
|
+
import { _generalSchemaRest } from './v/utils.ts';
|
|
5
|
+
|
|
6
|
+
export function schemaRenderVisible<T extends z.ZodType>(
|
|
7
|
+
visible?: boolean,
|
|
8
|
+
scene?: TypeSchemaScene,
|
|
9
|
+
) {
|
|
10
|
+
return function (schema: T): T {
|
|
11
|
+
const options = { visible };
|
|
12
|
+
return _generalSchemaRest(schema, options, scene);
|
|
13
|
+
};
|
|
14
|
+
}
|
package/src/lib/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Constructable, ILocaleMagic } from 'vona';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ISchemaObjectExtensionField, TypeSchemaOrderLevel } from 'vona-module-a-openapi';
|
|
3
3
|
|
|
4
4
|
import { isClass, isEmptyObject } from '@cabloy/utils';
|
|
5
5
|
import { ZodMetadata } from '@cabloy/zod-openapi';
|
|
@@ -7,12 +7,14 @@ import { appMetadata, appResource, cast, deepExtend, registerMappedClassMetadata
|
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
|
|
9
9
|
import type { TypeDecoratorRules } from '../types/decorator.ts';
|
|
10
|
-
import type { TypeSchemaOrderLevel } from '../types/order.ts';
|
|
11
10
|
|
|
12
11
|
import { OrderLevelBaseMap } from './const/database.ts';
|
|
13
12
|
import { SymbolDecoratorRule } from './const/decorator.ts';
|
|
14
13
|
|
|
15
|
-
export function getTargetDecoratorRules(
|
|
14
|
+
export function getTargetDecoratorRules(
|
|
15
|
+
target: object,
|
|
16
|
+
disableRegisterMetadata?: boolean,
|
|
17
|
+
): TypeDecoratorRules {
|
|
16
18
|
if (!disableRegisterMetadata) {
|
|
17
19
|
registerMappedClassMetadataKey(target, SymbolDecoratorRule, {
|
|
18
20
|
partialClass: (meta: z.ZodType) => {
|
|
@@ -37,20 +39,24 @@ export function getTargetDecoratorRuleColumnsMap(target: object): Record<string,
|
|
|
37
39
|
return map;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
export function
|
|
42
|
+
export function mergeDtoFieldsOpenapiMetadata(target: Constructable) {
|
|
41
43
|
// beanOptions
|
|
42
44
|
const beanOptions = appResource.getBean(target);
|
|
43
45
|
const fields = cast(beanOptions?.options)?.fields;
|
|
44
46
|
if (!fields) return;
|
|
45
47
|
for (const key in fields) {
|
|
46
|
-
const field:
|
|
48
|
+
const field: ISchemaObjectExtensionField | z.ZodType = fields[key];
|
|
47
49
|
if (!field) continue;
|
|
48
50
|
mergeFieldOpenapiMetadata(target.prototype, key, field);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
// fieldRule maybe undefined
|
|
53
|
-
export function mergeFieldOpenapiMetadata(
|
|
55
|
+
export function mergeFieldOpenapiMetadata(
|
|
56
|
+
target: object,
|
|
57
|
+
prop: string,
|
|
58
|
+
fieldRule?: ISchemaObjectExtensionField | z.ZodType,
|
|
59
|
+
): TypeDecoratorRules {
|
|
54
60
|
// rules
|
|
55
61
|
const rules = getTargetDecoratorRules(target);
|
|
56
62
|
// rule
|
|
@@ -81,7 +87,9 @@ export function mergeFieldOpenapiMetadata(target: object, prop: string, fieldRul
|
|
|
81
87
|
return rules;
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
export function prepareClassType<T>(
|
|
90
|
+
export function prepareClassType<T>(
|
|
91
|
+
classType: (() => Constructable<T>) | Constructable<T>,
|
|
92
|
+
): Constructable<T> {
|
|
85
93
|
return isClass(classType) ? (classType as Constructable<T>) : cast(classType)();
|
|
86
94
|
}
|
|
87
95
|
|
package/src/lib/web.ts
CHANGED
|
@@ -6,6 +6,9 @@ export function $apiPath<K extends keyof IApiPathRecord>(path: K): K {
|
|
|
6
6
|
return path;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function $apiPathAndCombineParamsAndQuery<K extends keyof IApiPathRecord>(
|
|
9
|
+
export function $apiPathAndCombineParamsAndQuery<K extends keyof IApiPathRecord>(
|
|
10
|
+
path: K,
|
|
11
|
+
options?: { params?: object; query?: object },
|
|
12
|
+
): string {
|
|
10
13
|
return combineParamsAndQuery(path, options);
|
|
11
14
|
}
|
package/src/types/api.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
OpenAPIObject as OpenAPIObject30,
|
|
3
|
+
SchemaObject as SchemaObject30,
|
|
4
|
+
} from 'openapi3-ts/oas30';
|
|
5
|
+
import type {
|
|
6
|
+
OpenAPIObject as OpenAPIObject31,
|
|
7
|
+
SchemaObject as SchemaObject31,
|
|
8
|
+
} from 'openapi3-ts/oas31';
|
|
3
9
|
import type { ILocaleMagic, VonaApplication } from 'vona';
|
|
4
10
|
import type z from 'zod';
|
|
5
11
|
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { TypeSchemaScene } from 'vona-module-a-openapi';
|
|
2
|
-
import type z from 'zod';
|
|
3
|
-
import type { ISchemaComponentRecord } from '../../../types/component.ts';
|
|
4
|
-
export declare function schemaComponent<K extends keyof ISchemaComponentRecord>(name: K, options?: ISchemaComponentRecord[K], scene?: TypeSchemaScene): ((schema: z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) => z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) | ((schema: z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) => z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) | ((schema: z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) => z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) | ((schema: z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) => z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) | ((schema: z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) => z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) | ((schema: z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) => z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) | ((schema: z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>) => z.ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>>);
|
|
5
|
-
//# sourceMappingURL=component.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/lib/schema/v/component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAOV,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAc1E,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,sBAAsB,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,sBAAsB,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,eAAe,ooCAE5I"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ISchemaObjectExtensionFieldRest, ISchemaObjectExtensionFieldRestScene, TypeRenderComponent, TypeSchemaScene } from 'vona-module-a-openapi';
|
|
2
|
-
import type z from 'zod';
|
|
3
|
-
import type { TypeSchemaOrderLevel } from '../../../types/order.ts';
|
|
4
|
-
export declare function schemaRest<T extends z.ZodType>(rest?: ISchemaObjectExtensionFieldRestScene | ISchemaObjectExtensionFieldRest, scene?: TypeSchemaScene): (schema: T) => T;
|
|
5
|
-
export declare function schemaCustomKey<T extends z.ZodType>(customKey: string, scene?: TypeSchemaScene): (schema: T) => T;
|
|
6
|
-
export declare function schemaOrder<T extends z.ZodType>(order: number, level?: TypeSchemaOrderLevel, scene?: TypeSchemaScene): (schema: T) => T;
|
|
7
|
-
export declare function schemaRender<T extends z.ZodType>(render: TypeRenderComponent, scene?: TypeSchemaScene): (schema: T) => T;
|
|
8
|
-
export declare function schemaVisible<T extends z.ZodType>(visible?: boolean, scene?: TypeSchemaScene): (schema: T) => T;
|
|
9
|
-
//# sourceMappingURL=rest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../../../src/lib/schema/v/rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,oCAAoC,EACpC,mBAAmB,EACnB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAKpE,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAC5C,IAAI,CAAC,EAAE,oCAAoC,GAAG,+BAA+B,EAC7E,KAAK,CAAC,EAAE,eAAe,IAEN,QAAQ,CAAC,KAAG,CAAC,CAG/B;AAED,wBAAgB,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,eAAe,IAC5E,QAAQ,CAAC,KAAG,CAAC,CAI/B;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,oBAAoB,EAAE,KAAK,CAAC,EAAE,eAAe,IAElG,QAAQ,CAAC,KAAG,CAAC,CAI/B;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,KAAK,CAAC,EAAE,eAAe,IACnF,QAAQ,CAAC,KAAG,CAAC,CAI/B;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,eAAe,IAC1E,QAAQ,CAAC,KAAG,CAAC,CAI/B"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { CurrencyOptions } from '@zhennann/currency';
|
|
2
|
-
import type { ICaptchaOptions, IResourcePickerOptions, ISelectOptions, ITextareaOptions, IToggleOptions, TypeDateFormat } from 'vona-module-a-openapi';
|
|
3
|
-
export interface ISchemaComponentRecord {
|
|
4
|
-
currency: CurrencyOptions;
|
|
5
|
-
date: TypeDateFormat;
|
|
6
|
-
captcha: ICaptchaOptions;
|
|
7
|
-
toggle: IToggleOptions;
|
|
8
|
-
select: ISelectOptions;
|
|
9
|
-
resourcePicker: IResourcePickerOptions;
|
|
10
|
-
textarea: ITextareaOptions;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=component.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/types/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,cAAc,EACf,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,eAAe,CAAC;IACzB,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,cAAc,CAAC;IACvB,cAAc,EAAE,sBAAsB,CAAC;IACvC,QAAQ,EAAE,gBAAgB,CAAC;CAC5B"}
|
package/dist/types/order.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { TypeSchemaScene } from 'vona-module-a-openapi';
|
|
2
|
-
export type TypeSchemaOrderLevel = 'core' | 'business' | 'max';
|
|
3
|
-
export interface ISchemaOrderParams {
|
|
4
|
-
order: number;
|
|
5
|
-
level?: TypeSchemaOrderLevel;
|
|
6
|
-
scene?: TypeSchemaScene;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=order.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../src/types/order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;AAE/D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { CurrencyOptions } from '@zhennann/currency';
|
|
2
|
-
import type {
|
|
3
|
-
ICaptchaOptions,
|
|
4
|
-
IResourcePickerOptions,
|
|
5
|
-
ISelectOptions,
|
|
6
|
-
ITextareaOptions,
|
|
7
|
-
IToggleOptions,
|
|
8
|
-
TypeDateFormat,
|
|
9
|
-
TypeSchemaScene,
|
|
10
|
-
} from 'vona-module-a-openapi';
|
|
11
|
-
import type z from 'zod';
|
|
12
|
-
|
|
13
|
-
import type { ISchemaComponentRecord } from '../../../types/component.ts';
|
|
14
|
-
|
|
15
|
-
import { _generalSchemaRest } from './utils.ts';
|
|
16
|
-
|
|
17
|
-
const __schemaComponents = {
|
|
18
|
-
currency: schemaCurrency,
|
|
19
|
-
date: schemaDate,
|
|
20
|
-
captcha: schemaCaptcha,
|
|
21
|
-
toggle: schemaToggle,
|
|
22
|
-
select: schemaSelect,
|
|
23
|
-
resourcePicker: schemaResourcePicker,
|
|
24
|
-
textarea: schemaTextarea,
|
|
25
|
-
} as const;
|
|
26
|
-
|
|
27
|
-
export function schemaComponent<K extends keyof ISchemaComponentRecord>(name: K, options?: ISchemaComponentRecord[K], scene?: TypeSchemaScene) {
|
|
28
|
-
return __schemaComponents[name](options as any, scene);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function schemaCurrency<T extends z.ZodType>(currency?: CurrencyOptions, scene?: TypeSchemaScene) {
|
|
32
|
-
return function (schema: T): T {
|
|
33
|
-
const options = currency !== undefined ? { render: 'currency', currency } : { render: 'currency' };
|
|
34
|
-
return _generalSchemaRest(schema, options, scene);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function schemaDate<T extends z.ZodType>(dateFormat?: TypeDateFormat, scene?: TypeSchemaScene) {
|
|
39
|
-
return function (schema: T): T {
|
|
40
|
-
const options = dateFormat !== undefined ? { render: 'date', dateFormat } : { render: 'date' };
|
|
41
|
-
return _generalSchemaRest(schema, options, scene);
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function schemaCaptcha<T extends z.ZodType>(captcha?: ICaptchaOptions, scene?: TypeSchemaScene) {
|
|
46
|
-
return function (schema: T): T {
|
|
47
|
-
const options = captcha !== undefined ? { render: 'captcha', captcha } : { render: 'captcha' };
|
|
48
|
-
return _generalSchemaRest(schema, options, scene);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function schemaToggle<T extends z.ZodType>(toggle?: IToggleOptions, scene?: TypeSchemaScene) {
|
|
53
|
-
return function (schema: T): T {
|
|
54
|
-
const options = toggle !== undefined ? { render: 'toggle', toggle } : { render: 'toggle' };
|
|
55
|
-
return _generalSchemaRest(schema, options, scene);
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function schemaSelect<T extends z.ZodType>(select?: ISelectOptions, scene?: TypeSchemaScene) {
|
|
60
|
-
return function (schema: T): T {
|
|
61
|
-
const options = select !== undefined ? { render: 'select', select } : { render: 'select' };
|
|
62
|
-
return _generalSchemaRest(schema, options, scene);
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function schemaResourcePicker<T extends z.ZodType>(resourcePicker?: IResourcePickerOptions, scene?: TypeSchemaScene) {
|
|
67
|
-
return function (schema: T): T {
|
|
68
|
-
const options = resourcePicker !== undefined ? { render: 'resourcePicker', resourcePicker } : { render: 'resourcePicker' };
|
|
69
|
-
return _generalSchemaRest(schema, options, scene);
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function schemaTextarea<T extends z.ZodType>(textarea?: ITextareaOptions, scene?: TypeSchemaScene) {
|
|
74
|
-
return function (schema: T): T {
|
|
75
|
-
const options = textarea !== undefined ? { render: 'textarea', textarea } : { render: 'textarea' };
|
|
76
|
-
return _generalSchemaRest(schema, options, scene);
|
|
77
|
-
};
|
|
78
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { IFilterTransformOptionsDateRange, IFilterTransformRecord, ISchemaObjectExtensionFieldFilter } from 'vona-module-a-web';
|
|
2
|
-
import type z from 'zod';
|
|
3
|
-
|
|
4
|
-
import React from 'react';
|
|
5
|
-
|
|
6
|
-
export function schemaFilter(options: ISchemaObjectExtensionFieldFilter) {
|
|
7
|
-
return function (schema: z.ZodType): z.ZodType {
|
|
8
|
-
return schema.openapi({
|
|
9
|
-
filter: options,
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function schemaFilterTransform<T extends keyof IFilterTransformRecord>(filterTransformName: T, options?: Partial<IFilterTransformRecord[T]>) {
|
|
15
|
-
return function (schema: z.ZodType): z.ZodType {
|
|
16
|
-
return schema.openapi({
|
|
17
|
-
filter: {
|
|
18
|
-
transform: [filterTransformName, options],
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function schemaFilterDateRange(options?: Partial<IFilterTransformOptionsDateRange>) {
|
|
25
|
-
const separator = options?.separator;
|
|
26
|
-
const DateRange = 'dateRange' as any;
|
|
27
|
-
const filterRender = separator ? <DateRange separator={separator}></DateRange> : 'dateRange';
|
|
28
|
-
return function (schema: z.ZodType): z.ZodType {
|
|
29
|
-
return schema.openapi({
|
|
30
|
-
filter: {
|
|
31
|
-
transform: ['a-web:dateRange', options],
|
|
32
|
-
},
|
|
33
|
-
rest: {
|
|
34
|
-
filter: {
|
|
35
|
-
render: filterRender,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
}
|
package/src/lib/schema/v/rest.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ISchemaObjectExtensionFieldRest,
|
|
3
|
-
ISchemaObjectExtensionFieldRestScene,
|
|
4
|
-
TypeRenderComponent,
|
|
5
|
-
TypeSchemaScene,
|
|
6
|
-
} from 'vona-module-a-openapi';
|
|
7
|
-
import type z from 'zod';
|
|
8
|
-
|
|
9
|
-
import type { TypeSchemaOrderLevel } from '../../../types/order.ts';
|
|
10
|
-
|
|
11
|
-
import { $order } from '../../utils.ts';
|
|
12
|
-
import { _generalSchemaRest } from './utils.ts';
|
|
13
|
-
|
|
14
|
-
export function schemaRest<T extends z.ZodType>(
|
|
15
|
-
rest?: ISchemaObjectExtensionFieldRestScene | ISchemaObjectExtensionFieldRest,
|
|
16
|
-
scene?: TypeSchemaScene,
|
|
17
|
-
) {
|
|
18
|
-
return function (schema: T): T {
|
|
19
|
-
return _generalSchemaRest(schema, rest, scene);
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function schemaCustomKey<T extends z.ZodType>(customKey: string, scene?: TypeSchemaScene) {
|
|
24
|
-
return function (schema: T): T {
|
|
25
|
-
const options = { customKey };
|
|
26
|
-
return _generalSchemaRest(schema, options, scene);
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function schemaOrder<T extends z.ZodType>(order: number, level?: TypeSchemaOrderLevel, scene?: TypeSchemaScene) {
|
|
31
|
-
const orderReal = $order(order, level);
|
|
32
|
-
return function (schema: T): T {
|
|
33
|
-
const options = { order: orderReal };
|
|
34
|
-
return _generalSchemaRest(schema, options, scene);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function schemaRender<T extends z.ZodType>(render: TypeRenderComponent, scene?: TypeSchemaScene) {
|
|
39
|
-
return function (schema: T): T {
|
|
40
|
-
const options = { render };
|
|
41
|
-
return _generalSchemaRest(schema, options, scene);
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function schemaVisible<T extends z.ZodType>(visible?: boolean, scene?: TypeSchemaScene) {
|
|
46
|
-
return function (schema: T): T {
|
|
47
|
-
const options = { visible };
|
|
48
|
-
return _generalSchemaRest(schema, options, scene);
|
|
49
|
-
};
|
|
50
|
-
}
|
package/src/types/component.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { CurrencyOptions } from '@zhennann/currency';
|
|
2
|
-
import type {
|
|
3
|
-
ICaptchaOptions,
|
|
4
|
-
IResourcePickerOptions,
|
|
5
|
-
ISelectOptions,
|
|
6
|
-
ITextareaOptions,
|
|
7
|
-
IToggleOptions,
|
|
8
|
-
TypeDateFormat,
|
|
9
|
-
} from 'vona-module-a-openapi';
|
|
10
|
-
|
|
11
|
-
export interface ISchemaComponentRecord {
|
|
12
|
-
currency: CurrencyOptions;
|
|
13
|
-
date: TypeDateFormat;
|
|
14
|
-
captcha: ICaptchaOptions;
|
|
15
|
-
toggle: IToggleOptions;
|
|
16
|
-
select: ISelectOptions;
|
|
17
|
-
resourcePicker: IResourcePickerOptions;
|
|
18
|
-
textarea: ITextareaOptions;
|
|
19
|
-
}
|
package/src/types/order.ts
DELETED