vona-module-a-openapi 5.0.54 → 5.0.55
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 -15
- package/dist/bean/bean.openapi.d.ts +3 -2
- package/dist/index.js +25 -623
- package/dist/lib/index.d.ts +0 -3
- package/dist/types/decorator.d.ts +0 -2
- package/dist/types/index.d.ts +1 -2
- package/dist/types/rest.d.ts +0 -2
- package/package.json +3 -3
- package/dist/config/locale/en-us.d.ts +0 -4
- package/dist/config/locale/zh-cn.d.ts +0 -4
- package/dist/lib/decorator/api.d.ts +0 -27
- package/dist/lib/decorator/field.d.ts +0 -2
- package/dist/lib/decorator/index.d.ts +0 -1
- package/dist/lib/schema/bodySchemaWrapper.d.ts +0 -6
- package/dist/lib/schema/index.d.ts +0 -5
- package/dist/lib/schema/makeSchemaLikes.d.ts +0 -5
- package/dist/lib/schema/schema.d.ts +0 -13
- package/dist/lib/schema/schemaDynamic.d.ts +0 -5
- package/dist/lib/schema/v/helpers.d.ts +0 -17
- package/dist/lib/schema/v/openapi.d.ts +0 -7
- package/dist/lib/schema/v/serializer.d.ts +0 -10
- package/dist/lib/schema/v/system.d.ts +0 -14
- package/dist/lib/schema/v/zod.d.ts +0 -4
- package/dist/lib/schema/v.d.ts +0 -41
- package/dist/lib/utils.d.ts +0 -10
- package/dist/types/database.d.ts +0 -4
- package/dist/types/query.d.ts +0 -13
|
@@ -75,26 +75,17 @@ export interface IModuleSummerCache {
|
|
|
75
75
|
/** config: begin */
|
|
76
76
|
export * from '../config/config.ts';
|
|
77
77
|
import type { config } from '../config/config.ts';
|
|
78
|
-
|
|
79
|
-
'en-us': {
|
|
80
|
-
ZodErrorRequired: string;
|
|
81
|
-
};
|
|
82
|
-
'zh-cn': {
|
|
83
|
-
ZodErrorRequired: string;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
/** locale: end */
|
|
78
|
+
/** config: end */
|
|
87
79
|
/** main: begin */
|
|
88
80
|
export * from '../main.ts';
|
|
89
81
|
/** main: end */
|
|
90
82
|
/** scope: begin */
|
|
91
|
-
import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig
|
|
83
|
+
import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig } from 'vona';
|
|
92
84
|
export declare class ScopeModuleAOpenapi extends BeanScopeBase {
|
|
93
85
|
}
|
|
94
86
|
export interface ScopeModuleAOpenapi {
|
|
95
87
|
util: BeanScopeUtil;
|
|
96
88
|
config: TypeModuleConfig<typeof config>;
|
|
97
|
-
locale: TypeModuleLocales<(typeof locales)[TypeLocaleBase]>;
|
|
98
89
|
service: IModuleService;
|
|
99
90
|
summerCache: IModuleSummerCache;
|
|
100
91
|
}
|
|
@@ -109,9 +100,5 @@ declare module 'vona' {
|
|
|
109
100
|
interface IBeanScopeConfig {
|
|
110
101
|
'a-openapi': ReturnType<typeof config>;
|
|
111
102
|
}
|
|
112
|
-
interface IBeanScopeLocale {
|
|
113
|
-
'a-openapi': (typeof locales)[TypeLocaleBase];
|
|
114
|
-
}
|
|
115
103
|
}
|
|
116
|
-
export declare function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): `a-openapi::${K}`;
|
|
117
104
|
/** scope: end */
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Constructable } from 'vona';
|
|
2
|
+
import type { ICachingActionKeyInfo } from 'vona-module-a-caching';
|
|
2
3
|
import type { IOpenapiObject } from 'vona-module-a-openapiutils';
|
|
3
4
|
import { BeanBase } from 'vona';
|
|
4
5
|
export declare class BeanOpenapi extends BeanBase {
|
|
5
6
|
generateJsonOfClass<K extends keyof IOpenapiObject>(schemaClass: Constructable, version?: K): Promise<IOpenapiObject[K]>;
|
|
6
7
|
generateJsonOfClasses<K extends keyof IOpenapiObject>(schemaClasses: Constructable[], version?: K): Promise<IOpenapiObject[K]>;
|
|
7
|
-
protected generateJsonCacheKey(
|
|
8
|
-
protected generateJsonOfControllerActionCacheKey(
|
|
8
|
+
protected generateJsonCacheKey(info: ICachingActionKeyInfo): string;
|
|
9
|
+
protected generateJsonOfControllerActionCacheKey(info: ICachingActionKeyInfo): string;
|
|
9
10
|
generateJson<K extends keyof IOpenapiObject>(version?: K): Promise<IOpenapiObject[K]>;
|
|
10
11
|
generateJsonOfControllerAction<K extends keyof IOpenapiObject>(controller: Constructable, actionKey: string, version?: K): Promise<IOpenapiObject[K]>;
|
|
11
12
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BeanInfo, BeanBase, appResource, cast, LocaleModuleNameSeparator, appMetadata, BeanSimple, BeanScopeBase } from 'vona';
|
|
2
2
|
import { OpenAPIRegistry, OpenApiGeneratorV3, OpenApiGeneratorV31 } from '@cabloy/zod-to-openapi';
|
|
3
3
|
import { Bean, Service, Scope } from 'vona-module-a-bean';
|
|
4
4
|
import { Caching } from 'vona-module-a-caching';
|
|
5
|
-
import {
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
import { isEmptyObject, isClass, isNil } from '@cabloy/utils';
|
|
8
|
-
import { ZodMetadata } from '@cabloy/zod-openapi';
|
|
5
|
+
import { $schema, SymbolOpenApiOptions, bodySchemaWrapperDefault, SymbolRouteHandlersArgumentsMeta } from 'vona-module-a-openapiutils';
|
|
9
6
|
import * as ModuleInfo from '@cabloy/module-info';
|
|
7
|
+
import { isNil, isEmptyObject } from '@cabloy/utils';
|
|
10
8
|
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
11
9
|
import { translateError } from '@cabloy/zod-errors-custom';
|
|
12
|
-
import { getInnerTypeName
|
|
10
|
+
import { getInnerTypeName } from '@cabloy/zod-query';
|
|
13
11
|
import { SymbolRequestMappingHandler } from 'vona-module-a-web';
|
|
12
|
+
import { z } from 'zod';
|
|
14
13
|
import { SummerCache, BeanSummerCacheBase } from 'vona-module-a-summer';
|
|
14
|
+
import { ZodMetadata } from '@cabloy/zod-openapi';
|
|
15
15
|
import 'openapi3-ts/oas30';
|
|
16
16
|
import 'openapi3-ts/oas31';
|
|
17
17
|
|
|
@@ -24,169 +24,6 @@ function _applyDecoratedDescriptor(i, e, r, n, l) {
|
|
|
24
24
|
}, a), l && void 0 !== a.initializer && (a.value = a.initializer ? a.initializer.call(l) : void 0, a.initializer = void 0), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function getTargetDecoratorRules(target, disableRegisterMetadata) {
|
|
28
|
-
if (!disableRegisterMetadata) {
|
|
29
|
-
registerMappedClassMetadataKey(target, SymbolDecoratorRule, {
|
|
30
|
-
partialClass: meta => {
|
|
31
|
-
return meta.optional();
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return appMetadata.getOwnMetadataMap(true, SymbolDecoratorRule, target);
|
|
36
|
-
}
|
|
37
|
-
function getTargetDecoratorRuleColumns(target) {
|
|
38
|
-
const rules = getTargetDecoratorRules(target, true);
|
|
39
|
-
return Object.keys(rules);
|
|
40
|
-
}
|
|
41
|
-
function getTargetDecoratorRuleColumnsMap(target) {
|
|
42
|
-
const columns = getTargetDecoratorRuleColumns(target);
|
|
43
|
-
const map = {};
|
|
44
|
-
for (const column of columns) {
|
|
45
|
-
map[column] = column;
|
|
46
|
-
}
|
|
47
|
-
return map;
|
|
48
|
-
}
|
|
49
|
-
function mergeFieldsOpenapiMetadata(target) {
|
|
50
|
-
// beanOptions
|
|
51
|
-
const beanOptions = appResource.getBean(target);
|
|
52
|
-
const fields = cast(beanOptions?.options)?.fields;
|
|
53
|
-
if (!fields) return;
|
|
54
|
-
for (const key in fields) {
|
|
55
|
-
const field = fields[key];
|
|
56
|
-
if (!field) continue;
|
|
57
|
-
mergeFieldOpenapiMetadata(target.prototype, key, field);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// fieldRule maybe undefined
|
|
62
|
-
function mergeFieldOpenapiMetadata(target, prop, fieldRule) {
|
|
63
|
-
// rules
|
|
64
|
-
const rules = getTargetDecoratorRules(target);
|
|
65
|
-
// rule
|
|
66
|
-
const schemaCurrent = rules[prop];
|
|
67
|
-
const metadataCurrent = schemaCurrent ? ZodMetadata.getOpenapiMetadata(schemaCurrent) : undefined;
|
|
68
|
-
// merge
|
|
69
|
-
if (Object.prototype.hasOwnProperty.call(fieldRule, 'parseAsync')) {
|
|
70
|
-
const schema = fieldRule;
|
|
71
|
-
if (isEmptyObject(metadataCurrent)) {
|
|
72
|
-
rules[prop] = schema;
|
|
73
|
-
} else {
|
|
74
|
-
const metadataCustom = ZodMetadata.getOpenapiMetadata(schema);
|
|
75
|
-
rules[prop] = schema.openapi(deepExtend({}, metadataCurrent, metadataCustom));
|
|
76
|
-
}
|
|
77
|
-
} else {
|
|
78
|
-
if (schemaCurrent) {
|
|
79
|
-
if (!isEmptyObject(fieldRule)) {
|
|
80
|
-
rules[prop] = schemaCurrent.openapi(deepExtend({}, metadataCurrent, fieldRule));
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
if (isEmptyObject(fieldRule)) {
|
|
84
|
-
rules[prop] = z.any();
|
|
85
|
-
} else {
|
|
86
|
-
rules[prop] = z.any().openapi(fieldRule);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return rules;
|
|
91
|
-
}
|
|
92
|
-
function prepareClassType(classType) {
|
|
93
|
-
return isClass(classType) ? classType : cast(classType)();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function $makeSchema(...schemaLikes) {
|
|
97
|
-
return makeSchemaLikes(schemaLikes, undefined);
|
|
98
|
-
}
|
|
99
|
-
function makeSchemaLikes(schemaLikes, typeInit) {
|
|
100
|
-
if (!Array.isArray(schemaLikes)) schemaLikes = [schemaLikes];
|
|
101
|
-
// default schema
|
|
102
|
-
let argSchema = $schema(typeInit);
|
|
103
|
-
// loop
|
|
104
|
-
for (let index = schemaLikes.length - 1; index >= 0; index--) {
|
|
105
|
-
const schemaLike = schemaLikes[index];
|
|
106
|
-
argSchema = makeSchemaLike(schemaLike, argSchema);
|
|
107
|
-
}
|
|
108
|
-
return argSchema;
|
|
109
|
-
}
|
|
110
|
-
function makeSchemaLike(schemaLike, schemaPrevious) {
|
|
111
|
-
if (!schemaLike) return schemaPrevious;
|
|
112
|
-
if (Object.prototype.hasOwnProperty.call(schemaLike, 'parseAsync')) {
|
|
113
|
-
// schema
|
|
114
|
-
return schemaLike;
|
|
115
|
-
} else if (isClass(schemaLike) || ['String', 'Number', 'Boolean', 'Date', 'BigInt', 'Array'].includes(cast(schemaLike).name)) {
|
|
116
|
-
// class
|
|
117
|
-
return $schema(cast(schemaLike));
|
|
118
|
-
} else {
|
|
119
|
-
// function
|
|
120
|
-
return cast(schemaLike)(schemaPrevious);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const __schemasDynamic = {};
|
|
125
|
-
const SymbolSchemaDynamicRefId = Symbol('SymbolSchemaDynamicRefId');
|
|
126
|
-
function addSchemaDynamic(dynamicName, classType) {
|
|
127
|
-
__schemasDynamic[dynamicName] = classType;
|
|
128
|
-
}
|
|
129
|
-
function getSchemaDynamic(dynamicName) {
|
|
130
|
-
return __schemasDynamic[dynamicName];
|
|
131
|
-
}
|
|
132
|
-
function getSchemasDynamic() {
|
|
133
|
-
return __schemasDynamic;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function $schema(classType, options) {
|
|
137
|
-
if (!classType) return z.any();
|
|
138
|
-
if (classType.parseAsync) return classType;
|
|
139
|
-
if (classType.name === 'String') return z.string();
|
|
140
|
-
if (classType.name === 'Number') return z.number();
|
|
141
|
-
if (classType.name === 'Boolean') return z.boolean();
|
|
142
|
-
if (classType.name === 'Date') return z.date();
|
|
143
|
-
if (classType.name === 'BigInt') return z.bigint();
|
|
144
|
-
if (classType.name === 'Array') return z.array(z.any());
|
|
145
|
-
// check if object
|
|
146
|
-
const rules = classType.prototype ? appMetadata.getMetadata(SymbolDecoratorRule, classType.prototype) : undefined;
|
|
147
|
-
if (!rules) {
|
|
148
|
-
// not object
|
|
149
|
-
return z.any();
|
|
150
|
-
}
|
|
151
|
-
// object
|
|
152
|
-
let schema = _createSchemaObject(rules, options);
|
|
153
|
-
// refId
|
|
154
|
-
const schemaDynamicRefId = classType[SymbolSchemaDynamicRefId];
|
|
155
|
-
if (schemaDynamicRefId) {
|
|
156
|
-
// dynamic
|
|
157
|
-
schema = schema.openapi(schemaDynamicRefId);
|
|
158
|
-
} else {
|
|
159
|
-
// static
|
|
160
|
-
const beanOptions = appResource.getBean(classType);
|
|
161
|
-
if (beanOptions) {
|
|
162
|
-
const pipes = cast(beanOptions.options)?.pipes;
|
|
163
|
-
if (pipes) {
|
|
164
|
-
schema = makeSchemaLikes(pipes, schema);
|
|
165
|
-
}
|
|
166
|
-
const openapi = cast(beanOptions.options)?.openapi;
|
|
167
|
-
schema = schema.openapi(beanOptions.beanFullName, openapi);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return schema;
|
|
171
|
-
}
|
|
172
|
-
function $schemaLazy(...schemaLikes) {
|
|
173
|
-
return z.lazy(() => {
|
|
174
|
-
return _createSchemaLazy(schemaLikes);
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
function _createSchemaLazy(schemaLikes) {
|
|
178
|
-
const classType = schemaLikes[schemaLikes.length - 1];
|
|
179
|
-
schemaLikes = schemaLikes.slice(0, schemaLikes.length - 1);
|
|
180
|
-
const classType2 = prepareClassType(classType);
|
|
181
|
-
return makeSchemaLikes(schemaLikes, $schema(classType2));
|
|
182
|
-
}
|
|
183
|
-
function _createSchemaObject(rules, options) {
|
|
184
|
-
let schema = z.object(rules);
|
|
185
|
-
if (options?.loose) schema = z.looseObject(schema.shape);
|
|
186
|
-
if (options?.strict) schema = z.strictObject(schema.shape);
|
|
187
|
-
return schema;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
27
|
var _dec$3, _dec2$3, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _class$3, _class2;
|
|
191
28
|
let BeanOpenapi = (_dec$3 = Bean(), _dec2$3 = BeanInfo({
|
|
192
29
|
module: "a-openapi"
|
|
@@ -220,17 +57,17 @@ let BeanOpenapi = (_dec$3 = Bean(), _dec2$3 = BeanInfo({
|
|
|
220
57
|
this.scope.service.openapi.translate(apiObj, 'rest');
|
|
221
58
|
return apiObj;
|
|
222
59
|
}
|
|
223
|
-
generateJsonCacheKey(
|
|
224
|
-
const version = args[0] ?? 'V31';
|
|
60
|
+
generateJsonCacheKey(info) {
|
|
61
|
+
const version = info.args[0] ?? 'V31';
|
|
225
62
|
const locale = this.ctx.locale;
|
|
226
|
-
return `${prop}_${version}_${locale}`;
|
|
63
|
+
return `${info.prop}_${version}_${locale}`;
|
|
227
64
|
}
|
|
228
|
-
generateJsonOfControllerActionCacheKey(
|
|
229
|
-
const [controller, actionKey, version] = args;
|
|
65
|
+
generateJsonOfControllerActionCacheKey(info) {
|
|
66
|
+
const [controller, actionKey, version] = info.args;
|
|
230
67
|
const beanOptions = appResource.getBean(controller);
|
|
231
68
|
const beanFullName = beanOptions.beanFullName;
|
|
232
69
|
const locale = this.ctx.locale;
|
|
233
|
-
return `${prop}_${beanFullName}_${actionKey}_${version ?? 'V31'}_${locale}`;
|
|
70
|
+
return `${info.prop}_${beanFullName}_${actionKey}_${version ?? 'V31'}_${locale}`;
|
|
234
71
|
}
|
|
235
72
|
async generateJson(version = 'V31') {
|
|
236
73
|
const registry = this.scope.service.openapi.collectRegistry();
|
|
@@ -251,17 +88,6 @@ let BeanOpenapi = (_dec$3 = Bean(), _dec2$3 = BeanInfo({
|
|
|
251
88
|
}
|
|
252
89
|
}, _applyDecoratedDescriptor(_class2.prototype, "generateJson", [_dec3, _dec4, _dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "generateJson"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "generateJsonOfControllerAction", [_dec6, _dec7, _dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "generateJsonOfControllerAction"), _class2.prototype), _class2)) || _class$3) || _class$3);
|
|
253
90
|
|
|
254
|
-
function bodySchemaWrapperDefault(bodySchema) {
|
|
255
|
-
return z.object({
|
|
256
|
-
code: z.string(),
|
|
257
|
-
message: z.string(),
|
|
258
|
-
data: bodySchema
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const SymbolRouteHandlersArgumentsMeta = Symbol('SymbolRouteHandlersArgumentsMeta');
|
|
263
|
-
const SymbolRouteHandlersArgumentsValue = Symbol('SymbolRouteHandlersArgumentsValue');
|
|
264
|
-
|
|
265
91
|
var _dec$2, _dec2$2, _class$2;
|
|
266
92
|
const __ArgumentTypes = ['param', 'query', 'body', 'headers', 'fields', 'field', 'files', 'file'];
|
|
267
93
|
let ServiceOpenapi = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
@@ -297,6 +123,17 @@ let ServiceOpenapi = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
|
297
123
|
if (schema.type === 'object' && schema.required === undefined) schema.required = [];
|
|
298
124
|
// serializerTransforms
|
|
299
125
|
delete schema.serializerTransforms;
|
|
126
|
+
// filter
|
|
127
|
+
if (schema.filter) {
|
|
128
|
+
const filterCapabilities = schema.filter.capabilities;
|
|
129
|
+
if (filterCapabilities) {
|
|
130
|
+
schema.filter = {
|
|
131
|
+
capabilities: filterCapabilities
|
|
132
|
+
};
|
|
133
|
+
} else {
|
|
134
|
+
delete schema.filter;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
300
137
|
// schema
|
|
301
138
|
this._translateStrings(schema, ['title', 'description']);
|
|
302
139
|
if (generateJsonScene === 'api' && !schema.description && schema.title) {
|
|
@@ -632,14 +469,6 @@ function config(_app) {
|
|
|
632
469
|
};
|
|
633
470
|
}
|
|
634
471
|
|
|
635
|
-
var locale_en_us = {
|
|
636
|
-
ZodErrorRequired: 'Required'
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
var locale_zh_cn = {
|
|
640
|
-
ZodErrorRequired: '必填项'
|
|
641
|
-
};
|
|
642
|
-
|
|
643
472
|
function schemaRefCustomAdapter(_app) {
|
|
644
473
|
const registry = new OpenAPIRegistry();
|
|
645
474
|
const generator31 = new OpenApiGeneratorV31(registry.definitions);
|
|
@@ -674,437 +503,10 @@ class Main extends BeanSimple {
|
|
|
674
503
|
}
|
|
675
504
|
|
|
676
505
|
var _dec, _dec2, _class;
|
|
677
|
-
const locales = {
|
|
678
|
-
'en-us': locale_en_us,
|
|
679
|
-
'zh-cn': locale_zh_cn
|
|
680
|
-
};
|
|
681
506
|
let ScopeModuleAOpenapi = (_dec = Scope(), _dec2 = BeanInfo({
|
|
682
507
|
module: "a-openapi"
|
|
683
508
|
}), _dec(_class = _dec2(_class = class ScopeModuleAOpenapi extends BeanScopeBase {}) || _class) || _class);
|
|
684
|
-
function $locale(key) {
|
|
685
|
-
return `a-openapi::${key}`;
|
|
686
|
-
}
|
|
687
|
-
/** scope: end */
|
|
688
|
-
|
|
689
|
-
function schemaEmail(params) {
|
|
690
|
-
return function (_schema) {
|
|
691
|
-
return z.email(params);
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
function schemaUrl(params) {
|
|
695
|
-
return function (_schema) {
|
|
696
|
-
return z.url(params);
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
function schemaUuid(params) {
|
|
700
|
-
return function (_schema) {
|
|
701
|
-
return z.uuid(params);
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
function schemaIPv4(params) {
|
|
705
|
-
return function (_schema) {
|
|
706
|
-
return z.ipv4(params);
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
function schemaIPv6(params) {
|
|
710
|
-
return function (_schema) {
|
|
711
|
-
return z.ipv6(params);
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
function schemaMin(min, params) {
|
|
715
|
-
return function (schema) {
|
|
716
|
-
if (schema.type === 'string') {
|
|
717
|
-
return schema.min(min, params);
|
|
718
|
-
} else {
|
|
719
|
-
return schema.min(min, params);
|
|
720
|
-
}
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
function schemaMax(max, params) {
|
|
724
|
-
return function (schema) {
|
|
725
|
-
if (schema.type === 'string') {
|
|
726
|
-
return schema.max(max, params);
|
|
727
|
-
} else {
|
|
728
|
-
return schema.max(max, params);
|
|
729
|
-
}
|
|
730
|
-
};
|
|
731
|
-
}
|
|
732
|
-
function schemaTrim() {
|
|
733
|
-
return function (schema) {
|
|
734
|
-
return schema.trim();
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
function schemaToLowerCase() {
|
|
738
|
-
return function (schema) {
|
|
739
|
-
return schema.toLowerCase();
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
function schemaToUpperCase() {
|
|
743
|
-
return function (schema) {
|
|
744
|
-
return schema.toUpperCase();
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
function schemaLowercase(params) {
|
|
748
|
-
return function (schema) {
|
|
749
|
-
return schema.lowercase(params);
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
function schemaUppercase(params) {
|
|
753
|
-
return function (schema) {
|
|
754
|
-
return schema.uppercase(params);
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
function schemaRegex(regex, params) {
|
|
758
|
-
return function (schema) {
|
|
759
|
-
return schema.regex(regex, params);
|
|
760
|
-
};
|
|
761
|
-
}
|
|
762
|
-
function schemaTableIdentity() {
|
|
763
|
-
const app = useApp();
|
|
764
|
-
const ormConfig = app.util.getModuleConfigRaw('a-orm');
|
|
765
|
-
const _identityType = ormConfig?.table?.identityType ?? 'bigint';
|
|
766
|
-
return function (_schema) {
|
|
767
|
-
if (_identityType === 'number') {
|
|
768
|
-
return z.number();
|
|
769
|
-
} else if (_identityType === 'bigint') {
|
|
770
|
-
return z.string().regex(/^\d+$/);
|
|
771
|
-
}
|
|
772
|
-
throw new Error('not support');
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
function schemaCaptcha(options) {
|
|
776
|
-
return function (schema) {
|
|
777
|
-
return schema.openapi({
|
|
778
|
-
captcha: options
|
|
779
|
-
});
|
|
780
|
-
};
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
function schemaOpenapi(refId, metadata) {
|
|
784
|
-
return function (schema) {
|
|
785
|
-
return schema.openapi(refId, metadata);
|
|
786
|
-
};
|
|
787
|
-
}
|
|
788
|
-
function schemaTitle(title) {
|
|
789
|
-
return function (schema) {
|
|
790
|
-
return schema.openapi({
|
|
791
|
-
title
|
|
792
|
-
});
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
function schemaDescription(description) {
|
|
796
|
-
return function (schema) {
|
|
797
|
-
return schema.openapi({
|
|
798
|
-
description
|
|
799
|
-
});
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
function schemaExample(example) {
|
|
803
|
-
return function (schema) {
|
|
804
|
-
return schema.openapi({
|
|
805
|
-
example
|
|
806
|
-
});
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
509
|
|
|
810
|
-
|
|
811
|
-
return function (schema) {
|
|
812
|
-
return schema.openapi({
|
|
813
|
-
serializerTransforms: {
|
|
814
|
-
[serializerTransformName]: options
|
|
815
|
-
}
|
|
816
|
-
});
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
function schemaSerializerExclude(param) {
|
|
820
|
-
let options;
|
|
821
|
-
if (!param || typeof param === 'boolean') {
|
|
822
|
-
options = {
|
|
823
|
-
exclude: param
|
|
824
|
-
};
|
|
825
|
-
} else {
|
|
826
|
-
options = param;
|
|
827
|
-
}
|
|
828
|
-
return function (schema) {
|
|
829
|
-
return schema.openapi({
|
|
830
|
-
serializerTransforms: {
|
|
831
|
-
'a-serialization:exclude': options
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
|
-
};
|
|
835
|
-
}
|
|
836
|
-
function schemaSerializerReplace(options) {
|
|
837
|
-
return function (schema) {
|
|
838
|
-
return schema.openapi({
|
|
839
|
-
serializerTransforms: {
|
|
840
|
-
'a-serialization:replace': options
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
function schemaSerializerGetter(param) {
|
|
846
|
-
let options;
|
|
847
|
-
if (typeof param === 'function') {
|
|
848
|
-
options = {
|
|
849
|
-
getter: param
|
|
850
|
-
};
|
|
851
|
-
} else {
|
|
852
|
-
options = param;
|
|
853
|
-
}
|
|
854
|
-
return function (schema) {
|
|
855
|
-
return schema.openapi({
|
|
856
|
-
serializerTransforms: {
|
|
857
|
-
'a-serialization:getter': options
|
|
858
|
-
}
|
|
859
|
-
});
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
function schemaSerializerCustom(param) {
|
|
863
|
-
let options;
|
|
864
|
-
if (typeof param === 'function') {
|
|
865
|
-
options = {
|
|
866
|
-
custom: param
|
|
867
|
-
};
|
|
868
|
-
} else {
|
|
869
|
-
options = param;
|
|
870
|
-
}
|
|
871
|
-
return function (schema) {
|
|
872
|
-
return schema.openapi({
|
|
873
|
-
serializerTransforms: {
|
|
874
|
-
'a-serialization:custom': options
|
|
875
|
-
}
|
|
876
|
-
});
|
|
877
|
-
};
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
function schemaDefault(defaultValue) {
|
|
881
|
-
return function (schema) {
|
|
882
|
-
return schema.default(defaultValue);
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
|
-
function schemaOptional() {
|
|
886
|
-
return function (schema) {
|
|
887
|
-
return schema.optional();
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
function schemaLazy(...schemaLikes) {
|
|
891
|
-
return function (_schema) {
|
|
892
|
-
return $schemaLazy(...schemaLikes);
|
|
893
|
-
};
|
|
894
|
-
}
|
|
895
|
-
function schemaObject(classType, options) {
|
|
896
|
-
return function (_schema) {
|
|
897
|
-
return $schema(classType, options);
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
function schemaArray(schemaLike, params) {
|
|
901
|
-
return function (schema) {
|
|
902
|
-
return z.preprocess(val => {
|
|
903
|
-
val = coerceWithNil(val);
|
|
904
|
-
if (isNil(val)) return val;
|
|
905
|
-
if (typeof val !== 'string') return val;
|
|
906
|
-
if (val.startsWith('[') && val.endsWith(']')) return JSON.parse(val);
|
|
907
|
-
return val.split(params?.separator ?? ',');
|
|
908
|
-
}, z.array(makeSchemaLike(schemaLike ?? schema, z.any()), params)
|
|
909
|
-
// z.array(makeSchemaLike(schemaLike, schema), params),
|
|
910
|
-
);
|
|
911
|
-
};
|
|
912
|
-
}
|
|
913
|
-
function schemaStrictObject() {
|
|
914
|
-
return function (schema) {
|
|
915
|
-
return z.strictObject(schema.shape);
|
|
916
|
-
};
|
|
917
|
-
}
|
|
918
|
-
function schemaLooseObject() {
|
|
919
|
-
return function (schema) {
|
|
920
|
-
return z.looseObject(schema.shape);
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
function schemaRequired(params) {
|
|
924
|
-
params = params || $locale('ZodErrorRequired');
|
|
925
|
-
return function (schema) {
|
|
926
|
-
schema._zod.def.error = z.util.normalizeParams(params).error;
|
|
927
|
-
return schema;
|
|
928
|
-
};
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
function schemaZodRefine(zodRefineName, options) {
|
|
932
|
-
return function (schema) {
|
|
933
|
-
return schema.superRefine(async (value, refinementCtx) => {
|
|
934
|
-
const app = useApp();
|
|
935
|
-
const options2 = app.bean.onion.zodRefine.getOnionOptionsDynamic(zodRefineName, options);
|
|
936
|
-
// execute
|
|
937
|
-
const beanFullName = beanFullNameFromOnionName(zodRefineName, 'zodRefine');
|
|
938
|
-
const beanInstance = app.bean._getBean(beanFullName);
|
|
939
|
-
if (!beanInstance) {
|
|
940
|
-
throw new Error(`zodRefine bean not found: ${beanFullName}`);
|
|
941
|
-
}
|
|
942
|
-
return await beanInstance.execute(value, refinementCtx, options2);
|
|
943
|
-
});
|
|
944
|
-
};
|
|
945
|
-
}
|
|
946
|
-
function schemaZodTransform(zodTransformName, options) {
|
|
947
|
-
return function (schema) {
|
|
948
|
-
return schema.transform(async value => {
|
|
949
|
-
const app = useApp();
|
|
950
|
-
const options2 = app.bean.onion.zodTransform.getOnionOptionsDynamic(zodTransformName, options);
|
|
951
|
-
// execute
|
|
952
|
-
const beanFullName = beanFullNameFromOnionName(zodTransformName, 'zodTransform');
|
|
953
|
-
const beanInstance = app.bean._getBean(beanFullName);
|
|
954
|
-
if (!beanInstance) {
|
|
955
|
-
throw new Error(`zodTransform bean not found: ${beanFullName}`);
|
|
956
|
-
}
|
|
957
|
-
return await beanInstance.execute(value, options2);
|
|
958
|
-
});
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
const v = {
|
|
963
|
-
required: schemaRequired,
|
|
964
|
-
optional: schemaOptional,
|
|
965
|
-
default: schemaDefault,
|
|
966
|
-
object: schemaObject,
|
|
967
|
-
strictObject: schemaStrictObject,
|
|
968
|
-
looseObject: schemaLooseObject,
|
|
969
|
-
array: schemaArray,
|
|
970
|
-
lazy: schemaLazy,
|
|
971
|
-
// helpers
|
|
972
|
-
email: schemaEmail,
|
|
973
|
-
url: schemaUrl,
|
|
974
|
-
uuid: schemaUuid,
|
|
975
|
-
ipv4: schemaIPv4,
|
|
976
|
-
ipv6: schemaIPv6,
|
|
977
|
-
min: schemaMin,
|
|
978
|
-
max: schemaMax,
|
|
979
|
-
trim: schemaTrim,
|
|
980
|
-
toLowerCase: schemaToLowerCase,
|
|
981
|
-
toUpperCase: schemaToUpperCase,
|
|
982
|
-
lowercase: schemaLowercase,
|
|
983
|
-
uppercase: schemaUppercase,
|
|
984
|
-
regex: schemaRegex,
|
|
985
|
-
tableIdentity: schemaTableIdentity,
|
|
986
|
-
captcha: schemaCaptcha,
|
|
987
|
-
serializerExclude: schemaSerializerExclude,
|
|
988
|
-
serializerTransform: schemaSerializerTransform,
|
|
989
|
-
serializerReplace: schemaSerializerReplace,
|
|
990
|
-
serializerGetter: schemaSerializerGetter,
|
|
991
|
-
serializerCustom: schemaSerializerCustom,
|
|
992
|
-
// openapi
|
|
993
|
-
openapi: schemaOpenapi,
|
|
994
|
-
title: schemaTitle,
|
|
995
|
-
description: schemaDescription,
|
|
996
|
-
example: schemaExample,
|
|
997
|
-
// zod
|
|
998
|
-
refine: schemaZodRefine,
|
|
999
|
-
transform: schemaZodTransform
|
|
1000
|
-
};
|
|
1001
|
-
|
|
1002
|
-
function Field(...schemaLikes) {
|
|
1003
|
-
return function (target, prop, descriptor) {
|
|
1004
|
-
const metaType = appMetadata.getDesignType(target, prop);
|
|
1005
|
-
const schema = makeSchemaLikes(schemaLikes, metaType);
|
|
1006
|
-
const rules = mergeFieldOpenapiMetadata(target, prop, schema);
|
|
1007
|
-
if (descriptor?.get) {
|
|
1008
|
-
rules[prop] = v.serializerGetter(descriptor.get)(rules[prop]);
|
|
1009
|
-
}
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
function httpCode(httpCode) {
|
|
1014
|
-
return function (target, prop, descriptor) {
|
|
1015
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
1016
|
-
options.httpCode = httpCode;
|
|
1017
|
-
return descriptor;
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
function contentType(contentType) {
|
|
1021
|
-
return function (target, prop, descriptor) {
|
|
1022
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
1023
|
-
options.contentType = contentType;
|
|
1024
|
-
return descriptor;
|
|
1025
|
-
};
|
|
1026
|
-
}
|
|
1027
|
-
function body(...schemaLikes) {
|
|
1028
|
-
return function (target, prop, descriptor) {
|
|
1029
|
-
// schema
|
|
1030
|
-
const metaType = appMetadata.getDesignReturntype(target, prop);
|
|
1031
|
-
const schema = makeSchemaLikes(schemaLikes, metaType);
|
|
1032
|
-
// options
|
|
1033
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
1034
|
-
options.bodySchema = schema;
|
|
1035
|
-
return descriptor;
|
|
1036
|
-
};
|
|
1037
|
-
}
|
|
1038
|
-
function bodyCustom(bodySchemaWrapper, ...schemaLikes) {
|
|
1039
|
-
return function (target, prop, descriptor) {
|
|
1040
|
-
// schema
|
|
1041
|
-
const metaType = appMetadata.getDesignReturntype(target, prop);
|
|
1042
|
-
const schema = makeSchemaLikes(schemaLikes, metaType);
|
|
1043
|
-
// options
|
|
1044
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
1045
|
-
options.bodySchema = schema;
|
|
1046
|
-
options.bodySchemaWrapper = bodySchemaWrapper;
|
|
1047
|
-
return descriptor;
|
|
1048
|
-
};
|
|
1049
|
-
}
|
|
1050
|
-
function exclude() {
|
|
1051
|
-
return function (target, prop, descriptor) {
|
|
1052
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
1053
|
-
options.exclude = true;
|
|
1054
|
-
return descriptor;
|
|
1055
|
-
};
|
|
1056
|
-
}
|
|
1057
|
-
function tags(tags) {
|
|
1058
|
-
return function (target, prop, descriptor) {
|
|
1059
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
1060
|
-
options.tags = tags;
|
|
1061
|
-
return descriptor;
|
|
1062
|
-
};
|
|
1063
|
-
}
|
|
1064
|
-
function header(header) {
|
|
1065
|
-
return function (target, prop, descriptor) {
|
|
1066
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
1067
|
-
if (!options.headers) options.headers = [];
|
|
1068
|
-
options.headers.push(header);
|
|
1069
|
-
return descriptor;
|
|
1070
|
-
};
|
|
1071
|
-
}
|
|
1072
|
-
function headers(headers) {
|
|
1073
|
-
return function (target, prop, descriptor) {
|
|
1074
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
1075
|
-
if (!options.headers) options.headers = [];
|
|
1076
|
-
options.headers.push(...headers);
|
|
1077
|
-
return descriptor;
|
|
1078
|
-
};
|
|
1079
|
-
}
|
|
1080
|
-
function setHeader(field, val) {
|
|
1081
|
-
return function (target, prop, descriptor) {
|
|
1082
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
1083
|
-
if (!options.setHeaders) options.setHeaders = {};
|
|
1084
|
-
if (typeof field === 'string') {
|
|
1085
|
-
options.setHeaders[field] = val;
|
|
1086
|
-
} else {
|
|
1087
|
-
Object.assign(options.setHeaders, field);
|
|
1088
|
-
}
|
|
1089
|
-
return descriptor;
|
|
1090
|
-
};
|
|
1091
|
-
}
|
|
1092
|
-
const Api = {
|
|
1093
|
-
field: Field,
|
|
1094
|
-
httpCode,
|
|
1095
|
-
contentType,
|
|
1096
|
-
body,
|
|
1097
|
-
bodyCustom,
|
|
1098
|
-
exclude,
|
|
1099
|
-
tags,
|
|
1100
|
-
header,
|
|
1101
|
-
headers,
|
|
1102
|
-
setHeader
|
|
1103
|
-
};
|
|
1104
|
-
|
|
1105
|
-
const OrderCoreBase = 100;
|
|
1106
|
-
const OrderBusinessBase = 1000;
|
|
1107
|
-
const OrderUnknownBase = 10000;
|
|
1108
|
-
const OrderMaxBase = 100000;
|
|
510
|
+
/** scope: end */
|
|
1109
511
|
|
|
1110
|
-
export {
|
|
512
|
+
export { BeanOpenapi, Main, ScopeModuleAOpenapi, ServiceOpenapi, SummerCacheJson, config, schemaRefCustomAdapter };
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -21,6 +21,4 @@ export interface RouteHandlerArgumentMeta {
|
|
|
21
21
|
index: number;
|
|
22
22
|
}
|
|
23
23
|
export type RouteHandlerArgumentType = 'request' | 'response' | 'body' | 'query' | 'param' | 'headers' | 'session' | 'fields' | 'field' | 'files' | 'file' | 'host' | 'ip' | 'rawBody' | 'string' | 'user';
|
|
24
|
-
export declare const SymbolRouteHandlersArgumentsMeta: unique symbol;
|
|
25
|
-
export declare const SymbolRouteHandlersArgumentsValue: unique symbol;
|
|
26
24
|
export type TypeExtractValue = (ctx: VonaContext, argMeta: RouteHandlerArgumentMetaDecorator) => Promise<any>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import '@cabloy/zod-query';
|
|
2
2
|
export * from './actions.ts';
|
|
3
3
|
export * from './behavior.ts';
|
|
4
|
+
export * from './captcha.ts';
|
|
4
5
|
export * from './component.ts';
|
|
5
|
-
export * from './database.ts';
|
|
6
6
|
export * from './decorator.ts';
|
|
7
|
-
export * from './query.ts';
|
|
8
7
|
export * from './rest.ts';
|
package/dist/types/rest.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import type { z } from 'zod';
|
|
|
5
5
|
import type { TypeResourceActionRowRecordRender } from './actions.ts';
|
|
6
6
|
import type { ISchemaObjectExtensionFieldCaptcha } from './captcha.ts';
|
|
7
7
|
import type { IComponentRecord } from './component.ts';
|
|
8
|
-
import type { ISchemaObjectExtensionFieldQuery } from './query.ts';
|
|
9
8
|
import 'openapi3-ts/oas30';
|
|
10
9
|
import 'openapi3-ts/oas31';
|
|
11
10
|
export interface ISchemaObjectExtensionFieldRest {
|
|
@@ -18,7 +17,6 @@ export interface ISchemaObjectExtensionFieldRest {
|
|
|
18
17
|
}
|
|
19
18
|
export interface ISchemaObjectExtensionField {
|
|
20
19
|
rest?: ISchemaObjectExtensionFieldRest;
|
|
21
|
-
query?: ISchemaObjectExtensionFieldQuery;
|
|
22
20
|
captcha?: ISchemaObjectExtensionFieldCaptcha;
|
|
23
21
|
}
|
|
24
22
|
declare module 'openapi3-ts/oas30' {
|
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.55",
|
|
5
5
|
"title": "a-openapi",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"capabilities": {
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@cabloy/zod-openapi": "^1.0.
|
|
38
|
+
"@cabloy/zod-openapi": "^1.0.6",
|
|
39
39
|
"@cabloy/zod-query": "^2.0.3",
|
|
40
40
|
"@cabloy/zod-to-openapi": "^8.1.4",
|
|
41
41
|
"@zhennann/currency": "^2.0.0",
|
|
42
42
|
"openapi3-ts": "^4.5.0",
|
|
43
|
-
"zod": "^4.1.
|
|
43
|
+
"zod": "^4.1.13"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"clean-package": "^2.2.0",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { IOpenApiHeader, SchemaLike, SchemaLikeCreate, TypeResponseContentType } from 'vona-module-a-openapiutils';
|
|
2
|
-
import { Field } from './field.ts';
|
|
3
|
-
declare function httpCode(httpCode: number): MethodDecorator;
|
|
4
|
-
declare function contentType(contentType: TypeResponseContentType): MethodDecorator;
|
|
5
|
-
declare function body(...schemaLikes: SchemaLike[]): MethodDecorator;
|
|
6
|
-
declare function bodyCustom(bodySchemaWrapper: SchemaLikeCreate | false, ...schemaLikes: SchemaLike[]): MethodDecorator;
|
|
7
|
-
declare function exclude(): ClassDecorator & MethodDecorator;
|
|
8
|
-
declare function tags(tags: string[]): ClassDecorator & MethodDecorator;
|
|
9
|
-
declare function header(header: IOpenApiHeader): ClassDecorator & MethodDecorator;
|
|
10
|
-
declare function headers(headers: IOpenApiHeader[]): ClassDecorator & MethodDecorator;
|
|
11
|
-
declare function setHeader(field: {
|
|
12
|
-
[key: string]: string | string[];
|
|
13
|
-
}): ClassDecorator & MethodDecorator;
|
|
14
|
-
declare function setHeader(field: string, val: string | string[]): ClassDecorator & MethodDecorator;
|
|
15
|
-
export declare const Api: {
|
|
16
|
-
field: typeof Field;
|
|
17
|
-
httpCode: typeof httpCode;
|
|
18
|
-
contentType: typeof contentType;
|
|
19
|
-
body: typeof body;
|
|
20
|
-
bodyCustom: typeof bodyCustom;
|
|
21
|
-
exclude: typeof exclude;
|
|
22
|
-
tags: typeof tags;
|
|
23
|
-
header: typeof header;
|
|
24
|
-
headers: typeof headers;
|
|
25
|
-
setHeader: typeof setHeader;
|
|
26
|
-
};
|
|
27
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './api.ts';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { SchemaLike } from 'vona-module-a-openapiutils';
|
|
2
|
-
import type { z } from 'zod';
|
|
3
|
-
export declare function $makeSchema(...schemaLikes: SchemaLike[]): z.ZodType;
|
|
4
|
-
export declare function makeSchemaLikes<T>(schemaLikes: SchemaLike<T> | SchemaLike<T>[], typeInit: any): z.ZodType<T>;
|
|
5
|
-
export declare function makeSchemaLike<T>(schemaLike: SchemaLike<T> | undefined, schemaPrevious: z.ZodType<T>): z.ZodType<T>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Constructable } from 'vona';
|
|
2
|
-
import type { SchemaLike } from 'vona-module-a-openapiutils';
|
|
3
|
-
import type { ISchemaObjectOptions } from '../../types/decorator.ts';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
export declare function $schema<T>(schemaLike: z.ZodType<T>): z.ZodType<T>;
|
|
6
|
-
export declare function $schema(classType: StringConstructor): z.ZodString;
|
|
7
|
-
export declare function $schema(classType: NumberConstructor): z.ZodNumber;
|
|
8
|
-
export declare function $schema(classType: BooleanConstructor): z.ZodBoolean;
|
|
9
|
-
export declare function $schema(classType: DateConstructor): z.ZodDate;
|
|
10
|
-
export declare function $schema(classType: BigIntConstructor): z.ZodBigInt;
|
|
11
|
-
export declare function $schema(classType: ArrayConstructor): z.ZodArray<z.ZodAny>;
|
|
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,5 +0,0 @@
|
|
|
1
|
-
import type { Constructable } from 'vona';
|
|
2
|
-
export declare const SymbolSchemaDynamicRefId: unique symbol;
|
|
3
|
-
export declare function addSchemaDynamic(dynamicName: string, classType: Constructable): void;
|
|
4
|
-
export declare function getSchemaDynamic(dynamicName: string): Constructable;
|
|
5
|
-
export declare function getSchemasDynamic(): Record<string, Constructable>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ISchemaObjectExtensionFieldCaptcha } from '../../../types/captcha.ts';
|
|
2
|
-
import { z } from 'zod';
|
|
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 schemaCaptcha(options: ISchemaObjectExtensionFieldCaptcha): (schema: z.ZodType) => z.ZodType;
|
|
@@ -1,7 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ISerializerTransformOptionsCustom, ISerializerTransformOptionsExclude, ISerializerTransformOptionsGetter, ISerializerTransformRecord, TypeSerializerTransformCustom, TypeSerializerTransformGetter } from 'vona-module-a-serialization';
|
|
2
|
-
import type z from 'zod';
|
|
3
|
-
export declare function schemaSerializerTransform<T extends keyof ISerializerTransformRecord>(serializerTransformName: T, options?: Partial<ISerializerTransformRecord[T]>): (schema: z.ZodType) => z.ZodType;
|
|
4
|
-
export declare function schemaSerializerExclude(options: Partial<ISerializerTransformOptionsExclude>): any;
|
|
5
|
-
export declare function schemaSerializerExclude(exclude?: boolean): any;
|
|
6
|
-
export declare function schemaSerializerReplace(options: ISerializerTransformRecord['a-serialization:replace']): (schema: z.ZodType) => z.ZodType;
|
|
7
|
-
export declare function schemaSerializerGetter(options: Partial<ISerializerTransformOptionsGetter>): any;
|
|
8
|
-
export declare function schemaSerializerGetter(getter: TypeSerializerTransformGetter): any;
|
|
9
|
-
export declare function schemaSerializerCustom(options: Partial<ISerializerTransformOptionsCustom>): any;
|
|
10
|
-
export declare function schemaSerializerCustom(getter: TypeSerializerTransformCustom): any;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Constructable } from 'vona';
|
|
2
|
-
import type { SchemaLike } from 'vona-module-a-openapiutils';
|
|
3
|
-
import type { ISchemaObjectOptions } from '../../../types/decorator.ts';
|
|
4
|
-
import { z } from 'zod';
|
|
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
|
-
separator?: string;
|
|
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;
|
|
14
|
-
export declare function schemaRequired(params?: string | z.core.$ZodStringParams): (schema: z.ZodType) => z.ZodType;
|
|
@@ -1,4 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { schemaCaptcha, schemaEmail, schemaIPv4, schemaIPv6, schemaLowercase, schemaMax, schemaMin, schemaRegex, schemaTableIdentity, schemaToLowerCase, schemaToUpperCase, schemaTrim, schemaUppercase, schemaUrl, schemaUuid } from './v/helpers.ts';
|
|
2
|
-
import { schemaDescription, schemaExample, schemaOpenapi, schemaTitle } from './v/openapi.ts';
|
|
3
|
-
import { schemaSerializerCustom, schemaSerializerExclude, schemaSerializerGetter, schemaSerializerReplace, schemaSerializerTransform } from './v/serializer.ts';
|
|
4
|
-
import { schemaArray, schemaDefault, schemaLazy, schemaLooseObject, schemaObject, schemaOptional, schemaRequired, schemaStrictObject } from './v/system.ts';
|
|
5
|
-
import { schemaZodRefine, schemaZodTransform } from './v/zod.ts';
|
|
6
|
-
export declare const v: {
|
|
7
|
-
required: typeof schemaRequired;
|
|
8
|
-
optional: typeof schemaOptional;
|
|
9
|
-
default: typeof schemaDefault;
|
|
10
|
-
object: typeof schemaObject;
|
|
11
|
-
strictObject: typeof schemaStrictObject;
|
|
12
|
-
looseObject: typeof schemaLooseObject;
|
|
13
|
-
array: typeof schemaArray;
|
|
14
|
-
lazy: typeof schemaLazy;
|
|
15
|
-
email: typeof schemaEmail;
|
|
16
|
-
url: typeof schemaUrl;
|
|
17
|
-
uuid: typeof schemaUuid;
|
|
18
|
-
ipv4: typeof schemaIPv4;
|
|
19
|
-
ipv6: typeof schemaIPv6;
|
|
20
|
-
min: typeof schemaMin;
|
|
21
|
-
max: typeof schemaMax;
|
|
22
|
-
trim: typeof schemaTrim;
|
|
23
|
-
toLowerCase: typeof schemaToLowerCase;
|
|
24
|
-
toUpperCase: typeof schemaToUpperCase;
|
|
25
|
-
lowercase: typeof schemaLowercase;
|
|
26
|
-
uppercase: typeof schemaUppercase;
|
|
27
|
-
regex: typeof schemaRegex;
|
|
28
|
-
tableIdentity: typeof schemaTableIdentity;
|
|
29
|
-
captcha: typeof schemaCaptcha;
|
|
30
|
-
serializerExclude: typeof schemaSerializerExclude;
|
|
31
|
-
serializerTransform: typeof schemaSerializerTransform;
|
|
32
|
-
serializerReplace: typeof schemaSerializerReplace;
|
|
33
|
-
serializerGetter: typeof schemaSerializerGetter;
|
|
34
|
-
serializerCustom: typeof schemaSerializerCustom;
|
|
35
|
-
openapi: typeof schemaOpenapi;
|
|
36
|
-
title: typeof schemaTitle;
|
|
37
|
-
description: typeof schemaDescription;
|
|
38
|
-
example: typeof schemaExample;
|
|
39
|
-
refine: typeof schemaZodRefine;
|
|
40
|
-
transform: typeof schemaZodTransform;
|
|
41
|
-
};
|
package/dist/lib/utils.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Constructable } from 'vona';
|
|
2
|
-
import type { TypeDecoratorRules } from 'vona-module-a-openapiutils';
|
|
3
|
-
import type { TypeOpenapiMetadata } from '../types/rest.ts';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
export declare function getTargetDecoratorRules(target: object, disableRegisterMetadata?: boolean): TypeDecoratorRules;
|
|
6
|
-
export declare function getTargetDecoratorRuleColumns(target: object): string[];
|
|
7
|
-
export declare function getTargetDecoratorRuleColumnsMap(target: object): Record<string, string>;
|
|
8
|
-
export declare function mergeFieldsOpenapiMetadata(target: Constructable): void;
|
|
9
|
-
export declare function mergeFieldOpenapiMetadata(target: object, prop: string, fieldRule?: TypeOpenapiMetadata | z.ZodType): TypeDecoratorRules;
|
|
10
|
-
export declare function prepareClassType<T>(classType: (() => Constructable<T>) | Constructable<T>): Constructable<T>;
|
package/dist/types/database.d.ts
DELETED
package/dist/types/query.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|