vona-module-a-openapi 5.0.12 → 5.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +779 -3
- package/package.json +2 -2
- package/dist/.metadata/index.js +0 -39
- package/dist/.metadata/this.js +0 -2
- package/dist/config/config.js +0 -30
- package/dist/config/locale/en-us.js +0 -2
- package/dist/config/locale/zh-cn.js +0 -2
- package/dist/lib/decorator/api.js +0 -71
- package/dist/lib/decorator/arguments.js +0 -39
- package/dist/lib/decorator/field.js +0 -15
- package/dist/lib/decorator/index.js +0 -3
- package/dist/lib/decorator/pipesArgument.js +0 -35
- package/dist/lib/index.js +0 -4
- package/dist/lib/schema/bodySchemaWrapper.js +0 -8
- package/dist/lib/schema/index.js +0 -4
- package/dist/lib/schema/makeSchemaLikes.js +0 -29
- package/dist/lib/schema/schema.js +0 -40
- package/dist/lib/schema/v/helpers.js +0 -36
- package/dist/lib/schema/v/openapi.js +0 -20
- package/dist/lib/schema/v/system.js +0 -34
- package/dist/lib/schema/v.js +0 -22
- package/dist/lib/utils.js +0 -43
- package/dist/lib/zod/errorUtil.js +0 -1
- package/dist/lib/zod/errorsAdapter.js +0 -9
- package/dist/lib/zod/index.js +0 -2
- package/dist/main.js +0 -9
- package/dist/service/openapi.js +0 -352
- package/dist/types/actions.js +0 -1
- package/dist/types/api.js +0 -1
- package/dist/types/behavior.js +0 -1
- package/dist/types/component.js +0 -1
- package/dist/types/database.js +0 -4
- package/dist/types/decorator.js +0 -4
- package/dist/types/index.js +0 -8
- package/dist/types/rest.js +0 -2
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.13",
|
|
5
5
|
"title": "a-openapi",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"capabilities": {
|
|
@@ -47,6 +47,6 @@
|
|
|
47
47
|
"gitHead": "0eab9dc4a5622caffe89e7b1b3f02c08ccbc4c4b",
|
|
48
48
|
"scripts": {
|
|
49
49
|
"clean": "rimraf dist tsconfig.build.tsbuildinfo",
|
|
50
|
-
"tsc:publish": "npm run clean && tsc -p tsconfig.build.json"
|
|
50
|
+
"tsc:publish": "npm run clean && vona :bin:buildModule && tsc -p tsconfig.build.json"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/dist/.metadata/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
/** main: end */
|
|
8
|
-
/** scope: begin */
|
|
9
|
-
import { BeanScopeBase } from 'vona';
|
|
10
|
-
import { Scope } from 'vona-module-a-bean';
|
|
11
|
-
/** config: end */
|
|
12
|
-
/** locale: begin */
|
|
13
|
-
import locale_en_us from "../config/locale/en-us.js";
|
|
14
|
-
import locale_zh_cn from "../config/locale/zh-cn.js";
|
|
15
|
-
/** service: end */
|
|
16
|
-
/** config: begin */
|
|
17
|
-
import 'vona';
|
|
18
|
-
import 'vona';
|
|
19
|
-
import 'vona';
|
|
20
|
-
export * from "../config/config.js";
|
|
21
|
-
/** locale: end */
|
|
22
|
-
/** main: begin */
|
|
23
|
-
export * from "../main.js";
|
|
24
|
-
export const locales = {
|
|
25
|
-
'en-us': locale_en_us,
|
|
26
|
-
'zh-cn': locale_zh_cn,
|
|
27
|
-
};
|
|
28
|
-
/** service: begin */
|
|
29
|
-
export * from "../service/openapi.js";
|
|
30
|
-
let ScopeModuleAOpenapi = class ScopeModuleAOpenapi extends BeanScopeBase {
|
|
31
|
-
};
|
|
32
|
-
ScopeModuleAOpenapi = __decorate([
|
|
33
|
-
Scope()
|
|
34
|
-
], ScopeModuleAOpenapi);
|
|
35
|
-
export { ScopeModuleAOpenapi };
|
|
36
|
-
export function $locale(key) {
|
|
37
|
-
return `a-openapi::${key}`;
|
|
38
|
-
}
|
|
39
|
-
/** scope: end */
|
package/dist/.metadata/this.js
DELETED
package/dist/config/config.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export function config(_app) {
|
|
2
|
-
return {
|
|
3
|
-
defaultVersion: 'V31',
|
|
4
|
-
generateDocument: {
|
|
5
|
-
V30: {
|
|
6
|
-
openapi: '3.0.0',
|
|
7
|
-
info: {
|
|
8
|
-
version: '5.0.0',
|
|
9
|
-
title: 'Vona',
|
|
10
|
-
description: 'Vona API',
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
V31: {
|
|
14
|
-
openapi: '3.1.0',
|
|
15
|
-
info: {
|
|
16
|
-
version: '5.0.0',
|
|
17
|
-
title: 'Vona',
|
|
18
|
-
description: 'Vona API',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
securitySchemes: {
|
|
23
|
-
bearerAuth: {
|
|
24
|
-
type: 'http',
|
|
25
|
-
scheme: 'bearer',
|
|
26
|
-
bearerFormat: 'JWT',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { appMetadata } from 'vona';
|
|
2
|
-
import { SymbolOpenApiOptions } from "../../types/api.js";
|
|
3
|
-
import { makeSchemaLikes } from "../schema/makeSchemaLikes.js";
|
|
4
|
-
import { Field } from "./field.js";
|
|
5
|
-
export function setPublic(target, prop, _descriptor, value) {
|
|
6
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
7
|
-
options.public = value;
|
|
8
|
-
}
|
|
9
|
-
function contentType(contentType) {
|
|
10
|
-
return function (target, prop, descriptor) {
|
|
11
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
12
|
-
options.contentType = contentType;
|
|
13
|
-
return descriptor;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function body(...schemaLikes) {
|
|
17
|
-
return function (target, prop, descriptor) {
|
|
18
|
-
// schema
|
|
19
|
-
const metaType = appMetadata.getDesignReturntype(target, prop);
|
|
20
|
-
const schema = makeSchemaLikes(schemaLikes, metaType);
|
|
21
|
-
// options
|
|
22
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
23
|
-
options.bodySchema = schema;
|
|
24
|
-
return descriptor;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function bodyCustom(bodySchemaWrapper, ...schemaLikes) {
|
|
28
|
-
return function (target, prop, descriptor) {
|
|
29
|
-
// schema
|
|
30
|
-
const metaType = appMetadata.getDesignReturntype(target, prop);
|
|
31
|
-
const schema = makeSchemaLikes(schemaLikes, metaType);
|
|
32
|
-
// options
|
|
33
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
34
|
-
options.bodySchema = schema;
|
|
35
|
-
options.bodySchemaWrapper = bodySchemaWrapper;
|
|
36
|
-
return descriptor;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function exclude() {
|
|
40
|
-
return function (target, prop, descriptor) {
|
|
41
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
42
|
-
options.exclude = true;
|
|
43
|
-
return descriptor;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function tags(tags) {
|
|
47
|
-
return function (target, prop, descriptor) {
|
|
48
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
49
|
-
options.tags = tags;
|
|
50
|
-
return descriptor;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function header(header) {
|
|
54
|
-
return function (target, prop, descriptor) {
|
|
55
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
56
|
-
if (!options.headers)
|
|
57
|
-
options.headers = [];
|
|
58
|
-
options.headers.push(header);
|
|
59
|
-
return descriptor;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function headers(headers) {
|
|
63
|
-
return function (target, prop, descriptor) {
|
|
64
|
-
const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
|
|
65
|
-
if (!options.headers)
|
|
66
|
-
options.headers = [];
|
|
67
|
-
options.headers.push(...headers);
|
|
68
|
-
return descriptor;
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
export const Api = { field: Field, contentType, body, bodyCustom, exclude, tags, header, headers };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { createPipesArgumentDecorator } from "./pipesArgument.js";
|
|
2
|
-
function Param(property, ...schemaLikes) {
|
|
3
|
-
return createPipesArgumentDecorator('param')(property, ...schemaLikes);
|
|
4
|
-
}
|
|
5
|
-
function Query(property, ...schemaLikes) {
|
|
6
|
-
return createPipesArgumentDecorator('query')(property, ...schemaLikes);
|
|
7
|
-
}
|
|
8
|
-
function Body(property, ...schemaLikes) {
|
|
9
|
-
return createPipesArgumentDecorator('body')(property, ...schemaLikes);
|
|
10
|
-
}
|
|
11
|
-
function Headers(property, ...schemaLikes) {
|
|
12
|
-
return createPipesArgumentDecorator('headers')(property, ...schemaLikes);
|
|
13
|
-
}
|
|
14
|
-
function Fields(property, ...schemaLikes) {
|
|
15
|
-
return createPipesArgumentDecorator('fields')(property, ...schemaLikes);
|
|
16
|
-
}
|
|
17
|
-
function Field(property, ...schemaLikes) {
|
|
18
|
-
return createPipesArgumentDecorator('field')(property, ...schemaLikes);
|
|
19
|
-
}
|
|
20
|
-
function Files(property, ...schemaLikes) {
|
|
21
|
-
return createPipesArgumentDecorator('files')(property, ...schemaLikes);
|
|
22
|
-
}
|
|
23
|
-
function File(property, ...schemaLikes) {
|
|
24
|
-
return createPipesArgumentDecorator('file')(property, ...schemaLikes);
|
|
25
|
-
}
|
|
26
|
-
function User(...schemaLikes) {
|
|
27
|
-
return createPipesArgumentDecorator('user')(undefined, ...schemaLikes);
|
|
28
|
-
}
|
|
29
|
-
export const Arg = {
|
|
30
|
-
param: Param,
|
|
31
|
-
query: Query,
|
|
32
|
-
body: Body,
|
|
33
|
-
headers: Headers,
|
|
34
|
-
fields: Fields,
|
|
35
|
-
field: Field,
|
|
36
|
-
files: Files,
|
|
37
|
-
file: File,
|
|
38
|
-
user: User,
|
|
39
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { appMetadata } from 'vona';
|
|
2
|
-
import { makeSchemaLikes } from "../schema/makeSchemaLikes.js";
|
|
3
|
-
import { getTargetDecoratorRuleColumns, getTargetDecoratorRules } from "../utils.js";
|
|
4
|
-
export function Field(...schemaLikes) {
|
|
5
|
-
return function (target, prop) {
|
|
6
|
-
// rules
|
|
7
|
-
const rules = getTargetDecoratorRules(target);
|
|
8
|
-
// rule
|
|
9
|
-
const metaType = appMetadata.getDesignType(target, prop);
|
|
10
|
-
rules[prop] = makeSchemaLikes(schemaLikes, metaType);
|
|
11
|
-
//
|
|
12
|
-
const columns = getTargetDecoratorRuleColumns(target);
|
|
13
|
-
columns[prop] = prop;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { appMetadata } from 'vona';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { SymbolRouteHandlersArgumentsMeta, } from "../../types/decorator.js";
|
|
4
|
-
import { makeSchemaLikes } from "../schema/makeSchemaLikes.js";
|
|
5
|
-
export function createPipesArgumentDecorator(paramType, extractValue) {
|
|
6
|
-
return function (field, ...schemaLikes) {
|
|
7
|
-
return function (target, prop, index) {
|
|
8
|
-
// not inherit
|
|
9
|
-
const argsMeta = appMetadata.getOwnMetadataArray(false, SymbolRouteHandlersArgumentsMeta, target, prop);
|
|
10
|
-
const hasParamField = typeof field === 'string';
|
|
11
|
-
const paramField = hasParamField ? field : undefined;
|
|
12
|
-
const paramSchemaLikes = hasParamField ? schemaLikes : [field, ...schemaLikes].filter(item => !!item);
|
|
13
|
-
const paramtypes = appMetadata.getMetadata('design:paramtypes', target, prop);
|
|
14
|
-
let metaType;
|
|
15
|
-
if (paramType === 'file') {
|
|
16
|
-
metaType = z.string().openapi({ format: 'binary' });
|
|
17
|
-
}
|
|
18
|
-
else if (paramType === 'files') {
|
|
19
|
-
metaType = z.array(z.string().openapi({ format: 'binary' }));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
metaType = paramtypes[index];
|
|
23
|
-
}
|
|
24
|
-
const argSchema = makeSchemaLikes(paramSchemaLikes, metaType);
|
|
25
|
-
argsMeta.push({
|
|
26
|
-
index,
|
|
27
|
-
type: paramType,
|
|
28
|
-
field: paramField,
|
|
29
|
-
pipes: [argSchema],
|
|
30
|
-
schema: argSchema,
|
|
31
|
-
extractValue,
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
}
|
package/dist/lib/index.js
DELETED
package/dist/lib/schema/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { cast, isClassStrict } from 'vona';
|
|
2
|
-
import { $schema } from "./schema.js";
|
|
3
|
-
export function makeSchemaLikes(schemaLikes, typeInit) {
|
|
4
|
-
// default schema
|
|
5
|
-
let argSchema = $schema(typeInit);
|
|
6
|
-
// loop
|
|
7
|
-
for (let index = schemaLikes.length - 1; index >= 0; index--) {
|
|
8
|
-
const schemaLike = schemaLikes[index];
|
|
9
|
-
argSchema = makeSchemaLike(schemaLike, argSchema);
|
|
10
|
-
}
|
|
11
|
-
return argSchema;
|
|
12
|
-
}
|
|
13
|
-
export function makeSchemaLike(schemaLike, schemaPrevious) {
|
|
14
|
-
if (!schemaLike)
|
|
15
|
-
return schemaPrevious;
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(schemaLike, 'parseAsync')) {
|
|
17
|
-
// schema
|
|
18
|
-
return schemaLike;
|
|
19
|
-
}
|
|
20
|
-
else if (isClassStrict(schemaLike) ||
|
|
21
|
-
['String', 'Number', 'Boolean', 'Date', 'BigInt', 'Array'].includes(cast(schemaLike).name)) {
|
|
22
|
-
// class
|
|
23
|
-
return $schema(cast(schemaLike));
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// function
|
|
27
|
-
return cast(schemaLike)(schemaPrevious);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { appMetadata, appResource, cast } from 'vona';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { SymbolDecoratorRule } from "../../types/decorator.js";
|
|
4
|
-
export function $schema(classType, options) {
|
|
5
|
-
if (!classType)
|
|
6
|
-
return z.any();
|
|
7
|
-
if (classType.parseAsync)
|
|
8
|
-
return classType;
|
|
9
|
-
if (classType.name === 'String')
|
|
10
|
-
return z.string();
|
|
11
|
-
if (classType.name === 'Number')
|
|
12
|
-
return z.number();
|
|
13
|
-
if (classType.name === 'Boolean')
|
|
14
|
-
return z.boolean();
|
|
15
|
-
if (classType.name === 'Date')
|
|
16
|
-
return z.date();
|
|
17
|
-
if (classType.name === 'BigInt')
|
|
18
|
-
return z.bigint();
|
|
19
|
-
if (classType.name === 'Array')
|
|
20
|
-
return z.array(z.any());
|
|
21
|
-
// check if object
|
|
22
|
-
const rules = classType.prototype ? appMetadata.getMetadata(SymbolDecoratorRule, classType.prototype) : undefined;
|
|
23
|
-
if (!rules) {
|
|
24
|
-
// not object
|
|
25
|
-
return z.any();
|
|
26
|
-
}
|
|
27
|
-
// object
|
|
28
|
-
let schema = z.object(rules);
|
|
29
|
-
if (options?.passthrough)
|
|
30
|
-
schema = schema.passthrough();
|
|
31
|
-
if (options?.strict)
|
|
32
|
-
schema = schema.strict();
|
|
33
|
-
// refId
|
|
34
|
-
const beanOptions = appResource.getBean(classType);
|
|
35
|
-
if (beanOptions) {
|
|
36
|
-
const openapi = cast(beanOptions.options)?.openapi;
|
|
37
|
-
schema = schema.openapi(beanOptions.beanFullName, openapi);
|
|
38
|
-
}
|
|
39
|
-
return schema;
|
|
40
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export function schemaEmail(message) {
|
|
3
|
-
return function (schema) {
|
|
4
|
-
return schema.email(message);
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
export function schemaUrl(message) {
|
|
8
|
-
return function (schema) {
|
|
9
|
-
return schema.url(message);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export function schemaUuid(message) {
|
|
13
|
-
return function (schema) {
|
|
14
|
-
return schema.uuid(message);
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export function schemaIp(options) {
|
|
18
|
-
return function (schema) {
|
|
19
|
-
return schema.ip(options);
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export function schemaMin(min, message) {
|
|
23
|
-
return function (schema) {
|
|
24
|
-
return schema.min(min, message);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export function schemaMax(max, message) {
|
|
28
|
-
return function (schema) {
|
|
29
|
-
return schema.max(max, message);
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export function schemaTableIdentity() {
|
|
33
|
-
return function (_schema) {
|
|
34
|
-
return z.union([z.string(), z.number()]);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function schemaOpenapi(refId, metadata) {
|
|
2
|
-
return function (schema) {
|
|
3
|
-
return schema.openapi(refId, metadata);
|
|
4
|
-
};
|
|
5
|
-
}
|
|
6
|
-
export function schemaTitle(title) {
|
|
7
|
-
return function (schema) {
|
|
8
|
-
return schema.openapi({ title });
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function schemaDescription(description) {
|
|
12
|
-
return function (schema) {
|
|
13
|
-
return schema.openapi({ description });
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export function schemaExample(example) {
|
|
17
|
-
return function (schema) {
|
|
18
|
-
return schema.openapi({ example });
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { isNil } from '@cabloy/utils';
|
|
2
|
-
import { coerceWithNil } from '@cabloy/zod-query';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import { makeSchemaLike } from "../makeSchemaLikes.js";
|
|
5
|
-
import { $schema } from "../schema.js";
|
|
6
|
-
export function schemaDefault(defaultValue) {
|
|
7
|
-
return function (schema) {
|
|
8
|
-
return schema.default(defaultValue);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function schemaOptional() {
|
|
12
|
-
return function (schema) {
|
|
13
|
-
return schema.optional();
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export function schemaObject(classType, options) {
|
|
17
|
-
return function (_schema) {
|
|
18
|
-
return $schema(classType, options);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export function schemaArray(schemaLike, params) {
|
|
22
|
-
return function (schema) {
|
|
23
|
-
return z.preprocess(val => {
|
|
24
|
-
val = coerceWithNil(val);
|
|
25
|
-
if (isNil(val))
|
|
26
|
-
return val;
|
|
27
|
-
if (typeof val !== 'string')
|
|
28
|
-
return val;
|
|
29
|
-
if (isNil(params?.separator) && val[0] === '[')
|
|
30
|
-
return JSON.parse(val);
|
|
31
|
-
return val.split(params?.separator ?? ',');
|
|
32
|
-
}, z.array(makeSchemaLike(schemaLike ?? schema, z.any()), params));
|
|
33
|
-
};
|
|
34
|
-
}
|
package/dist/lib/schema/v.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { schemaEmail, schemaIp, schemaMax, schemaMin, schemaTableIdentity, schemaUrl, schemaUuid } from "./v/helpers.js";
|
|
2
|
-
import { schemaDescription, schemaExample, schemaOpenapi, schemaTitle } from "./v/openapi.js";
|
|
3
|
-
import { schemaArray, schemaDefault, schemaObject, schemaOptional } from "./v/system.js";
|
|
4
|
-
export const v = {
|
|
5
|
-
array: schemaArray,
|
|
6
|
-
default: schemaDefault,
|
|
7
|
-
object: schemaObject,
|
|
8
|
-
optional: schemaOptional,
|
|
9
|
-
// helpers
|
|
10
|
-
email: schemaEmail,
|
|
11
|
-
url: schemaUrl,
|
|
12
|
-
uuid: schemaUuid,
|
|
13
|
-
ip: schemaIp,
|
|
14
|
-
min: schemaMin,
|
|
15
|
-
max: schemaMax,
|
|
16
|
-
tableIdentity: schemaTableIdentity,
|
|
17
|
-
// openapi
|
|
18
|
-
openapi: schemaOpenapi,
|
|
19
|
-
title: schemaTitle,
|
|
20
|
-
description: schemaDescription,
|
|
21
|
-
example: schemaExample,
|
|
22
|
-
};
|
package/dist/lib/utils.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { appMetadata, appResource, cast, deepExtend, registerMappedClassMetadataKey } from 'vona';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { SymbolDecoratorRule, SymbolDecoratorRuleColumn } from "../types/decorator.js";
|
|
4
|
-
export function getTargetDecoratorRules(target) {
|
|
5
|
-
registerMappedClassMetadataKey(target, SymbolDecoratorRule, {
|
|
6
|
-
partialClass: (meta) => {
|
|
7
|
-
return meta.optional();
|
|
8
|
-
},
|
|
9
|
-
});
|
|
10
|
-
return appMetadata.getOwnMetadataMap(true, SymbolDecoratorRule, target);
|
|
11
|
-
}
|
|
12
|
-
export function getTargetDecoratorRuleColumns(target) {
|
|
13
|
-
registerMappedClassMetadataKey(target, SymbolDecoratorRuleColumn);
|
|
14
|
-
return appMetadata.getOwnMetadataMap(true, SymbolDecoratorRuleColumn, target);
|
|
15
|
-
}
|
|
16
|
-
export function mergeFieldsOpenAPIMetadata(target) {
|
|
17
|
-
// rules
|
|
18
|
-
const rules = getTargetDecoratorRules(target.prototype);
|
|
19
|
-
// beanOptions
|
|
20
|
-
const beanOptions = appResource.getBean(target);
|
|
21
|
-
const fields = cast(beanOptions?.options)?.fields;
|
|
22
|
-
if (!fields)
|
|
23
|
-
return;
|
|
24
|
-
for (const key in fields) {
|
|
25
|
-
const field = fields[key];
|
|
26
|
-
if (!field)
|
|
27
|
-
continue;
|
|
28
|
-
const schemaCurrent = rules[key];
|
|
29
|
-
if (Object.prototype.hasOwnProperty.call(field, 'parseAsync')) {
|
|
30
|
-
const schema = field;
|
|
31
|
-
rules[key] = schema.openapi(deepExtend({}, schemaCurrent?._def.openapi?.metadata, schema._def.openapi?.metadata));
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
// use deepExtend for sure strict
|
|
35
|
-
if (schemaCurrent) {
|
|
36
|
-
rules[key] = schemaCurrent.openapi(deepExtend({}, schemaCurrent._def.openapi?.metadata, field));
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
rules[key] = z.any().openapi(deepExtend({}, field));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { setErrorMapDefault, setErrorMapSchema } from '@cabloy/zod-errors-custom';
|
|
2
|
-
export function errorsAdapter(app) {
|
|
3
|
-
setErrorMapDefault((text, ...args) => {
|
|
4
|
-
return app.meta.text(text, ...args);
|
|
5
|
-
});
|
|
6
|
-
setErrorMapSchema((text, ...args) => {
|
|
7
|
-
return app.meta.text(text, ...args);
|
|
8
|
-
});
|
|
9
|
-
}
|
package/dist/lib/zod/index.js
DELETED
package/dist/main.js
DELETED