vona-module-a-openapi 5.0.30 → 5.0.32
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/index.d.ts +2 -167
- package/dist/config/config.d.ts +2 -2
- package/dist/index.js +155 -57
- package/dist/lib/schema/bodySchemaWrapper.d.ts +1 -9
- package/dist/lib/schema/makeSchemaLikes.d.ts +2 -2
- package/dist/lib/schema/schema.d.ts +3 -3
- package/dist/lib/schema/v/helpers.d.ts +17 -13
- package/dist/lib/schema/v/openapi.d.ts +7 -7
- package/dist/lib/schema/v/system.d.ts +8 -6
- package/dist/lib/schema/v/zod.d.ts +4 -0
- package/dist/lib/schema/v.d.ts +16 -3
- package/dist/lib/utils.d.ts +4 -2
- package/dist/lib/zod/index.d.ts +0 -2
- package/dist/types/captcha.d.ts +4 -0
- package/dist/types/decorator.d.ts +2 -2
- package/dist/types/query.d.ts +3 -1
- package/dist/types/rest.d.ts +6 -4
- package/package.json +10 -7
- package/dist/config/locale/en-us.d.ts +0 -80
- package/dist/config/locale/zh-cn.d.ts +0 -80
- package/dist/lib/zod/errorUtil.d.ts +0 -9
- package/dist/lib/zod/errorsAdapter.d.ts +0 -2
|
@@ -55,178 +55,17 @@ export interface IModuleSummerCache {
|
|
|
55
55
|
/** config: begin */
|
|
56
56
|
export * from '../config/config.ts';
|
|
57
57
|
import type { config } from '../config/config.ts';
|
|
58
|
-
|
|
59
|
-
'en-us': {
|
|
60
|
-
ZodError_invalid_input: string;
|
|
61
|
-
ZodError_invalid_type_required: string;
|
|
62
|
-
ZodError_invalid_type_requiredDetail: string;
|
|
63
|
-
ZodError_invalid_literal: string;
|
|
64
|
-
ZodError_unrecognized_keys: string;
|
|
65
|
-
ZodError_invalid_union: string;
|
|
66
|
-
ZodError_invalid_union_discriminator: string;
|
|
67
|
-
ZodError_invalid_enum_value: string;
|
|
68
|
-
ZodError_invalid_arguments: string;
|
|
69
|
-
ZodError_invalid_return_type: string;
|
|
70
|
-
ZodError_invalid_date: string;
|
|
71
|
-
ZodError_invalid_string_includes: string;
|
|
72
|
-
ZodError_invalid_string_includes_position: string;
|
|
73
|
-
ZodError_invalid_string_startsWith: string;
|
|
74
|
-
ZodError_invalid_string_endsWith: string;
|
|
75
|
-
ZodError_invalid_string_validation: string;
|
|
76
|
-
ZodError_invalid_string: string;
|
|
77
|
-
ZodError_too_small_array_exact: string;
|
|
78
|
-
ZodError_too_small_array_inclusive: string;
|
|
79
|
-
ZodError_too_small_array_not_inclusive: string;
|
|
80
|
-
ZodError_too_small_string_exact: string;
|
|
81
|
-
ZodError_too_small_string_inclusive: string;
|
|
82
|
-
ZodError_too_small_string_not_inclusive: string;
|
|
83
|
-
ZodError_too_small_number_exact: string;
|
|
84
|
-
ZodError_too_small_number_inclusive: string;
|
|
85
|
-
ZodError_too_small_number_not_inclusive: string;
|
|
86
|
-
ZodError_too_small_set_exact: string;
|
|
87
|
-
ZodError_too_small_set_inclusive: string;
|
|
88
|
-
ZodError_too_small_set_not_inclusive: string;
|
|
89
|
-
ZodError_too_small_date_exact: string;
|
|
90
|
-
ZodError_too_small_date_inclusive: string;
|
|
91
|
-
ZodError_too_small_date_not_inclusive: string;
|
|
92
|
-
ZodError_too_big_array_exact: string;
|
|
93
|
-
ZodError_too_big_array_inclusive: string;
|
|
94
|
-
ZodError_too_big_array_not_inclusive: string;
|
|
95
|
-
ZodError_too_big_string_exact: string;
|
|
96
|
-
ZodError_too_big_string_inclusive: string;
|
|
97
|
-
ZodError_too_big_string_not_inclusive: string;
|
|
98
|
-
ZodError_too_big_number_exact: string;
|
|
99
|
-
ZodError_too_big_number_inclusive: string;
|
|
100
|
-
ZodError_too_big_number_not_inclusive: string;
|
|
101
|
-
ZodError_too_big_set_exact: string;
|
|
102
|
-
ZodError_too_big_set_inclusive: string;
|
|
103
|
-
ZodError_too_big_set_not_inclusive: string;
|
|
104
|
-
ZodError_too_big_date_exact: string;
|
|
105
|
-
ZodError_too_big_date_inclusive: string;
|
|
106
|
-
ZodError_too_big_date_not_inclusive: string;
|
|
107
|
-
ZodError_custom: string;
|
|
108
|
-
ZodError_invalid_intersection_types: string;
|
|
109
|
-
ZodError_not_multiple_of: string;
|
|
110
|
-
ZodError_not_finite: string;
|
|
111
|
-
ZodError_validations_email: string;
|
|
112
|
-
ZodError_validations_url: string;
|
|
113
|
-
ZodError_validations_uuid: string;
|
|
114
|
-
ZodError_validations_cuid: string;
|
|
115
|
-
ZodError_validations_regex: string;
|
|
116
|
-
ZodError_validations_datetime: string;
|
|
117
|
-
ZodError_types_function: string;
|
|
118
|
-
ZodError_types_number: string;
|
|
119
|
-
ZodError_types_string: string;
|
|
120
|
-
ZodError_types_nan: string;
|
|
121
|
-
ZodError_types_integer: string;
|
|
122
|
-
ZodError_types_float: string;
|
|
123
|
-
ZodError_types_boolean: string;
|
|
124
|
-
ZodError_types_date: string;
|
|
125
|
-
ZodError_types_bigint: string;
|
|
126
|
-
ZodError_types_undefined: string;
|
|
127
|
-
ZodError_types_symbol: string;
|
|
128
|
-
ZodError_types_null: string;
|
|
129
|
-
ZodError_types_array: string;
|
|
130
|
-
ZodError_types_object: string;
|
|
131
|
-
ZodError_types_unknown: string;
|
|
132
|
-
ZodError_types_promise: string;
|
|
133
|
-
ZodError_types_void: string;
|
|
134
|
-
ZodError_types_never: string;
|
|
135
|
-
ZodError_types_map: string;
|
|
136
|
-
ZodError_types_set: string;
|
|
137
|
-
};
|
|
138
|
-
'zh-cn': {
|
|
139
|
-
ZodError_invalid_input: string;
|
|
140
|
-
ZodError_invalid_type_required: string;
|
|
141
|
-
ZodError_invalid_type_requiredDetail: string;
|
|
142
|
-
ZodError_invalid_literal: string;
|
|
143
|
-
ZodError_unrecognized_keys: string;
|
|
144
|
-
ZodError_invalid_union: string;
|
|
145
|
-
ZodError_invalid_union_discriminator: string;
|
|
146
|
-
ZodError_invalid_enum_value: string;
|
|
147
|
-
ZodError_invalid_arguments: string;
|
|
148
|
-
ZodError_invalid_return_type: string;
|
|
149
|
-
ZodError_invalid_date: string;
|
|
150
|
-
ZodError_invalid_string_includes: string;
|
|
151
|
-
ZodError_invalid_string_includes_position: string;
|
|
152
|
-
ZodError_invalid_string_startsWith: string;
|
|
153
|
-
ZodError_invalid_string_endsWith: string;
|
|
154
|
-
ZodError_invalid_string_validation: string;
|
|
155
|
-
ZodError_invalid_string: string;
|
|
156
|
-
ZodError_too_small_array_exact: string;
|
|
157
|
-
ZodError_too_small_array_inclusive: string;
|
|
158
|
-
ZodError_too_small_array_not_inclusive: string;
|
|
159
|
-
ZodError_too_small_string_exact: string;
|
|
160
|
-
ZodError_too_small_string_inclusive: string;
|
|
161
|
-
ZodError_too_small_string_not_inclusive: string;
|
|
162
|
-
ZodError_too_small_number_exact: string;
|
|
163
|
-
ZodError_too_small_number_inclusive: string;
|
|
164
|
-
ZodError_too_small_number_not_inclusive: string;
|
|
165
|
-
ZodError_too_small_set_exact: string;
|
|
166
|
-
ZodError_too_small_set_inclusive: string;
|
|
167
|
-
ZodError_too_small_set_not_inclusive: string;
|
|
168
|
-
ZodError_too_small_date_exact: string;
|
|
169
|
-
ZodError_too_small_date_inclusive: string;
|
|
170
|
-
ZodError_too_small_date_not_inclusive: string;
|
|
171
|
-
ZodError_too_big_array_exact: string;
|
|
172
|
-
ZodError_too_big_array_inclusive: string;
|
|
173
|
-
ZodError_too_big_array_not_inclusive: string;
|
|
174
|
-
ZodError_too_big_string_exact: string;
|
|
175
|
-
ZodError_too_big_string_inclusive: string;
|
|
176
|
-
ZodError_too_big_string_not_inclusive: string;
|
|
177
|
-
ZodError_too_big_number_exact: string;
|
|
178
|
-
ZodError_too_big_number_inclusive: string;
|
|
179
|
-
ZodError_too_big_number_not_inclusive: string;
|
|
180
|
-
ZodError_too_big_set_exact: string;
|
|
181
|
-
ZodError_too_big_set_inclusive: string;
|
|
182
|
-
ZodError_too_big_set_not_inclusive: string;
|
|
183
|
-
ZodError_too_big_date_exact: string;
|
|
184
|
-
ZodError_too_big_date_inclusive: string;
|
|
185
|
-
ZodError_too_big_date_not_inclusive: string;
|
|
186
|
-
ZodError_custom: string;
|
|
187
|
-
ZodError_invalid_intersection_types: string;
|
|
188
|
-
ZodError_not_multiple_of: string;
|
|
189
|
-
ZodError_not_finite: string;
|
|
190
|
-
ZodError_validations_email: string;
|
|
191
|
-
ZodError_validations_url: string;
|
|
192
|
-
ZodError_validations_uuid: string;
|
|
193
|
-
ZodError_validations_cuid: string;
|
|
194
|
-
ZodError_validations_regex: string;
|
|
195
|
-
ZodError_validations_datetime: string;
|
|
196
|
-
ZodError_types_function: string;
|
|
197
|
-
ZodError_types_number: string;
|
|
198
|
-
ZodError_types_string: string;
|
|
199
|
-
ZodError_types_nan: string;
|
|
200
|
-
ZodError_types_integer: string;
|
|
201
|
-
ZodError_types_float: string;
|
|
202
|
-
ZodError_types_boolean: string;
|
|
203
|
-
ZodError_types_date: string;
|
|
204
|
-
ZodError_types_bigint: string;
|
|
205
|
-
ZodError_types_undefined: string;
|
|
206
|
-
ZodError_types_symbol: string;
|
|
207
|
-
ZodError_types_null: string;
|
|
208
|
-
ZodError_types_array: string;
|
|
209
|
-
ZodError_types_object: string;
|
|
210
|
-
ZodError_types_unknown: string;
|
|
211
|
-
ZodError_types_promise: string;
|
|
212
|
-
ZodError_types_void: string;
|
|
213
|
-
ZodError_types_never: string;
|
|
214
|
-
ZodError_types_map: string;
|
|
215
|
-
ZodError_types_set: string;
|
|
216
|
-
};
|
|
217
|
-
};
|
|
218
|
-
/** locale: end */
|
|
58
|
+
/** config: end */
|
|
219
59
|
/** main: begin */
|
|
220
60
|
export * from '../main.ts';
|
|
221
61
|
/** main: end */
|
|
222
62
|
/** scope: begin */
|
|
223
|
-
import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig
|
|
63
|
+
import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig } from 'vona';
|
|
224
64
|
export declare class ScopeModuleAOpenapi extends BeanScopeBase {
|
|
225
65
|
}
|
|
226
66
|
export interface ScopeModuleAOpenapi {
|
|
227
67
|
util: BeanScopeUtil;
|
|
228
68
|
config: TypeModuleConfig<typeof config>;
|
|
229
|
-
locale: TypeModuleLocales<(typeof locales)[TypeLocaleBase]>;
|
|
230
69
|
service: IModuleService;
|
|
231
70
|
summerCache: IModuleSummerCache;
|
|
232
71
|
}
|
|
@@ -241,9 +80,5 @@ declare module 'vona' {
|
|
|
241
80
|
interface IBeanScopeConfig {
|
|
242
81
|
'a-openapi': ReturnType<typeof config>;
|
|
243
82
|
}
|
|
244
|
-
interface IBeanScopeLocale {
|
|
245
|
-
'a-openapi': (typeof locales)[TypeLocaleBase];
|
|
246
|
-
}
|
|
247
83
|
}
|
|
248
|
-
export declare function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): `a-openapi::${K}`;
|
|
249
84
|
/** scope: end */
|
package/dist/config/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { OpenAPIObjectConfig as OpenAPIObjectConfigV30 } from '@
|
|
2
|
-
import type { OpenAPIObjectConfigV31 } from '@
|
|
1
|
+
import type { OpenAPIObjectConfig as OpenAPIObjectConfigV30 } from '@cabloy/zod-to-openapi/dist/v3.0/openapi-generator.ts';
|
|
2
|
+
import type { OpenAPIObjectConfigV31 } from '@cabloy/zod-to-openapi/dist/v3.1/openapi-generator.ts';
|
|
3
3
|
import type { VonaApplication } from 'vona';
|
|
4
4
|
import type { TypeOpenApiVersion, TypeSecuritySchemes } from 'vona-module-a-openapiutils';
|
|
5
5
|
export declare function config(_app: VonaApplication): {
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { registerMappedClassMetadataKey, appMetadata, appResource, cast, deepExtend, BeanInfo, BeanBase, LocaleModuleNameSeparator, HttpStatus, BeanSimple, BeanScopeBase, useApp } from 'vona';
|
|
2
|
-
import { OpenApiGeneratorV3, OpenApiGeneratorV31, OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
|
1
|
+
import { registerMappedClassMetadataKey, appMetadata, appResource, cast, deepExtend, BeanInfo, BeanBase, LocaleModuleNameSeparator, HttpStatus, BeanSimple, BeanScopeBase, useApp, beanFullNameFromOnionName } from 'vona';
|
|
3
2
|
import * as ModuleInfo from '@cabloy/module-info';
|
|
4
3
|
import { isClass, isEmptyObject, isNil } from '@cabloy/utils';
|
|
5
4
|
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
6
|
-
import {
|
|
5
|
+
import { getInnerTypeName, coerceWithNil } from '@cabloy/zod-query';
|
|
6
|
+
import { OpenApiGeneratorV3, OpenApiGeneratorV31, OpenAPIRegistry } from '@cabloy/zod-to-openapi';
|
|
7
7
|
import { Service, Scope } from 'vona-module-a-bean';
|
|
8
8
|
import { Caching } from 'vona-module-a-caching';
|
|
9
|
-
import { SymbolDecoratorRule,
|
|
9
|
+
import { SymbolDecoratorRule, SymbolOpenApiOptions } from 'vona-module-a-openapiutils';
|
|
10
10
|
import { SymbolRequestMappingHandler } from 'vona-module-a-web';
|
|
11
11
|
import { z } from 'zod';
|
|
12
|
+
import { ZodMetadata } from '@cabloy/zod-openapi';
|
|
12
13
|
import { SummerCache, BeanSummerCacheBase } from 'vona-module-a-summer';
|
|
13
|
-
import { locales as locales$1, setErrorMapDefault, setErrorMapSchema } from '@cabloy/zod-errors-custom';
|
|
14
14
|
import 'openapi3-ts/oas30';
|
|
15
15
|
import 'openapi3-ts/oas31';
|
|
16
16
|
|
|
@@ -31,17 +31,27 @@ function bodySchemaWrapperDefault(bodySchema) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function getTargetDecoratorRules(target) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
function getTargetDecoratorRules(target, disableRegisterMetadata) {
|
|
35
|
+
if (!disableRegisterMetadata) {
|
|
36
|
+
registerMappedClassMetadataKey(target, SymbolDecoratorRule, {
|
|
37
|
+
partialClass: meta => {
|
|
38
|
+
return meta.optional();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
40
42
|
return appMetadata.getOwnMetadataMap(true, SymbolDecoratorRule, target);
|
|
41
43
|
}
|
|
42
44
|
function getTargetDecoratorRuleColumns(target) {
|
|
43
|
-
|
|
44
|
-
return
|
|
45
|
+
const rules = getTargetDecoratorRules(target, true);
|
|
46
|
+
return Object.keys(rules);
|
|
47
|
+
}
|
|
48
|
+
function getTargetDecoratorRuleColumnsMap(target) {
|
|
49
|
+
const columns = getTargetDecoratorRuleColumns(target);
|
|
50
|
+
const map = {};
|
|
51
|
+
for (const column of columns) {
|
|
52
|
+
map[column] = column;
|
|
53
|
+
}
|
|
54
|
+
return map;
|
|
45
55
|
}
|
|
46
56
|
function mergeFieldsOpenapiMetadata(target) {
|
|
47
57
|
// rules
|
|
@@ -54,13 +64,15 @@ function mergeFieldsOpenapiMetadata(target) {
|
|
|
54
64
|
const field = fields[key];
|
|
55
65
|
if (!field) continue;
|
|
56
66
|
const schemaCurrent = rules[key];
|
|
67
|
+
const metadataCurrent = schemaCurrent ? ZodMetadata.getOpenapiMetadata(schemaCurrent) : undefined;
|
|
57
68
|
if (Object.prototype.hasOwnProperty.call(field, 'parseAsync')) {
|
|
58
69
|
const schema = field;
|
|
59
|
-
|
|
70
|
+
const metadataCustom = ZodMetadata.getOpenapiMetadata(schema);
|
|
71
|
+
rules[key] = schema.openapi(deepExtend({}, metadataCurrent, metadataCustom));
|
|
60
72
|
} else {
|
|
61
73
|
// use deepExtend for sure strict
|
|
62
74
|
if (schemaCurrent) {
|
|
63
|
-
rules[key] = schemaCurrent.openapi(deepExtend({},
|
|
75
|
+
rules[key] = schemaCurrent.openapi(deepExtend({}, metadataCurrent, field));
|
|
64
76
|
} else {
|
|
65
77
|
rules[key] = z.any().openapi(deepExtend({}, field));
|
|
66
78
|
}
|
|
@@ -72,6 +84,7 @@ function prepareClassType(classType) {
|
|
|
72
84
|
}
|
|
73
85
|
|
|
74
86
|
function makeSchemaLikes(schemaLikes, typeInit) {
|
|
87
|
+
if (!Array.isArray(schemaLikes)) schemaLikes = [schemaLikes];
|
|
75
88
|
// default schema
|
|
76
89
|
let argSchema = $schema(typeInit);
|
|
77
90
|
// loop
|
|
@@ -133,6 +146,10 @@ function $schema(classType, options) {
|
|
|
133
146
|
// static
|
|
134
147
|
const beanOptions = appResource.getBean(classType);
|
|
135
148
|
if (beanOptions) {
|
|
149
|
+
const pipes = cast(beanOptions.options)?.pipes;
|
|
150
|
+
if (pipes) {
|
|
151
|
+
schema = makeSchemaLikes(pipes, schema);
|
|
152
|
+
}
|
|
136
153
|
const openapi = cast(beanOptions.options)?.openapi;
|
|
137
154
|
schema = schema.openapi(beanOptions.beanFullName, openapi);
|
|
138
155
|
}
|
|
@@ -152,8 +169,8 @@ function _createSchemaLazy(schemaLikes) {
|
|
|
152
169
|
}
|
|
153
170
|
function _createSchemaObject(rules, options) {
|
|
154
171
|
let schema = z.object(rules);
|
|
155
|
-
if (options?.
|
|
156
|
-
if (options?.strict) schema = schema.
|
|
172
|
+
if (options?.loose) schema = z.looseObject(schema.shape);
|
|
173
|
+
if (options?.strict) schema = z.strictObject(schema.shape);
|
|
157
174
|
return schema;
|
|
158
175
|
}
|
|
159
176
|
|
|
@@ -429,7 +446,7 @@ let ServiceOpenapi = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
|
429
446
|
}
|
|
430
447
|
if (!schema) continue;
|
|
431
448
|
// check schema
|
|
432
|
-
if (
|
|
449
|
+
if (getInnerTypeName(schema) === 'any') {
|
|
433
450
|
throw new Error(`Invalid Openapi argument type: ${info.relativeName}:${controller.name}.${actionKey}#${argumentType}`);
|
|
434
451
|
}
|
|
435
452
|
// record
|
|
@@ -566,19 +583,6 @@ function config(_app) {
|
|
|
566
583
|
};
|
|
567
584
|
}
|
|
568
585
|
|
|
569
|
-
var locale_en_us = locales$1['en-us'];
|
|
570
|
-
|
|
571
|
-
var locale_zh_cn = locales$1['zh-cn'];
|
|
572
|
-
|
|
573
|
-
function errorsAdapter(app) {
|
|
574
|
-
setErrorMapDefault((text, ...args) => {
|
|
575
|
-
return app.meta.text(text, ...args);
|
|
576
|
-
});
|
|
577
|
-
setErrorMapSchema((text, ...args) => {
|
|
578
|
-
return app.meta.text(text, ...args);
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
|
|
582
586
|
function schemaRefCustomAdapter(_app) {
|
|
583
587
|
const registry = new OpenAPIRegistry();
|
|
584
588
|
const generator31 = new OpenApiGeneratorV31(registry.definitions);
|
|
@@ -610,23 +614,16 @@ function _patchGenerator(generator) {
|
|
|
610
614
|
class Main extends BeanSimple {
|
|
611
615
|
async moduleLoading() {}
|
|
612
616
|
async moduleLoaded() {
|
|
613
|
-
errorsAdapter(this.app);
|
|
614
617
|
schemaRefCustomAdapter(this.app);
|
|
615
618
|
}
|
|
616
619
|
async configLoaded(_config) {}
|
|
617
620
|
}
|
|
618
621
|
|
|
619
622
|
var _dec, _dec2, _class;
|
|
620
|
-
const locales = {
|
|
621
|
-
'en-us': locale_en_us,
|
|
622
|
-
'zh-cn': locale_zh_cn
|
|
623
|
-
};
|
|
624
623
|
let ScopeModuleAOpenapi = (_dec = Scope(), _dec2 = BeanInfo({
|
|
625
624
|
module: "a-openapi"
|
|
626
625
|
}), _dec(_class = _dec2(_class = class ScopeModuleAOpenapi extends BeanScopeBase {}) || _class) || _class);
|
|
627
|
-
|
|
628
|
-
return `a-openapi::${key}`;
|
|
629
|
-
}
|
|
626
|
+
|
|
630
627
|
/** scope: end */
|
|
631
628
|
|
|
632
629
|
function Field(...schemaLikes) {
|
|
@@ -636,9 +633,6 @@ function Field(...schemaLikes) {
|
|
|
636
633
|
// rule
|
|
637
634
|
const metaType = appMetadata.getDesignType(target, prop);
|
|
638
635
|
rules[prop] = makeSchemaLikes(schemaLikes, metaType);
|
|
639
|
-
//
|
|
640
|
-
const columns = getTargetDecoratorRuleColumns(target);
|
|
641
|
-
columns[prop] = prop;
|
|
642
636
|
};
|
|
643
637
|
}
|
|
644
638
|
|
|
@@ -734,34 +728,77 @@ const Api = {
|
|
|
734
728
|
setHeader
|
|
735
729
|
};
|
|
736
730
|
|
|
737
|
-
function schemaEmail(
|
|
731
|
+
function schemaEmail(params) {
|
|
732
|
+
return function (_schema) {
|
|
733
|
+
return z.email(params);
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
function schemaUrl(params) {
|
|
737
|
+
return function (_schema) {
|
|
738
|
+
return z.url(params);
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
function schemaUuid(params) {
|
|
742
|
+
return function (_schema) {
|
|
743
|
+
return z.uuid(params);
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
function schemaIPv4(params) {
|
|
747
|
+
return function (_schema) {
|
|
748
|
+
return z.ipv4(params);
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
function schemaIPv6(params) {
|
|
752
|
+
return function (_schema) {
|
|
753
|
+
return z.ipv6(params);
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
function schemaMin(min, params) {
|
|
738
757
|
return function (schema) {
|
|
739
|
-
|
|
758
|
+
if (schema.type === 'string') {
|
|
759
|
+
return schema.min(min, params);
|
|
760
|
+
} else {
|
|
761
|
+
return schema.min(min, params);
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
function schemaMax(max, params) {
|
|
766
|
+
return function (schema) {
|
|
767
|
+
if (schema.type === 'string') {
|
|
768
|
+
return schema.max(max, params);
|
|
769
|
+
} else {
|
|
770
|
+
return schema.max(max, params);
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
function schemaTrim() {
|
|
775
|
+
return function (schema) {
|
|
776
|
+
return schema.trim();
|
|
740
777
|
};
|
|
741
778
|
}
|
|
742
|
-
function
|
|
779
|
+
function schemaToLowerCase() {
|
|
743
780
|
return function (schema) {
|
|
744
|
-
return schema.
|
|
781
|
+
return schema.toLowerCase();
|
|
745
782
|
};
|
|
746
783
|
}
|
|
747
|
-
function
|
|
784
|
+
function schemaToUpperCase() {
|
|
748
785
|
return function (schema) {
|
|
749
|
-
return schema.
|
|
786
|
+
return schema.toUpperCase();
|
|
750
787
|
};
|
|
751
788
|
}
|
|
752
|
-
function
|
|
789
|
+
function schemaLowercase(params) {
|
|
753
790
|
return function (schema) {
|
|
754
|
-
return schema.
|
|
791
|
+
return schema.lowercase(params);
|
|
755
792
|
};
|
|
756
793
|
}
|
|
757
|
-
function
|
|
794
|
+
function schemaUppercase(params) {
|
|
758
795
|
return function (schema) {
|
|
759
|
-
return schema.
|
|
796
|
+
return schema.uppercase(params);
|
|
760
797
|
};
|
|
761
798
|
}
|
|
762
|
-
function
|
|
799
|
+
function schemaRegex(regex, params) {
|
|
763
800
|
return function (schema) {
|
|
764
|
-
return schema.
|
|
801
|
+
return schema.regex(regex, params);
|
|
765
802
|
};
|
|
766
803
|
}
|
|
767
804
|
function schemaTableIdentity() {
|
|
@@ -782,6 +819,13 @@ function schemaBigNumber() {
|
|
|
782
819
|
return z.union([z.string(), z.number()]);
|
|
783
820
|
};
|
|
784
821
|
}
|
|
822
|
+
function schemaCaptcha(options) {
|
|
823
|
+
return function (schema) {
|
|
824
|
+
return schema.openapi({
|
|
825
|
+
captcha: options
|
|
826
|
+
});
|
|
827
|
+
};
|
|
828
|
+
}
|
|
785
829
|
|
|
786
830
|
function schemaOpenapi(refId, metadata) {
|
|
787
831
|
return function (schema) {
|
|
@@ -843,6 +887,47 @@ function schemaArray(schemaLike, params) {
|
|
|
843
887
|
);
|
|
844
888
|
};
|
|
845
889
|
}
|
|
890
|
+
function schemaStrictObject() {
|
|
891
|
+
return function (schema) {
|
|
892
|
+
return z.strictObject(schema.shape);
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
function schemaLooseObject() {
|
|
896
|
+
return function (schema) {
|
|
897
|
+
return z.looseObject(schema.shape);
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
function schemaZodRefine(zodRefineName, options) {
|
|
902
|
+
return function (schema) {
|
|
903
|
+
return schema.superRefine(async (value, refinementCtx) => {
|
|
904
|
+
const app = useApp();
|
|
905
|
+
const options2 = app.bean.onion.zodRefine.getOnionOptionsDynamic(zodRefineName, options);
|
|
906
|
+
// execute
|
|
907
|
+
const beanFullName = beanFullNameFromOnionName(zodRefineName, 'zodRefine');
|
|
908
|
+
const beanInstance = app.bean._getBean(beanFullName);
|
|
909
|
+
if (!beanInstance) {
|
|
910
|
+
throw new Error(`zodRefine bean not found: ${beanFullName}`);
|
|
911
|
+
}
|
|
912
|
+
return await beanInstance.execute(value, refinementCtx, options2);
|
|
913
|
+
});
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
function schemaZodTransform(zodTransformName, options) {
|
|
917
|
+
return function (schema) {
|
|
918
|
+
return schema.transform(async value => {
|
|
919
|
+
const app = useApp();
|
|
920
|
+
const options2 = app.bean.onion.zodTransform.getOnionOptionsDynamic(zodTransformName, options);
|
|
921
|
+
// execute
|
|
922
|
+
const beanFullName = beanFullNameFromOnionName(zodTransformName, 'zodTransform');
|
|
923
|
+
const beanInstance = app.bean._getBean(beanFullName);
|
|
924
|
+
if (!beanInstance) {
|
|
925
|
+
throw new Error(`zodTransform bean not found: ${beanFullName}`);
|
|
926
|
+
}
|
|
927
|
+
return await beanInstance.execute(value, options2);
|
|
928
|
+
});
|
|
929
|
+
};
|
|
930
|
+
}
|
|
846
931
|
|
|
847
932
|
const v = {
|
|
848
933
|
lazy: schemaLazy,
|
|
@@ -850,20 +935,33 @@ const v = {
|
|
|
850
935
|
default: schemaDefault,
|
|
851
936
|
object: schemaObject,
|
|
852
937
|
optional: schemaOptional,
|
|
938
|
+
strictObject: schemaStrictObject,
|
|
939
|
+
looseObject: schemaLooseObject,
|
|
853
940
|
// helpers
|
|
854
941
|
email: schemaEmail,
|
|
855
942
|
url: schemaUrl,
|
|
856
943
|
uuid: schemaUuid,
|
|
857
|
-
|
|
944
|
+
ipv4: schemaIPv4,
|
|
945
|
+
ipv6: schemaIPv6,
|
|
858
946
|
min: schemaMin,
|
|
859
947
|
max: schemaMax,
|
|
948
|
+
trim: schemaTrim,
|
|
949
|
+
toLowerCase: schemaToLowerCase,
|
|
950
|
+
toUpperCase: schemaToUpperCase,
|
|
951
|
+
lowercase: schemaLowercase,
|
|
952
|
+
uppercase: schemaUppercase,
|
|
953
|
+
regex: schemaRegex,
|
|
860
954
|
tableIdentity: schemaTableIdentity,
|
|
861
955
|
bigNumber: schemaBigNumber,
|
|
956
|
+
captcha: schemaCaptcha,
|
|
862
957
|
// openapi
|
|
863
958
|
openapi: schemaOpenapi,
|
|
864
959
|
title: schemaTitle,
|
|
865
960
|
description: schemaDescription,
|
|
866
|
-
example: schemaExample
|
|
961
|
+
example: schemaExample,
|
|
962
|
+
// zod
|
|
963
|
+
refine: schemaZodRefine,
|
|
964
|
+
transform: schemaZodTransform
|
|
867
965
|
};
|
|
868
966
|
|
|
869
967
|
const OrderCoreBase = 100;
|
|
@@ -871,4 +969,4 @@ const OrderBusinessBase = 1000;
|
|
|
871
969
|
const OrderUnknownBase = 10000;
|
|
872
970
|
const OrderMaxBase = 100000;
|
|
873
971
|
|
|
874
|
-
export { $
|
|
972
|
+
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, mergeFieldsOpenapiMetadata, prepareClassType, schemaRefCustomAdapter, v };
|
|
@@ -3,12 +3,4 @@ export declare function bodySchemaWrapperDefault(bodySchema: any): z.ZodObject<{
|
|
|
3
3
|
code: z.ZodString;
|
|
4
4
|
message: z.ZodString;
|
|
5
5
|
data: any;
|
|
6
|
-
},
|
|
7
|
-
message: string;
|
|
8
|
-
code: string;
|
|
9
|
-
data?: any;
|
|
10
|
-
}, {
|
|
11
|
-
message: string;
|
|
12
|
-
code: string;
|
|
13
|
-
data?: any;
|
|
14
|
-
}>;
|
|
6
|
+
}, z.core.$strip>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SchemaLike } from 'vona-module-a-openapiutils';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
|
-
export declare function makeSchemaLikes(schemaLikes: SchemaLike[], typeInit: any): z.
|
|
4
|
-
export declare function makeSchemaLike(schemaLike: SchemaLike | undefined, schemaPrevious: z.
|
|
3
|
+
export declare function makeSchemaLikes<T>(schemaLikes: SchemaLike<T> | SchemaLike<T>[], typeInit: any): z.ZodType<T>;
|
|
4
|
+
export declare function makeSchemaLike<T>(schemaLike: SchemaLike<T> | undefined, schemaPrevious: z.ZodType<T>): z.ZodType<T>;
|
|
@@ -2,12 +2,12 @@ import type { Constructable } from 'vona';
|
|
|
2
2
|
import type { SchemaLike } from 'vona-module-a-openapiutils';
|
|
3
3
|
import type { ISchemaObjectOptions } from '../../types/decorator.ts';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
export declare function $schema(schemaLike: z.
|
|
5
|
+
export declare function $schema<T>(schemaLike: z.ZodType<T>): z.ZodType<T>;
|
|
6
6
|
export declare function $schema(classType: StringConstructor): z.ZodString;
|
|
7
7
|
export declare function $schema(classType: NumberConstructor): z.ZodNumber;
|
|
8
8
|
export declare function $schema(classType: BooleanConstructor): z.ZodBoolean;
|
|
9
9
|
export declare function $schema(classType: DateConstructor): z.ZodDate;
|
|
10
10
|
export declare function $schema(classType: BigIntConstructor): z.ZodBigInt;
|
|
11
11
|
export declare function $schema(classType: ArrayConstructor): z.ZodArray<z.ZodAny>;
|
|
12
|
-
export declare function $schema<T>(classType: Constructable<T>, options?: ISchemaObjectOptions): z.
|
|
13
|
-
export declare function $schemaLazy<T>(...schemaLikes: SchemaLike[]): z.
|
|
12
|
+
export declare function $schema<T>(classType: Constructable<T>, options?: ISchemaObjectOptions): z.ZodType<T>;
|
|
13
|
+
export declare function $schemaLazy<T>(...schemaLikes: SchemaLike<T>[]): z.ZodType<T>;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { errorUtil } from '../../zod/errorUtil.ts';
|
|
1
|
+
import type { ISchemaObjectExtensionFieldCaptcha } from '../../../types/captcha.ts';
|
|
3
2
|
import { z } from 'zod';
|
|
4
|
-
export declare function schemaEmail(
|
|
5
|
-
export declare function schemaUrl(
|
|
6
|
-
export declare function schemaUuid(
|
|
7
|
-
export declare function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
3
|
+
export declare function schemaEmail(params?: string | z.core.$ZodEmailParams): (_schema: z.ZodString) => z.ZodEmail;
|
|
4
|
+
export declare function schemaUrl(params?: string | z.core.$ZodURLParams): (_schema: z.ZodString) => z.ZodURL;
|
|
5
|
+
export declare function schemaUuid(params?: string | z.core.$ZodUUIDParams): (_schema: z.ZodString) => z.ZodUUID;
|
|
6
|
+
export declare function schemaIPv4(params?: string | z.core.$ZodIPv4Params): (_schema: z.ZodString) => z.ZodIPv4;
|
|
7
|
+
export declare function schemaIPv6(params?: string | z.core.$ZodIPv6Params): (_schema: z.ZodString) => z.ZodIPv6;
|
|
8
|
+
export declare function schemaMin(min: number, params?: string | z.core.$ZodCheckMinLengthParams | z.core.$ZodCheckGreaterThanParams): (schema: z.ZodString | z.ZodNumber) => z.ZodString | z.ZodNumber;
|
|
9
|
+
export declare function schemaMax(max: number, params?: string | z.core.$ZodCheckMaxLengthParams | z.core.$ZodCheckLessThanParams): (schema: z.ZodString | z.ZodNumber) => z.ZodString | z.ZodNumber;
|
|
10
|
+
export declare function schemaTrim(): (schema: z.ZodString) => z.ZodString;
|
|
11
|
+
export declare function schemaToLowerCase(): (schema: z.ZodString) => z.ZodString;
|
|
12
|
+
export declare function schemaToUpperCase(): (schema: z.ZodString) => z.ZodString;
|
|
13
|
+
export declare function schemaLowercase(params?: string | z.core.$ZodCheckLowerCaseParams): (schema: z.ZodString) => z.ZodString;
|
|
14
|
+
export declare function schemaUppercase(params?: string | z.core.$ZodCheckUpperCaseParams): (schema: z.ZodString) => z.ZodString;
|
|
15
|
+
export declare function schemaRegex(regex: RegExp, params?: string | z.core.$ZodCheckRegexParams): (schema: z.ZodString) => z.ZodString;
|
|
16
|
+
export declare function schemaTableIdentity(): (_schema?: any) => z.ZodString | z.ZodNumber;
|
|
17
|
+
export declare function schemaBigNumber(): (_schema: any) => z.ZodType;
|
|
18
|
+
export declare function schemaCaptcha(options: ISchemaObjectExtensionFieldCaptcha): (schema: z.ZodType) => z.ZodType;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ZodOpenAPIMetadata } from '@
|
|
2
|
-
import type { z
|
|
3
|
-
export declare function schemaOpenapi<T extends
|
|
4
|
-
export declare function schemaOpenapi<T extends
|
|
5
|
-
export declare function schemaTitle<T extends
|
|
6
|
-
export declare function schemaDescription<T extends
|
|
7
|
-
export declare function schemaExample<T extends
|
|
1
|
+
import type { ZodOpenAPIMetadata } from '@cabloy/zod-to-openapi';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
export declare function schemaOpenapi<T extends z.ZodType>(metadata: Partial<ZodOpenAPIMetadata<z.input<T>>>): T;
|
|
4
|
+
export declare function schemaOpenapi<T extends z.ZodType>(refId: string, metadata?: Partial<ZodOpenAPIMetadata<z.input<T>>>): T;
|
|
5
|
+
export declare function schemaTitle<T extends z.ZodType>(title?: string): (schema: T) => T;
|
|
6
|
+
export declare function schemaDescription<T extends z.ZodType>(description?: string): (schema: T) => T;
|
|
7
|
+
export declare function schemaExample<T extends z.ZodType>(example?: any): (schema: T) => T;
|
|
@@ -2,10 +2,12 @@ import type { Constructable } from 'vona';
|
|
|
2
2
|
import type { SchemaLike } from 'vona-module-a-openapiutils';
|
|
3
3
|
import type { ISchemaObjectOptions } from '../../../types/decorator.ts';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
export declare function schemaDefault(defaultValue: any | Function): (schema: z.
|
|
6
|
-
export declare function schemaOptional(): (schema: z.
|
|
7
|
-
export declare function schemaLazy<T>(...schemaLikes: SchemaLike[]): (_schema?: z.
|
|
8
|
-
export declare function schemaObject<T>(classType: Constructable<T>, options?: ISchemaObjectOptions): (_schema?: z.
|
|
9
|
-
export declare function schemaArray(schemaLike?: SchemaLike, params?: z.
|
|
5
|
+
export declare function schemaDefault(defaultValue: any | Function): (schema: z.ZodType) => z.ZodType;
|
|
6
|
+
export declare function schemaOptional(): (schema: z.ZodType) => z.ZodType;
|
|
7
|
+
export declare function schemaLazy<T>(...schemaLikes: SchemaLike<T>[]): (_schema?: z.ZodType) => z.ZodType<T>;
|
|
8
|
+
export declare function schemaObject<T>(classType: Constructable<T>, options?: ISchemaObjectOptions): (_schema?: z.ZodType) => z.ZodType<T>;
|
|
9
|
+
export declare function schemaArray(schemaLike?: SchemaLike, params?: z.core.$ZodArrayParams & {
|
|
10
10
|
separator?: string;
|
|
11
|
-
}): (schema: z.
|
|
11
|
+
}): (schema: z.ZodType) => z.ZodType;
|
|
12
|
+
export declare function schemaStrictObject(): (schema: z.ZodObject) => z.ZodObject;
|
|
13
|
+
export declare function schemaLooseObject(): (schema: z.ZodObject) => z.ZodObject;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IZodRefineRecord, IZodTransformRecord } from 'vona-module-a-zod';
|
|
2
|
+
import type z from 'zod';
|
|
3
|
+
export declare function schemaZodRefine<T extends keyof IZodRefineRecord>(zodRefineName: T, options?: Partial<IZodRefineRecord[T]>): (schema: z.ZodType) => z.ZodType;
|
|
4
|
+
export declare function schemaZodTransform<T extends keyof IZodTransformRecord>(zodTransformName: T, options?: Partial<IZodTransformRecord[T]>): (schema: z.ZodType) => z.ZodType;
|
package/dist/lib/schema/v.d.ts
CHANGED
|
@@ -1,22 +1,35 @@
|
|
|
1
|
-
import { schemaBigNumber, schemaEmail,
|
|
1
|
+
import { schemaBigNumber, 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 { schemaArray, schemaDefault, schemaLazy, schemaObject, schemaOptional } from './v/system.ts';
|
|
3
|
+
import { schemaArray, schemaDefault, schemaLazy, schemaLooseObject, schemaObject, schemaOptional, schemaStrictObject } from './v/system.ts';
|
|
4
|
+
import { schemaZodRefine, schemaZodTransform } from './v/zod.ts';
|
|
4
5
|
export declare const v: {
|
|
5
6
|
lazy: typeof schemaLazy;
|
|
6
7
|
array: typeof schemaArray;
|
|
7
8
|
default: typeof schemaDefault;
|
|
8
9
|
object: typeof schemaObject;
|
|
9
10
|
optional: typeof schemaOptional;
|
|
11
|
+
strictObject: typeof schemaStrictObject;
|
|
12
|
+
looseObject: typeof schemaLooseObject;
|
|
10
13
|
email: typeof schemaEmail;
|
|
11
14
|
url: typeof schemaUrl;
|
|
12
15
|
uuid: typeof schemaUuid;
|
|
13
|
-
|
|
16
|
+
ipv4: typeof schemaIPv4;
|
|
17
|
+
ipv6: typeof schemaIPv6;
|
|
14
18
|
min: typeof schemaMin;
|
|
15
19
|
max: typeof schemaMax;
|
|
20
|
+
trim: typeof schemaTrim;
|
|
21
|
+
toLowerCase: typeof schemaToLowerCase;
|
|
22
|
+
toUpperCase: typeof schemaToUpperCase;
|
|
23
|
+
lowercase: typeof schemaLowercase;
|
|
24
|
+
uppercase: typeof schemaUppercase;
|
|
25
|
+
regex: typeof schemaRegex;
|
|
16
26
|
tableIdentity: typeof schemaTableIdentity;
|
|
17
27
|
bigNumber: typeof schemaBigNumber;
|
|
28
|
+
captcha: typeof schemaCaptcha;
|
|
18
29
|
openapi: typeof schemaOpenapi;
|
|
19
30
|
title: typeof schemaTitle;
|
|
20
31
|
description: typeof schemaDescription;
|
|
21
32
|
example: typeof schemaExample;
|
|
33
|
+
refine: typeof schemaZodRefine;
|
|
34
|
+
transform: typeof schemaZodTransform;
|
|
22
35
|
};
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Constructable } from 'vona';
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
2
|
+
import type { TypeDecoratorRules } from 'vona-module-a-openapiutils';
|
|
3
|
+
export declare function getTargetDecoratorRules(target: object, disableRegisterMetadata?: boolean): TypeDecoratorRules;
|
|
4
|
+
export declare function getTargetDecoratorRuleColumns(target: object): string[];
|
|
5
|
+
export declare function getTargetDecoratorRuleColumnsMap(target: object): Record<string, string>;
|
|
4
6
|
export declare function mergeFieldsOpenapiMetadata(target: Constructable): void;
|
|
5
7
|
export declare function prepareClassType<T>(classType: (() => Constructable<T>) | Constructable<T>): Constructable<T>;
|
package/dist/lib/zod/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Constructable, Type, VonaContext } from 'vona';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
export interface ISchemaObjectOptions {
|
|
4
|
-
|
|
4
|
+
loose?: boolean;
|
|
5
5
|
strict?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export interface RouteHandlerArgumentMetaDecorator {
|
|
@@ -9,7 +9,7 @@ export interface RouteHandlerArgumentMetaDecorator {
|
|
|
9
9
|
type: RouteHandlerArgumentType;
|
|
10
10
|
field?: string;
|
|
11
11
|
pipes: Function[];
|
|
12
|
-
schema: z.
|
|
12
|
+
schema: z.ZodType;
|
|
13
13
|
extractValue?: TypeExtractValue;
|
|
14
14
|
}
|
|
15
15
|
export interface RouteHandlerArgumentMeta {
|
package/dist/types/query.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ export interface ISchemaObjectExtensionFieldQueryJoin {
|
|
|
5
5
|
on: [string, string];
|
|
6
6
|
}
|
|
7
7
|
export interface ISchemaObjectExtensionFieldQuery {
|
|
8
|
-
|
|
8
|
+
table?: keyof ITableRecord;
|
|
9
|
+
joinType?: IModelSelectParamsJoinType;
|
|
10
|
+
joinOn?: [string, string];
|
|
9
11
|
originalName?: string;
|
|
10
12
|
op?: TypeOpsNormal;
|
|
11
13
|
}
|
package/dist/types/rest.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { ZodOpenAPIMetadata } from '@
|
|
1
|
+
import type { ZodOpenAPIMetadata } from '@cabloy/zod-to-openapi';
|
|
2
2
|
import type { CurrencyOptions } from '@zhennann/currency';
|
|
3
3
|
import type { IOpenApiOptions } from 'vona-module-a-openapiutils';
|
|
4
|
-
import type { z
|
|
4
|
+
import type { z } from 'zod';
|
|
5
5
|
import type { TypeResourceActionRowRecordRender } from './actions.ts';
|
|
6
|
+
import type { ISchemaObjectExtensionFieldCaptcha } from './captcha.ts';
|
|
6
7
|
import type { IComponentRecord } from './component.ts';
|
|
7
8
|
import type { ISchemaObjectExtensionFieldQuery } from './query.ts';
|
|
8
9
|
import 'openapi3-ts/oas30';
|
|
@@ -18,6 +19,7 @@ export interface ISchemaObjectExtensionFieldRest {
|
|
|
18
19
|
export interface ISchemaObjectExtensionField {
|
|
19
20
|
rest?: ISchemaObjectExtensionFieldRest;
|
|
20
21
|
query?: ISchemaObjectExtensionFieldQuery;
|
|
22
|
+
captcha?: ISchemaObjectExtensionFieldCaptcha;
|
|
21
23
|
}
|
|
22
24
|
declare module 'openapi3-ts/oas30' {
|
|
23
25
|
interface SchemaObject extends ISchemaObjectExtensionField {
|
|
@@ -30,9 +32,9 @@ declare module 'openapi3-ts/oas31' {
|
|
|
30
32
|
export type TypeFieldRenderComponent = (keyof IComponentRecord) | (keyof TypeResourceActionRowRecordRender) | 'text' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'switch' | 'image' | 'file' | 'color' | 'password' | 'email' | 'url';
|
|
31
33
|
export type TypeFieldRenderComponentProvider = (keyof IComponentRecord) | (keyof TypeResourceActionRowRecordRender) | 'input' | 'textarea' | 'select';
|
|
32
34
|
export type TypeSchemaScene = 'table' | 'form';
|
|
33
|
-
export type TypeOpenapiMetadata<T extends
|
|
35
|
+
export type TypeOpenapiMetadata<T extends z.ZodType = z.ZodType> = Partial<ZodOpenAPIMetadata<z.input<T>>>;
|
|
34
36
|
export type TypeEntityOptionsFields<T extends {}, More extends string | undefined = never> = {
|
|
35
|
-
[key in ((keyof T) | (More extends string ? More : never))]?: TypeOpenapiMetadata | z.
|
|
37
|
+
[key in ((keyof T) | (More extends string ? More : never))]?: TypeOpenapiMetadata | z.ZodType;
|
|
36
38
|
};
|
|
37
39
|
export type TypeControllerOptionsActions<T extends {}> = {
|
|
38
40
|
[key in (keyof T)]?: IOpenApiOptions;
|
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.
|
|
4
|
+
"version": "5.0.32",
|
|
5
5
|
"title": "a-openapi",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"capabilities": {
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {},
|
|
11
11
|
"globalDependencies": {
|
|
12
|
-
"@
|
|
12
|
+
"@cabloy/zod-openapi": true,
|
|
13
|
+
"@cabloy/zod-to-openapi": true,
|
|
14
|
+
"openapi3-ts": true,
|
|
13
15
|
"zod": true
|
|
14
16
|
}
|
|
15
17
|
},
|
|
@@ -33,12 +35,13 @@
|
|
|
33
35
|
"static"
|
|
34
36
|
],
|
|
35
37
|
"dependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@cabloy/zod-
|
|
38
|
-
"@cabloy/zod-query": "^
|
|
38
|
+
"@cabloy/zod-errors-custom": "^2.0.2",
|
|
39
|
+
"@cabloy/zod-openapi": "^1.0.1",
|
|
40
|
+
"@cabloy/zod-query": "^2.0.1",
|
|
41
|
+
"@cabloy/zod-to-openapi": "^8.1.1",
|
|
39
42
|
"@zhennann/currency": "^2.0.0",
|
|
40
|
-
"openapi3-ts": "^4.
|
|
41
|
-
"zod": "^
|
|
43
|
+
"openapi3-ts": "^4.5.0",
|
|
44
|
+
"zod": "^4.1.5"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
44
47
|
"clean-package": "^2.2.0",
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
ZodError_invalid_input: string;
|
|
3
|
-
ZodError_invalid_type_required: string;
|
|
4
|
-
ZodError_invalid_type_requiredDetail: string;
|
|
5
|
-
ZodError_invalid_literal: string;
|
|
6
|
-
ZodError_unrecognized_keys: string;
|
|
7
|
-
ZodError_invalid_union: string;
|
|
8
|
-
ZodError_invalid_union_discriminator: string;
|
|
9
|
-
ZodError_invalid_enum_value: string;
|
|
10
|
-
ZodError_invalid_arguments: string;
|
|
11
|
-
ZodError_invalid_return_type: string;
|
|
12
|
-
ZodError_invalid_date: string;
|
|
13
|
-
ZodError_invalid_string_includes: string;
|
|
14
|
-
ZodError_invalid_string_includes_position: string;
|
|
15
|
-
ZodError_invalid_string_startsWith: string;
|
|
16
|
-
ZodError_invalid_string_endsWith: string;
|
|
17
|
-
ZodError_invalid_string_validation: string;
|
|
18
|
-
ZodError_invalid_string: string;
|
|
19
|
-
ZodError_too_small_array_exact: string;
|
|
20
|
-
ZodError_too_small_array_inclusive: string;
|
|
21
|
-
ZodError_too_small_array_not_inclusive: string;
|
|
22
|
-
ZodError_too_small_string_exact: string;
|
|
23
|
-
ZodError_too_small_string_inclusive: string;
|
|
24
|
-
ZodError_too_small_string_not_inclusive: string;
|
|
25
|
-
ZodError_too_small_number_exact: string;
|
|
26
|
-
ZodError_too_small_number_inclusive: string;
|
|
27
|
-
ZodError_too_small_number_not_inclusive: string;
|
|
28
|
-
ZodError_too_small_set_exact: string;
|
|
29
|
-
ZodError_too_small_set_inclusive: string;
|
|
30
|
-
ZodError_too_small_set_not_inclusive: string;
|
|
31
|
-
ZodError_too_small_date_exact: string;
|
|
32
|
-
ZodError_too_small_date_inclusive: string;
|
|
33
|
-
ZodError_too_small_date_not_inclusive: string;
|
|
34
|
-
ZodError_too_big_array_exact: string;
|
|
35
|
-
ZodError_too_big_array_inclusive: string;
|
|
36
|
-
ZodError_too_big_array_not_inclusive: string;
|
|
37
|
-
ZodError_too_big_string_exact: string;
|
|
38
|
-
ZodError_too_big_string_inclusive: string;
|
|
39
|
-
ZodError_too_big_string_not_inclusive: string;
|
|
40
|
-
ZodError_too_big_number_exact: string;
|
|
41
|
-
ZodError_too_big_number_inclusive: string;
|
|
42
|
-
ZodError_too_big_number_not_inclusive: string;
|
|
43
|
-
ZodError_too_big_set_exact: string;
|
|
44
|
-
ZodError_too_big_set_inclusive: string;
|
|
45
|
-
ZodError_too_big_set_not_inclusive: string;
|
|
46
|
-
ZodError_too_big_date_exact: string;
|
|
47
|
-
ZodError_too_big_date_inclusive: string;
|
|
48
|
-
ZodError_too_big_date_not_inclusive: string;
|
|
49
|
-
ZodError_custom: string;
|
|
50
|
-
ZodError_invalid_intersection_types: string;
|
|
51
|
-
ZodError_not_multiple_of: string;
|
|
52
|
-
ZodError_not_finite: string;
|
|
53
|
-
ZodError_validations_email: string;
|
|
54
|
-
ZodError_validations_url: string;
|
|
55
|
-
ZodError_validations_uuid: string;
|
|
56
|
-
ZodError_validations_cuid: string;
|
|
57
|
-
ZodError_validations_regex: string;
|
|
58
|
-
ZodError_validations_datetime: string;
|
|
59
|
-
ZodError_types_function: string;
|
|
60
|
-
ZodError_types_number: string;
|
|
61
|
-
ZodError_types_string: string;
|
|
62
|
-
ZodError_types_nan: string;
|
|
63
|
-
ZodError_types_integer: string;
|
|
64
|
-
ZodError_types_float: string;
|
|
65
|
-
ZodError_types_boolean: string;
|
|
66
|
-
ZodError_types_date: string;
|
|
67
|
-
ZodError_types_bigint: string;
|
|
68
|
-
ZodError_types_undefined: string;
|
|
69
|
-
ZodError_types_symbol: string;
|
|
70
|
-
ZodError_types_null: string;
|
|
71
|
-
ZodError_types_array: string;
|
|
72
|
-
ZodError_types_object: string;
|
|
73
|
-
ZodError_types_unknown: string;
|
|
74
|
-
ZodError_types_promise: string;
|
|
75
|
-
ZodError_types_void: string;
|
|
76
|
-
ZodError_types_never: string;
|
|
77
|
-
ZodError_types_map: string;
|
|
78
|
-
ZodError_types_set: string;
|
|
79
|
-
};
|
|
80
|
-
export default _default;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
ZodError_invalid_input: string;
|
|
3
|
-
ZodError_invalid_type_required: string;
|
|
4
|
-
ZodError_invalid_type_requiredDetail: string;
|
|
5
|
-
ZodError_invalid_literal: string;
|
|
6
|
-
ZodError_unrecognized_keys: string;
|
|
7
|
-
ZodError_invalid_union: string;
|
|
8
|
-
ZodError_invalid_union_discriminator: string;
|
|
9
|
-
ZodError_invalid_enum_value: string;
|
|
10
|
-
ZodError_invalid_arguments: string;
|
|
11
|
-
ZodError_invalid_return_type: string;
|
|
12
|
-
ZodError_invalid_date: string;
|
|
13
|
-
ZodError_invalid_string_includes: string;
|
|
14
|
-
ZodError_invalid_string_includes_position: string;
|
|
15
|
-
ZodError_invalid_string_startsWith: string;
|
|
16
|
-
ZodError_invalid_string_endsWith: string;
|
|
17
|
-
ZodError_invalid_string_validation: string;
|
|
18
|
-
ZodError_invalid_string: string;
|
|
19
|
-
ZodError_too_small_array_exact: string;
|
|
20
|
-
ZodError_too_small_array_inclusive: string;
|
|
21
|
-
ZodError_too_small_array_not_inclusive: string;
|
|
22
|
-
ZodError_too_small_string_exact: string;
|
|
23
|
-
ZodError_too_small_string_inclusive: string;
|
|
24
|
-
ZodError_too_small_string_not_inclusive: string;
|
|
25
|
-
ZodError_too_small_number_exact: string;
|
|
26
|
-
ZodError_too_small_number_inclusive: string;
|
|
27
|
-
ZodError_too_small_number_not_inclusive: string;
|
|
28
|
-
ZodError_too_small_set_exact: string;
|
|
29
|
-
ZodError_too_small_set_inclusive: string;
|
|
30
|
-
ZodError_too_small_set_not_inclusive: string;
|
|
31
|
-
ZodError_too_small_date_exact: string;
|
|
32
|
-
ZodError_too_small_date_inclusive: string;
|
|
33
|
-
ZodError_too_small_date_not_inclusive: string;
|
|
34
|
-
ZodError_too_big_array_exact: string;
|
|
35
|
-
ZodError_too_big_array_inclusive: string;
|
|
36
|
-
ZodError_too_big_array_not_inclusive: string;
|
|
37
|
-
ZodError_too_big_string_exact: string;
|
|
38
|
-
ZodError_too_big_string_inclusive: string;
|
|
39
|
-
ZodError_too_big_string_not_inclusive: string;
|
|
40
|
-
ZodError_too_big_number_exact: string;
|
|
41
|
-
ZodError_too_big_number_inclusive: string;
|
|
42
|
-
ZodError_too_big_number_not_inclusive: string;
|
|
43
|
-
ZodError_too_big_set_exact: string;
|
|
44
|
-
ZodError_too_big_set_inclusive: string;
|
|
45
|
-
ZodError_too_big_set_not_inclusive: string;
|
|
46
|
-
ZodError_too_big_date_exact: string;
|
|
47
|
-
ZodError_too_big_date_inclusive: string;
|
|
48
|
-
ZodError_too_big_date_not_inclusive: string;
|
|
49
|
-
ZodError_custom: string;
|
|
50
|
-
ZodError_invalid_intersection_types: string;
|
|
51
|
-
ZodError_not_multiple_of: string;
|
|
52
|
-
ZodError_not_finite: string;
|
|
53
|
-
ZodError_validations_email: string;
|
|
54
|
-
ZodError_validations_url: string;
|
|
55
|
-
ZodError_validations_uuid: string;
|
|
56
|
-
ZodError_validations_cuid: string;
|
|
57
|
-
ZodError_validations_regex: string;
|
|
58
|
-
ZodError_validations_datetime: string;
|
|
59
|
-
ZodError_types_function: string;
|
|
60
|
-
ZodError_types_number: string;
|
|
61
|
-
ZodError_types_string: string;
|
|
62
|
-
ZodError_types_nan: string;
|
|
63
|
-
ZodError_types_integer: string;
|
|
64
|
-
ZodError_types_float: string;
|
|
65
|
-
ZodError_types_boolean: string;
|
|
66
|
-
ZodError_types_date: string;
|
|
67
|
-
ZodError_types_bigint: string;
|
|
68
|
-
ZodError_types_undefined: string;
|
|
69
|
-
ZodError_types_symbol: string;
|
|
70
|
-
ZodError_types_null: string;
|
|
71
|
-
ZodError_types_array: string;
|
|
72
|
-
ZodError_types_object: string;
|
|
73
|
-
ZodError_types_unknown: string;
|
|
74
|
-
ZodError_types_promise: string;
|
|
75
|
-
ZodError_types_void: string;
|
|
76
|
-
ZodError_types_never: string;
|
|
77
|
-
ZodError_types_map: string;
|
|
78
|
-
ZodError_types_set: string;
|
|
79
|
-
};
|
|
80
|
-
export default _default;
|