vona-module-a-openapi 5.0.29 → 5.0.31
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 +132 -113
- package/dist/lib/decorator/index.d.ts +0 -2
- 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 +2 -1
- package/dist/lib/zod/index.d.ts +0 -2
- package/dist/types/captcha.d.ts +4 -0
- package/dist/types/decorator.d.ts +3 -3
- package/dist/types/index.d.ts +1 -0
- package/dist/types/query.d.ts +13 -0
- package/dist/types/rest.d.ts +8 -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/decorator/arguments.d.ts +0 -38
- package/dist/lib/decorator/pipesArgument.d.ts +0 -3
- 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
9
|
import { SymbolDecoratorRule, SymbolDecoratorRuleColumn, 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
|
|
|
@@ -54,13 +54,15 @@ function mergeFieldsOpenapiMetadata(target) {
|
|
|
54
54
|
const field = fields[key];
|
|
55
55
|
if (!field) continue;
|
|
56
56
|
const schemaCurrent = rules[key];
|
|
57
|
+
const metadataCurrent = schemaCurrent ? ZodMetadata.getOpenapiMetadata(schemaCurrent) : undefined;
|
|
57
58
|
if (Object.prototype.hasOwnProperty.call(field, 'parseAsync')) {
|
|
58
59
|
const schema = field;
|
|
59
|
-
|
|
60
|
+
const metadataCustom = ZodMetadata.getOpenapiMetadata(schema);
|
|
61
|
+
rules[key] = schema.openapi(deepExtend({}, metadataCurrent, metadataCustom));
|
|
60
62
|
} else {
|
|
61
63
|
// use deepExtend for sure strict
|
|
62
64
|
if (schemaCurrent) {
|
|
63
|
-
rules[key] = schemaCurrent.openapi(deepExtend({},
|
|
65
|
+
rules[key] = schemaCurrent.openapi(deepExtend({}, metadataCurrent, field));
|
|
64
66
|
} else {
|
|
65
67
|
rules[key] = z.any().openapi(deepExtend({}, field));
|
|
66
68
|
}
|
|
@@ -72,6 +74,7 @@ function prepareClassType(classType) {
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
function makeSchemaLikes(schemaLikes, typeInit) {
|
|
77
|
+
if (!Array.isArray(schemaLikes)) schemaLikes = [schemaLikes];
|
|
75
78
|
// default schema
|
|
76
79
|
let argSchema = $schema(typeInit);
|
|
77
80
|
// loop
|
|
@@ -133,6 +136,10 @@ function $schema(classType, options) {
|
|
|
133
136
|
// static
|
|
134
137
|
const beanOptions = appResource.getBean(classType);
|
|
135
138
|
if (beanOptions) {
|
|
139
|
+
const pipes = cast(beanOptions.options)?.pipes;
|
|
140
|
+
if (pipes) {
|
|
141
|
+
schema = makeSchemaLikes(pipes, schema);
|
|
142
|
+
}
|
|
136
143
|
const openapi = cast(beanOptions.options)?.openapi;
|
|
137
144
|
schema = schema.openapi(beanOptions.beanFullName, openapi);
|
|
138
145
|
}
|
|
@@ -152,8 +159,8 @@ function _createSchemaLazy(schemaLikes) {
|
|
|
152
159
|
}
|
|
153
160
|
function _createSchemaObject(rules, options) {
|
|
154
161
|
let schema = z.object(rules);
|
|
155
|
-
if (options?.
|
|
156
|
-
if (options?.strict) schema = schema.
|
|
162
|
+
if (options?.loose) schema = z.looseObject(schema.shape);
|
|
163
|
+
if (options?.strict) schema = z.strictObject(schema.shape);
|
|
157
164
|
return schema;
|
|
158
165
|
}
|
|
159
166
|
|
|
@@ -381,6 +388,7 @@ let ServiceOpenapi = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
|
381
388
|
const argsMapIsolate = {};
|
|
382
389
|
let isUpload;
|
|
383
390
|
for (const argMeta of argsMeta) {
|
|
391
|
+
if (!argMeta) continue;
|
|
384
392
|
if (!__ArgumentTypes.includes(argMeta.type)) continue;
|
|
385
393
|
if (['fields', 'field', 'files', 'file'].includes(argMeta.type)) {
|
|
386
394
|
isUpload = true;
|
|
@@ -428,7 +436,7 @@ let ServiceOpenapi = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
|
428
436
|
}
|
|
429
437
|
if (!schema) continue;
|
|
430
438
|
// check schema
|
|
431
|
-
if (
|
|
439
|
+
if (getInnerTypeName(schema) === 'any') {
|
|
432
440
|
throw new Error(`Invalid Openapi argument type: ${info.relativeName}:${controller.name}.${actionKey}#${argumentType}`);
|
|
433
441
|
}
|
|
434
442
|
// record
|
|
@@ -565,19 +573,6 @@ function config(_app) {
|
|
|
565
573
|
};
|
|
566
574
|
}
|
|
567
575
|
|
|
568
|
-
var locale_en_us = locales$1['en-us'];
|
|
569
|
-
|
|
570
|
-
var locale_zh_cn = locales$1['zh-cn'];
|
|
571
|
-
|
|
572
|
-
function errorsAdapter(app) {
|
|
573
|
-
setErrorMapDefault((text, ...args) => {
|
|
574
|
-
return app.meta.text(text, ...args);
|
|
575
|
-
});
|
|
576
|
-
setErrorMapSchema((text, ...args) => {
|
|
577
|
-
return app.meta.text(text, ...args);
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
|
|
581
576
|
function schemaRefCustomAdapter(_app) {
|
|
582
577
|
const registry = new OpenAPIRegistry();
|
|
583
578
|
const generator31 = new OpenApiGeneratorV31(registry.definitions);
|
|
@@ -609,26 +604,19 @@ function _patchGenerator(generator) {
|
|
|
609
604
|
class Main extends BeanSimple {
|
|
610
605
|
async moduleLoading() {}
|
|
611
606
|
async moduleLoaded() {
|
|
612
|
-
errorsAdapter(this.app);
|
|
613
607
|
schemaRefCustomAdapter(this.app);
|
|
614
608
|
}
|
|
615
609
|
async configLoaded(_config) {}
|
|
616
610
|
}
|
|
617
611
|
|
|
618
612
|
var _dec, _dec2, _class;
|
|
619
|
-
const locales = {
|
|
620
|
-
'en-us': locale_en_us,
|
|
621
|
-
'zh-cn': locale_zh_cn
|
|
622
|
-
};
|
|
623
613
|
let ScopeModuleAOpenapi = (_dec = Scope(), _dec2 = BeanInfo({
|
|
624
614
|
module: "a-openapi"
|
|
625
615
|
}), _dec(_class = _dec2(_class = class ScopeModuleAOpenapi extends BeanScopeBase {}) || _class) || _class);
|
|
626
|
-
|
|
627
|
-
return `a-openapi::${key}`;
|
|
628
|
-
}
|
|
616
|
+
|
|
629
617
|
/** scope: end */
|
|
630
618
|
|
|
631
|
-
function Field
|
|
619
|
+
function Field(...schemaLikes) {
|
|
632
620
|
return function (target, prop) {
|
|
633
621
|
// rules
|
|
634
622
|
const rules = getTargetDecoratorRules(target);
|
|
@@ -721,7 +709,7 @@ function setHeader(field, val) {
|
|
|
721
709
|
};
|
|
722
710
|
}
|
|
723
711
|
const Api = {
|
|
724
|
-
field: Field
|
|
712
|
+
field: Field,
|
|
725
713
|
httpCode,
|
|
726
714
|
contentType,
|
|
727
715
|
body,
|
|
@@ -733,107 +721,77 @@ const Api = {
|
|
|
733
721
|
setHeader
|
|
734
722
|
};
|
|
735
723
|
|
|
736
|
-
function
|
|
737
|
-
return function (
|
|
738
|
-
return
|
|
739
|
-
// not inherit
|
|
740
|
-
const argsMeta = appMetadata.getOwnMetadataArray(false, SymbolRouteHandlersArgumentsMeta, target, prop);
|
|
741
|
-
const hasParamField = typeof field === 'string';
|
|
742
|
-
const paramField = hasParamField ? field : undefined;
|
|
743
|
-
const paramSchemaLikes = hasParamField ? schemaLikes : [field, ...schemaLikes].filter(item => !!item);
|
|
744
|
-
const paramtypes = appMetadata.getMetadata('design:paramtypes', target, prop);
|
|
745
|
-
let metaType;
|
|
746
|
-
if (paramType === 'file') {
|
|
747
|
-
metaType = z.string().openapi({
|
|
748
|
-
format: 'binary'
|
|
749
|
-
});
|
|
750
|
-
} else if (paramType === 'files') {
|
|
751
|
-
metaType = z.array(z.string().openapi({
|
|
752
|
-
format: 'binary'
|
|
753
|
-
}));
|
|
754
|
-
} else {
|
|
755
|
-
metaType = paramtypes[index];
|
|
756
|
-
}
|
|
757
|
-
const argSchema = makeSchemaLikes(paramSchemaLikes, metaType);
|
|
758
|
-
argsMeta.push({
|
|
759
|
-
index,
|
|
760
|
-
type: paramType,
|
|
761
|
-
field: paramField,
|
|
762
|
-
pipes: [argSchema],
|
|
763
|
-
schema: argSchema,
|
|
764
|
-
extractValue
|
|
765
|
-
});
|
|
766
|
-
};
|
|
724
|
+
function schemaEmail(params) {
|
|
725
|
+
return function (_schema) {
|
|
726
|
+
return z.email(params);
|
|
767
727
|
};
|
|
768
728
|
}
|
|
769
|
-
|
|
770
|
-
function
|
|
771
|
-
|
|
772
|
-
}
|
|
773
|
-
function Query(property, ...schemaLikes) {
|
|
774
|
-
return createPipesArgumentDecorator('query')(property, ...schemaLikes);
|
|
775
|
-
}
|
|
776
|
-
function Body(property, ...schemaLikes) {
|
|
777
|
-
return createPipesArgumentDecorator('body')(property, ...schemaLikes);
|
|
778
|
-
}
|
|
779
|
-
function Headers(property, ...schemaLikes) {
|
|
780
|
-
return createPipesArgumentDecorator('headers')(property, ...schemaLikes);
|
|
729
|
+
function schemaUrl(params) {
|
|
730
|
+
return function (_schema) {
|
|
731
|
+
return z.url(params);
|
|
732
|
+
};
|
|
781
733
|
}
|
|
782
|
-
function
|
|
783
|
-
return
|
|
734
|
+
function schemaUuid(params) {
|
|
735
|
+
return function (_schema) {
|
|
736
|
+
return z.uuid(params);
|
|
737
|
+
};
|
|
784
738
|
}
|
|
785
|
-
function
|
|
786
|
-
return
|
|
739
|
+
function schemaIPv4(params) {
|
|
740
|
+
return function (_schema) {
|
|
741
|
+
return z.ipv4(params);
|
|
742
|
+
};
|
|
787
743
|
}
|
|
788
|
-
function
|
|
789
|
-
return
|
|
744
|
+
function schemaIPv6(params) {
|
|
745
|
+
return function (_schema) {
|
|
746
|
+
return z.ipv6(params);
|
|
747
|
+
};
|
|
790
748
|
}
|
|
791
|
-
function
|
|
792
|
-
return
|
|
749
|
+
function schemaMin(min, params) {
|
|
750
|
+
return function (schema) {
|
|
751
|
+
if (schema.type === 'string') {
|
|
752
|
+
return schema.min(min, params);
|
|
753
|
+
} else {
|
|
754
|
+
return schema.min(min, params);
|
|
755
|
+
}
|
|
756
|
+
};
|
|
793
757
|
}
|
|
794
|
-
function
|
|
795
|
-
return
|
|
758
|
+
function schemaMax(max, params) {
|
|
759
|
+
return function (schema) {
|
|
760
|
+
if (schema.type === 'string') {
|
|
761
|
+
return schema.max(max, params);
|
|
762
|
+
} else {
|
|
763
|
+
return schema.max(max, params);
|
|
764
|
+
}
|
|
765
|
+
};
|
|
796
766
|
}
|
|
797
|
-
|
|
798
|
-
param: Param,
|
|
799
|
-
query: Query,
|
|
800
|
-
body: Body,
|
|
801
|
-
headers: Headers,
|
|
802
|
-
fields: Fields,
|
|
803
|
-
field: Field,
|
|
804
|
-
files: Files,
|
|
805
|
-
file: File,
|
|
806
|
-
user: User
|
|
807
|
-
};
|
|
808
|
-
|
|
809
|
-
function schemaEmail(message) {
|
|
767
|
+
function schemaTrim() {
|
|
810
768
|
return function (schema) {
|
|
811
|
-
return schema.
|
|
769
|
+
return schema.trim();
|
|
812
770
|
};
|
|
813
771
|
}
|
|
814
|
-
function
|
|
772
|
+
function schemaToLowerCase() {
|
|
815
773
|
return function (schema) {
|
|
816
|
-
return schema.
|
|
774
|
+
return schema.toLowerCase();
|
|
817
775
|
};
|
|
818
776
|
}
|
|
819
|
-
function
|
|
777
|
+
function schemaToUpperCase() {
|
|
820
778
|
return function (schema) {
|
|
821
|
-
return schema.
|
|
779
|
+
return schema.toUpperCase();
|
|
822
780
|
};
|
|
823
781
|
}
|
|
824
|
-
function
|
|
782
|
+
function schemaLowercase(params) {
|
|
825
783
|
return function (schema) {
|
|
826
|
-
return schema.
|
|
784
|
+
return schema.lowercase(params);
|
|
827
785
|
};
|
|
828
786
|
}
|
|
829
|
-
function
|
|
787
|
+
function schemaUppercase(params) {
|
|
830
788
|
return function (schema) {
|
|
831
|
-
return schema.
|
|
789
|
+
return schema.uppercase(params);
|
|
832
790
|
};
|
|
833
791
|
}
|
|
834
|
-
function
|
|
792
|
+
function schemaRegex(regex, params) {
|
|
835
793
|
return function (schema) {
|
|
836
|
-
return schema.
|
|
794
|
+
return schema.regex(regex, params);
|
|
837
795
|
};
|
|
838
796
|
}
|
|
839
797
|
function schemaTableIdentity() {
|
|
@@ -854,6 +812,13 @@ function schemaBigNumber() {
|
|
|
854
812
|
return z.union([z.string(), z.number()]);
|
|
855
813
|
};
|
|
856
814
|
}
|
|
815
|
+
function schemaCaptcha(options) {
|
|
816
|
+
return function (schema) {
|
|
817
|
+
return schema.openapi({
|
|
818
|
+
captcha: options
|
|
819
|
+
});
|
|
820
|
+
};
|
|
821
|
+
}
|
|
857
822
|
|
|
858
823
|
function schemaOpenapi(refId, metadata) {
|
|
859
824
|
return function (schema) {
|
|
@@ -908,13 +873,54 @@ function schemaArray(schemaLike, params) {
|
|
|
908
873
|
val = coerceWithNil(val);
|
|
909
874
|
if (isNil(val)) return val;
|
|
910
875
|
if (typeof val !== 'string') return val;
|
|
911
|
-
if (
|
|
876
|
+
if (val.startsWith('[') && val.endsWith(']')) return JSON.parse(val);
|
|
912
877
|
return val.split(params?.separator ?? ',');
|
|
913
878
|
}, z.array(makeSchemaLike(schemaLike ?? schema, z.any()), params)
|
|
914
879
|
// z.array(makeSchemaLike(schemaLike, schema), params),
|
|
915
880
|
);
|
|
916
881
|
};
|
|
917
882
|
}
|
|
883
|
+
function schemaStrictObject() {
|
|
884
|
+
return function (schema) {
|
|
885
|
+
return z.strictObject(schema.shape);
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
function schemaLooseObject() {
|
|
889
|
+
return function (schema) {
|
|
890
|
+
return z.looseObject(schema.shape);
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
function schemaZodRefine(zodRefineName, options) {
|
|
895
|
+
return function (schema) {
|
|
896
|
+
return schema.superRefine(async (value, refinementCtx) => {
|
|
897
|
+
const app = useApp();
|
|
898
|
+
const options2 = app.bean.onion.zodRefine.getOnionOptionsDynamic(zodRefineName, options);
|
|
899
|
+
// execute
|
|
900
|
+
const beanFullName = beanFullNameFromOnionName(zodRefineName, 'zodRefine');
|
|
901
|
+
const beanInstance = app.bean._getBean(beanFullName);
|
|
902
|
+
if (!beanInstance) {
|
|
903
|
+
throw new Error(`zodRefine bean not found: ${beanFullName}`);
|
|
904
|
+
}
|
|
905
|
+
return await beanInstance.execute(value, refinementCtx, options2);
|
|
906
|
+
});
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
function schemaZodTransform(zodTransformName, options) {
|
|
910
|
+
return function (schema) {
|
|
911
|
+
return schema.transform(async value => {
|
|
912
|
+
const app = useApp();
|
|
913
|
+
const options2 = app.bean.onion.zodTransform.getOnionOptionsDynamic(zodTransformName, options);
|
|
914
|
+
// execute
|
|
915
|
+
const beanFullName = beanFullNameFromOnionName(zodTransformName, 'zodTransform');
|
|
916
|
+
const beanInstance = app.bean._getBean(beanFullName);
|
|
917
|
+
if (!beanInstance) {
|
|
918
|
+
throw new Error(`zodTransform bean not found: ${beanFullName}`);
|
|
919
|
+
}
|
|
920
|
+
return await beanInstance.execute(value, options2);
|
|
921
|
+
});
|
|
922
|
+
};
|
|
923
|
+
}
|
|
918
924
|
|
|
919
925
|
const v = {
|
|
920
926
|
lazy: schemaLazy,
|
|
@@ -922,20 +928,33 @@ const v = {
|
|
|
922
928
|
default: schemaDefault,
|
|
923
929
|
object: schemaObject,
|
|
924
930
|
optional: schemaOptional,
|
|
931
|
+
strictObject: schemaStrictObject,
|
|
932
|
+
looseObject: schemaLooseObject,
|
|
925
933
|
// helpers
|
|
926
934
|
email: schemaEmail,
|
|
927
935
|
url: schemaUrl,
|
|
928
936
|
uuid: schemaUuid,
|
|
929
|
-
|
|
937
|
+
ipv4: schemaIPv4,
|
|
938
|
+
ipv6: schemaIPv6,
|
|
930
939
|
min: schemaMin,
|
|
931
940
|
max: schemaMax,
|
|
941
|
+
trim: schemaTrim,
|
|
942
|
+
toLowerCase: schemaToLowerCase,
|
|
943
|
+
toUpperCase: schemaToUpperCase,
|
|
944
|
+
lowercase: schemaLowercase,
|
|
945
|
+
uppercase: schemaUppercase,
|
|
946
|
+
regex: schemaRegex,
|
|
932
947
|
tableIdentity: schemaTableIdentity,
|
|
933
948
|
bigNumber: schemaBigNumber,
|
|
949
|
+
captcha: schemaCaptcha,
|
|
934
950
|
// openapi
|
|
935
951
|
openapi: schemaOpenapi,
|
|
936
952
|
title: schemaTitle,
|
|
937
953
|
description: schemaDescription,
|
|
938
|
-
example: schemaExample
|
|
954
|
+
example: schemaExample,
|
|
955
|
+
// zod
|
|
956
|
+
refine: schemaZodRefine,
|
|
957
|
+
transform: schemaZodTransform
|
|
939
958
|
};
|
|
940
959
|
|
|
941
960
|
const OrderCoreBase = 100;
|
|
@@ -943,4 +962,4 @@ const OrderBusinessBase = 1000;
|
|
|
943
962
|
const OrderUnknownBase = 10000;
|
|
944
963
|
const OrderMaxBase = 100000;
|
|
945
964
|
|
|
946
|
-
export { $
|
|
965
|
+
export { $schema, $schemaLazy, Api, Main, OrderBusinessBase, OrderCoreBase, OrderMaxBase, OrderUnknownBase, ScopeModuleAOpenapi, ServiceOpenapi, SummerCacheJson, SymbolRouteHandlersArgumentsMeta, SymbolRouteHandlersArgumentsValue, SymbolSchemaDynamicRefId, addSchemaDynamic, bodySchemaWrapperDefault, config, getSchemaDynamic, getSchemasDynamic, getTargetDecoratorRuleColumns, 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,6 @@
|
|
|
1
1
|
import type { Constructable } from 'vona';
|
|
2
|
-
|
|
2
|
+
import type { TypeDecoratorRules } from 'vona-module-a-openapiutils';
|
|
3
|
+
export declare function getTargetDecoratorRules(target: object): TypeDecoratorRules;
|
|
3
4
|
export declare function getTargetDecoratorRuleColumns(target: object): Record<PropertyKey, unknown>;
|
|
4
5
|
export declare function mergeFieldsOpenapiMetadata(target: Constructable): void;
|
|
5
6
|
export declare function prepareClassType<T>(classType: (() => Constructable<T>) | Constructable<T>): Constructable<T>;
|
package/dist/lib/zod/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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 {
|
|
8
8
|
index: number;
|
|
9
9
|
type: RouteHandlerArgumentType;
|
|
10
10
|
field?: string;
|
|
11
|
-
pipes:
|
|
12
|
-
schema: z.
|
|
11
|
+
pipes: Function[];
|
|
12
|
+
schema: z.ZodType;
|
|
13
13
|
extractValue?: TypeExtractValue;
|
|
14
14
|
}
|
|
15
15
|
export interface RouteHandlerArgumentMeta {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IModelSelectParamsJoinType, ITableRecord, TypeOpsNormal } from 'vona-module-a-orm';
|
|
2
|
+
export interface ISchemaObjectExtensionFieldQueryJoin {
|
|
3
|
+
type?: IModelSelectParamsJoinType;
|
|
4
|
+
table: keyof ITableRecord;
|
|
5
|
+
on: [string, string];
|
|
6
|
+
}
|
|
7
|
+
export interface ISchemaObjectExtensionFieldQuery {
|
|
8
|
+
table?: keyof ITableRecord;
|
|
9
|
+
joinType?: IModelSelectParamsJoinType;
|
|
10
|
+
joinOn?: [string, string];
|
|
11
|
+
originalName?: string;
|
|
12
|
+
op?: TypeOpsNormal;
|
|
13
|
+
}
|
package/dist/types/rest.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
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';
|
|
8
|
+
import type { ISchemaObjectExtensionFieldQuery } from './query.ts';
|
|
7
9
|
import 'openapi3-ts/oas30';
|
|
8
10
|
import 'openapi3-ts/oas31';
|
|
9
11
|
export interface ISchemaObjectExtensionFieldRest {
|
|
@@ -16,6 +18,8 @@ export interface ISchemaObjectExtensionFieldRest {
|
|
|
16
18
|
}
|
|
17
19
|
export interface ISchemaObjectExtensionField {
|
|
18
20
|
rest?: ISchemaObjectExtensionFieldRest;
|
|
21
|
+
query?: ISchemaObjectExtensionFieldQuery;
|
|
22
|
+
captcha?: ISchemaObjectExtensionFieldCaptcha;
|
|
19
23
|
}
|
|
20
24
|
declare module 'openapi3-ts/oas30' {
|
|
21
25
|
interface SchemaObject extends ISchemaObjectExtensionField {
|
|
@@ -28,9 +32,9 @@ declare module 'openapi3-ts/oas31' {
|
|
|
28
32
|
export type TypeFieldRenderComponent = (keyof IComponentRecord) | (keyof TypeResourceActionRowRecordRender) | 'text' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'switch' | 'image' | 'file' | 'color' | 'password' | 'email' | 'url';
|
|
29
33
|
export type TypeFieldRenderComponentProvider = (keyof IComponentRecord) | (keyof TypeResourceActionRowRecordRender) | 'input' | 'textarea' | 'select';
|
|
30
34
|
export type TypeSchemaScene = 'table' | 'form';
|
|
31
|
-
export type TypeOpenapiMetadata<T extends
|
|
35
|
+
export type TypeOpenapiMetadata<T extends z.ZodType = z.ZodType> = Partial<ZodOpenAPIMetadata<z.input<T>>>;
|
|
32
36
|
export type TypeEntityOptionsFields<T extends {}, More extends string | undefined = never> = {
|
|
33
|
-
[key in ((keyof T) | (More extends string ? More : never))]?: TypeOpenapiMetadata | z.
|
|
37
|
+
[key in ((keyof T) | (More extends string ? More : never))]?: TypeOpenapiMetadata | z.ZodType;
|
|
34
38
|
};
|
|
35
39
|
export type TypeControllerOptionsActions<T extends {}> = {
|
|
36
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.31",
|
|
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.1",
|
|
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;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { SchemaLike } from 'vona-module-a-openapiutils';
|
|
2
|
-
declare function Param(): ParameterDecorator;
|
|
3
|
-
declare function Param(...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
4
|
-
declare function Param(property: string, ...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
5
|
-
declare function Query(): ParameterDecorator;
|
|
6
|
-
declare function Query(...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
7
|
-
declare function Query(property: string, ...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
8
|
-
declare function Body(): ParameterDecorator;
|
|
9
|
-
declare function Body(...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
10
|
-
declare function Body(property: string, ...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
11
|
-
declare function Headers(): ParameterDecorator;
|
|
12
|
-
declare function Headers(...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
13
|
-
declare function Headers(property: string, ...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
14
|
-
declare function Fields(): ParameterDecorator;
|
|
15
|
-
declare function Fields(...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
16
|
-
declare function Fields(property: string, ...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
17
|
-
declare function Field(): ParameterDecorator;
|
|
18
|
-
declare function Field(...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
19
|
-
declare function Field(property: string, ...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
20
|
-
declare function Files(): ParameterDecorator;
|
|
21
|
-
declare function Files(...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
22
|
-
declare function Files(property: string, ...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
23
|
-
declare function File(): ParameterDecorator;
|
|
24
|
-
declare function File(...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
25
|
-
declare function File(property: string, ...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
26
|
-
declare function User(...schemaLikes: SchemaLike[]): ParameterDecorator;
|
|
27
|
-
export declare const Arg: {
|
|
28
|
-
param: typeof Param;
|
|
29
|
-
query: typeof Query;
|
|
30
|
-
body: typeof Body;
|
|
31
|
-
headers: typeof Headers;
|
|
32
|
-
fields: typeof Fields;
|
|
33
|
-
field: typeof Field;
|
|
34
|
-
files: typeof Files;
|
|
35
|
-
file: typeof File;
|
|
36
|
-
user: typeof User;
|
|
37
|
-
};
|
|
38
|
-
export {};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { SchemaLike } from 'vona-module-a-openapiutils';
|
|
2
|
-
import type { RouteHandlerArgumentType, TypeExtractValue } from '../../types/decorator.ts';
|
|
3
|
-
export declare function createPipesArgumentDecorator(paramType: RouteHandlerArgumentType, extractValue?: TypeExtractValue): (field?: string | SchemaLike, ...schemaLikes: SchemaLike[]) => ParameterDecorator;
|