vona-module-a-openapiutils 5.0.13 → 5.0.15
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.
|
@@ -7,4 +7,4 @@ export declare const locales: {
|
|
|
7
7
|
ZodErrorRequired: string;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
export declare function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K):
|
|
10
|
+
export declare function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K, ...args: any[]): any;
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { BeanInfo, BeanScopeBase, $makeLocaleMagic, registerMappedClassMetadataKey, appMetadata, appResource, cast, deepExtend, useApp, beanFullNameFromOnionName } from 'vona';
|
|
2
|
+
import { __decorate } from 'tslib';
|
|
2
3
|
import { Scope } from 'vona-module-a-bean';
|
|
3
4
|
import { isEmptyObject, isClass, isNil, combineParamsAndQuery } from '@cabloy/utils';
|
|
4
5
|
import { z } from 'zod';
|
|
5
6
|
import { ZodMetadata } from '@cabloy/zod-openapi';
|
|
6
7
|
import { coerceWithNil } from '@cabloy/zod-query';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
let ScopeModuleAOpenapiutils = class ScopeModuleAOpenapiutils extends BeanScopeBase {};
|
|
10
|
+
ScopeModuleAOpenapiutils = __decorate([Scope(), BeanInfo({
|
|
10
11
|
module: "a-openapiutils"
|
|
11
|
-
}),
|
|
12
|
-
|
|
12
|
+
})], ScopeModuleAOpenapiutils);
|
|
13
13
|
/** scope: end */
|
|
14
14
|
|
|
15
15
|
var locale_en_us = {
|
|
@@ -24,22 +24,25 @@ const locales = {
|
|
|
24
24
|
'en-us': locale_en_us,
|
|
25
25
|
'zh-cn': locale_zh_cn
|
|
26
26
|
};
|
|
27
|
-
function $locale(key) {
|
|
28
|
-
return $makeLocaleMagic(`a-openapiutils::${key}
|
|
27
|
+
function $locale(key, ...args) {
|
|
28
|
+
return $makeLocaleMagic(`a-openapiutils::${key}`, ...args);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const OrderCoreBase = 100;
|
|
32
32
|
const OrderBusinessBase = 1000;
|
|
33
33
|
const OrderUnknownBase = 10000;
|
|
34
34
|
const OrderMaxBase = 100000;
|
|
35
|
+
const OrderLevelBaseMap = {
|
|
36
|
+
core: OrderCoreBase,
|
|
37
|
+
business: OrderBusinessBase,
|
|
38
|
+
max: OrderMaxBase
|
|
39
|
+
};
|
|
35
40
|
|
|
36
41
|
const SymbolRouteHandlersArgumentsMeta = Symbol('SymbolRouteHandlersArgumentsMeta');
|
|
37
42
|
const SymbolRouteHandlersArgumentsValue = Symbol('SymbolRouteHandlersArgumentsValue');
|
|
38
43
|
|
|
39
44
|
const SymbolOpenApiOptions = Symbol('SymbolOpenApiOptions');
|
|
40
45
|
|
|
41
|
-
// not use z.ZodType
|
|
42
|
-
|
|
43
46
|
const SymbolDecoratorRule = Symbol('SymbolDecoratorRule');
|
|
44
47
|
|
|
45
48
|
function getTargetDecoratorRules(target, disableRegisterMetadata) {
|
|
@@ -75,7 +78,6 @@ function mergeFieldsOpenapiMetadata(target) {
|
|
|
75
78
|
mergeFieldOpenapiMetadata(target.prototype, key, field);
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
|
-
|
|
79
81
|
// fieldRule maybe undefined
|
|
80
82
|
function mergeFieldOpenapiMetadata(target, prop, fieldRule) {
|
|
81
83
|
// rules
|
|
@@ -235,6 +237,11 @@ function schemaFilterDateRange(options) {
|
|
|
235
237
|
return schema.openapi({
|
|
236
238
|
filter: {
|
|
237
239
|
transform: ['a-web:dateRange', options]
|
|
240
|
+
},
|
|
241
|
+
rest: {
|
|
242
|
+
filter: {
|
|
243
|
+
render: 'dateRange'
|
|
244
|
+
}
|
|
238
245
|
}
|
|
239
246
|
});
|
|
240
247
|
};
|
|
@@ -365,6 +372,88 @@ function schemaExample(example) {
|
|
|
365
372
|
};
|
|
366
373
|
}
|
|
367
374
|
|
|
375
|
+
function schemaOrder(order, level, scene) {
|
|
376
|
+
const levelBase = OrderLevelBaseMap[level ?? 'business'];
|
|
377
|
+
const orderReal = levelBase + order;
|
|
378
|
+
return function (schema) {
|
|
379
|
+
return schema.openapi(scene ? {
|
|
380
|
+
rest: {
|
|
381
|
+
[scene]: {
|
|
382
|
+
order: orderReal
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
} : {
|
|
386
|
+
rest: {
|
|
387
|
+
order: orderReal
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
function schemaRender(render, scene) {
|
|
393
|
+
return function (schema) {
|
|
394
|
+
return schema.openapi(scene ? {
|
|
395
|
+
rest: {
|
|
396
|
+
[scene]: {
|
|
397
|
+
render: render
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
} : {
|
|
401
|
+
rest: {
|
|
402
|
+
render: render
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
function schemaVisible(visible, scene) {
|
|
408
|
+
return function (schema) {
|
|
409
|
+
return schema.openapi(scene ? {
|
|
410
|
+
rest: {
|
|
411
|
+
[scene]: {
|
|
412
|
+
visible
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
} : {
|
|
416
|
+
rest: {
|
|
417
|
+
visible
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
function schemaCurrency(currency, scene) {
|
|
423
|
+
return function (schema) {
|
|
424
|
+
const options = currency !== undefined ? {
|
|
425
|
+
render: 'currency',
|
|
426
|
+
currency
|
|
427
|
+
} : {
|
|
428
|
+
render: 'currency'
|
|
429
|
+
};
|
|
430
|
+
return schema.openapi(scene ? {
|
|
431
|
+
rest: {
|
|
432
|
+
[scene]: options
|
|
433
|
+
}
|
|
434
|
+
} : {
|
|
435
|
+
rest: options
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function schemaDate(dateFormat, scene) {
|
|
440
|
+
return function (schema) {
|
|
441
|
+
const options = dateFormat !== undefined ? {
|
|
442
|
+
render: 'date',
|
|
443
|
+
dateFormat
|
|
444
|
+
} : {
|
|
445
|
+
render: 'date'
|
|
446
|
+
};
|
|
447
|
+
return schema.openapi(scene ? {
|
|
448
|
+
rest: {
|
|
449
|
+
[scene]: options
|
|
450
|
+
}
|
|
451
|
+
} : {
|
|
452
|
+
rest: options
|
|
453
|
+
});
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
|
|
368
457
|
function schemaSerializerTransform(serializerTransformName, options) {
|
|
369
458
|
return function (schema) {
|
|
370
459
|
return schema.openapi({
|
|
@@ -463,9 +552,7 @@ function schemaArray(schemaLike, params) {
|
|
|
463
552
|
if (typeof val !== 'string') return val;
|
|
464
553
|
if (val.startsWith('[') && val.endsWith(']')) return JSON.parse(val);
|
|
465
554
|
return val.split(params?.separator ?? ',');
|
|
466
|
-
}, z.array(makeSchemaLike(schemaLike ?? schema, z.any()), params)
|
|
467
|
-
// z.array(makeSchemaLike(schemaLike, schema), params),
|
|
468
|
-
);
|
|
555
|
+
}, z.array(makeSchemaLike(schemaLike ?? schema, z.any()), params));
|
|
469
556
|
};
|
|
470
557
|
}
|
|
471
558
|
function schemaStrictObject() {
|
|
@@ -557,6 +644,12 @@ const v = {
|
|
|
557
644
|
title: schemaTitle,
|
|
558
645
|
description: schemaDescription,
|
|
559
646
|
example: schemaExample,
|
|
647
|
+
// rest
|
|
648
|
+
currency: schemaCurrency,
|
|
649
|
+
date: schemaDate,
|
|
650
|
+
order: schemaOrder,
|
|
651
|
+
render: schemaRender,
|
|
652
|
+
visible: schemaVisible,
|
|
560
653
|
// zod
|
|
561
654
|
refine: schemaZodRefine,
|
|
562
655
|
transform: schemaZodTransform
|
|
@@ -687,4 +780,4 @@ function $makeFilterTransform(filterTransformName, options) {
|
|
|
687
780
|
return [filterTransformName, options];
|
|
688
781
|
}
|
|
689
782
|
|
|
690
|
-
export { $apiPath, $apiPathAndCombineParamsAndQuery, $locale, $makeFilterTransform, $makeSchema, $schema, $schemaLazy, Api, OrderBusinessBase, OrderCoreBase, OrderMaxBase, OrderUnknownBase, ScopeModuleAOpenapiutils, SymbolDecoratorRule, SymbolOpenApiOptions, SymbolRouteHandlersArgumentsMeta, SymbolRouteHandlersArgumentsValue, SymbolSchemaDynamicRefId, addSchemaDynamic, bodySchemaWrapperDefault, getSchemaDynamic, getSchemasDynamic, getTargetDecoratorRuleColumns, getTargetDecoratorRuleColumnsMap, getTargetDecoratorRules, locales, makeSchemaLike, makeSchemaLikes, mergeFieldOpenapiMetadata, mergeFieldsOpenapiMetadata, normalizeErrorParams, prepareClassType, setPublic, v };
|
|
783
|
+
export { $apiPath, $apiPathAndCombineParamsAndQuery, $locale, $makeFilterTransform, $makeSchema, $schema, $schemaLazy, Api, OrderBusinessBase, OrderCoreBase, OrderLevelBaseMap, OrderMaxBase, OrderUnknownBase, ScopeModuleAOpenapiutils, SymbolDecoratorRule, SymbolOpenApiOptions, SymbolRouteHandlersArgumentsMeta, SymbolRouteHandlersArgumentsValue, SymbolSchemaDynamicRefId, addSchemaDynamic, bodySchemaWrapperDefault, getSchemaDynamic, getSchemasDynamic, getTargetDecoratorRuleColumns, getTargetDecoratorRuleColumnsMap, getTargetDecoratorRules, locales, makeSchemaLike, makeSchemaLikes, mergeFieldOpenapiMetadata, mergeFieldsOpenapiMetadata, normalizeErrorParams, prepareClassType, setPublic, v };
|
|
@@ -2,3 +2,8 @@ export declare const OrderCoreBase = 100;
|
|
|
2
2
|
export declare const OrderBusinessBase = 1000;
|
|
3
3
|
export declare const OrderUnknownBase = 10000;
|
|
4
4
|
export declare const OrderMaxBase = 100000;
|
|
5
|
+
export declare const OrderLevelBaseMap: {
|
|
6
|
+
core: number;
|
|
7
|
+
business: number;
|
|
8
|
+
max: number;
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CurrencyOptions } from '@zhennann/currency';
|
|
2
|
+
import type { TypeDateFormat, TypeRenderComponent, TypeSchemaScene } from 'vona-module-a-openapi';
|
|
3
|
+
import type z from 'zod';
|
|
4
|
+
import type { TypeSchemaOrderLevel } from '../../../types/order.ts';
|
|
5
|
+
export declare function schemaOrder<T extends z.ZodType>(order: number, level?: TypeSchemaOrderLevel, scene?: TypeSchemaScene): (schema: T) => T;
|
|
6
|
+
export declare function schemaRender<T extends z.ZodType>(render: TypeRenderComponent, scene?: TypeSchemaScene): (schema: T) => T;
|
|
7
|
+
export declare function schemaVisible<T extends z.ZodType>(visible?: boolean, scene?: TypeSchemaScene): (schema: T) => T;
|
|
8
|
+
export declare function schemaCurrency<T extends z.ZodType>(currency?: CurrencyOptions, scene?: TypeSchemaScene): (schema: T) => T;
|
|
9
|
+
export declare function schemaDate<T extends z.ZodType>(dateFormat?: TypeDateFormat, scene?: TypeSchemaScene): (schema: T) => T;
|
package/dist/lib/schema/v.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { schemaFilter, schemaFilterDateRange, schemaFilterTransform } from './v/filter.ts';
|
|
2
2
|
import { schemaCaptcha, schemaEmail, schemaIPv4, schemaIPv6, schemaLowercase, schemaMax, schemaMin, schemaRegex, schemaTableIdentity, schemaToLowerCase, schemaToUpperCase, schemaTrim, schemaUppercase, schemaUrl, schemaUuid } from './v/helpers.ts';
|
|
3
3
|
import { schemaDescription, schemaExample, schemaOpenapi, schemaTitle } from './v/openapi.ts';
|
|
4
|
+
import { schemaCurrency, schemaDate, schemaOrder, schemaRender, schemaVisible } from './v/rest.ts';
|
|
4
5
|
import { schemaSerializerCustom, schemaSerializerExclude, schemaSerializerGetter, schemaSerializerReplace, schemaSerializerTransform } from './v/serializer.ts';
|
|
5
6
|
import { schemaArray, schemaDefault, schemaLazy, schemaLooseObject, schemaObject, schemaOptional, schemaRequired, schemaStrictObject } from './v/system.ts';
|
|
6
7
|
import { schemaZodRefine, schemaZodTransform } from './v/zod.ts';
|
|
@@ -40,6 +41,11 @@ export declare const v: {
|
|
|
40
41
|
title: typeof schemaTitle;
|
|
41
42
|
description: typeof schemaDescription;
|
|
42
43
|
example: typeof schemaExample;
|
|
44
|
+
currency: typeof schemaCurrency;
|
|
45
|
+
date: typeof schemaDate;
|
|
46
|
+
order: typeof schemaOrder;
|
|
47
|
+
render: typeof schemaRender;
|
|
48
|
+
visible: typeof schemaVisible;
|
|
43
49
|
refine: typeof schemaZodRefine;
|
|
44
50
|
transform: typeof schemaZodTransform;
|
|
45
51
|
};
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-a-openapiutils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.15",
|
|
5
5
|
"title": "a-openapiutils",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"dependencies": {}
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
"assets",
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@zhennann/currency": "^2.0.0"
|
|
30
|
+
},
|
|
28
31
|
"scripts": {
|
|
29
32
|
"clean": "rimraf dist tsconfig.build.tsbuildinfo",
|
|
30
33
|
"tsc:publish": "npm run clean && vona :bin:buildModule && tsc -p tsconfig.build.json"
|