vona-module-a-openapiutils 5.0.15 → 5.0.17

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 CHANGED
@@ -4,6 +4,7 @@ import { Scope } from 'vona-module-a-bean';
4
4
  import { isEmptyObject, isClass, isNil, combineParamsAndQuery } from '@cabloy/utils';
5
5
  import { z } from 'zod';
6
6
  import { ZodMetadata } from '@cabloy/zod-openapi';
7
+ import React from 'react';
7
8
  import { coerceWithNil } from '@cabloy/zod-query';
8
9
 
9
10
  let ScopeModuleAOpenapiutils = class ScopeModuleAOpenapiutils extends BeanScopeBase {};
@@ -40,10 +41,9 @@ const OrderLevelBaseMap = {
40
41
 
41
42
  const SymbolRouteHandlersArgumentsMeta = Symbol('SymbolRouteHandlersArgumentsMeta');
42
43
  const SymbolRouteHandlersArgumentsValue = Symbol('SymbolRouteHandlersArgumentsValue');
43
-
44
44
  const SymbolOpenApiOptions = Symbol('SymbolOpenApiOptions');
45
-
46
45
  const SymbolDecoratorRule = Symbol('SymbolDecoratorRule');
46
+ const SymbolControllerResource = Symbol('SymbolControllerResource');
47
47
 
48
48
  function getTargetDecoratorRules(target, disableRegisterMetadata) {
49
49
  if (!disableRegisterMetadata) {
@@ -233,6 +233,11 @@ function schemaFilterTransform(filterTransformName, options) {
233
233
  };
234
234
  }
235
235
  function schemaFilterDateRange(options) {
236
+ const separator = options?.separator;
237
+ const DateRange = 'dateRange';
238
+ const filterRender = separator ? React.createElement(DateRange, {
239
+ separator: separator
240
+ }) : 'dateRange';
236
241
  return function (schema) {
237
242
  return schema.openapi({
238
243
  filter: {
@@ -240,7 +245,7 @@ function schemaFilterDateRange(options) {
240
245
  },
241
246
  rest: {
242
247
  filter: {
243
- render: 'dateRange'
248
+ render: filterRender
244
249
  }
245
250
  }
246
251
  });
@@ -762,6 +767,13 @@ function setPublic(target, prop, _descriptor, value) {
762
767
  options.public = value;
763
768
  }
764
769
 
770
+ function Resource() {
771
+ return function (target) {
772
+ // controller resource
773
+ appMetadata.defineMetadata(SymbolControllerResource, true, target);
774
+ };
775
+ }
776
+
765
777
  function bodySchemaWrapperDefault(bodySchema) {
766
778
  return z.object({
767
779
  code: z.string(),
@@ -780,4 +792,4 @@ function $makeFilterTransform(filterTransformName, options) {
780
792
  return [filterTransformName, options];
781
793
  }
782
794
 
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 };
795
+ export { $apiPath, $apiPathAndCombineParamsAndQuery, $locale, $makeFilterTransform, $makeSchema, $schema, $schemaLazy, Api, OrderBusinessBase, OrderCoreBase, OrderLevelBaseMap, OrderMaxBase, OrderUnknownBase, Resource, ScopeModuleAOpenapiutils, SymbolControllerResource, SymbolDecoratorRule, SymbolOpenApiOptions, SymbolRouteHandlersArgumentsMeta, SymbolRouteHandlersArgumentsValue, SymbolSchemaDynamicRefId, addSchemaDynamic, bodySchemaWrapperDefault, getSchemaDynamic, getSchemasDynamic, getTargetDecoratorRuleColumns, getTargetDecoratorRuleColumnsMap, getTargetDecoratorRules, locales, makeSchemaLike, makeSchemaLikes, mergeFieldOpenapiMetadata, mergeFieldsOpenapiMetadata, normalizeErrorParams, prepareClassType, setPublic, v };
@@ -1,2 +1,5 @@
1
1
  export declare const SymbolRouteHandlersArgumentsMeta: unique symbol;
2
2
  export declare const SymbolRouteHandlersArgumentsValue: unique symbol;
3
+ export declare const SymbolOpenApiOptions: unique symbol;
4
+ export declare const SymbolDecoratorRule: unique symbol;
5
+ export declare const SymbolControllerResource: unique symbol;
@@ -1,5 +1,5 @@
1
1
  import type { MetadataKey } from 'vona';
2
- import type { IOpenApiHeader, TypeResponseContentType } from '../../types/api.ts';
2
+ import type { IOpenapiHeader, TypeResponseContentType } from '../../types/api.ts';
3
3
  import type { SchemaLike, SchemaLikeCreate } from '../../types/decorator.ts';
4
4
  import { Field } from './field.ts';
5
5
  declare function httpCode(httpCode: number): MethodDecorator;
@@ -8,8 +8,8 @@ declare function body(...schemaLikes: SchemaLike[]): MethodDecorator;
8
8
  declare function bodyCustom(bodySchemaWrapper: SchemaLikeCreate | false, ...schemaLikes: SchemaLike[]): MethodDecorator;
9
9
  declare function exclude(): ClassDecorator & MethodDecorator;
10
10
  declare function tags(tags: string[]): ClassDecorator & MethodDecorator;
11
- declare function header(header: IOpenApiHeader): ClassDecorator & MethodDecorator;
12
- declare function headers(headers: IOpenApiHeader[]): ClassDecorator & MethodDecorator;
11
+ declare function header(header: IOpenapiHeader): ClassDecorator & MethodDecorator;
12
+ declare function headers(headers: IOpenapiHeader[]): ClassDecorator & MethodDecorator;
13
13
  declare function setHeader(field: {
14
14
  [key: string]: string | string[];
15
15
  }): ClassDecorator & MethodDecorator;
@@ -1 +1,2 @@
1
1
  export * from './api.ts';
2
+ export * from './resource.ts';
@@ -0,0 +1 @@
1
+ export declare function Resource(): ClassDecorator;
@@ -1,4 +1,4 @@
1
- import { schemaFilter, schemaFilterDateRange, schemaFilterTransform } from './v/filter.ts';
1
+ import { schemaFilter, schemaFilterDateRange, schemaFilterTransform } from './v/filter.tsx';
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
4
  import { schemaCurrency, schemaDate, schemaOrder, schemaRender, schemaVisible } from './v/rest.ts';
@@ -3,8 +3,7 @@ import type { OpenAPIObject as OpenAPIObject31, SchemaObject as SchemaObject31 }
3
3
  import type { ILocaleMagic, VonaApplication } from 'vona';
4
4
  import type z from 'zod';
5
5
  import type { SchemaLikeCreate } from './decorator.ts';
6
- export declare const SymbolOpenApiOptions: unique symbol;
7
- export interface IOpenApiHeader {
6
+ export interface IOpenapiHeader {
8
7
  name: string;
9
8
  description?: string;
10
9
  }
@@ -22,7 +21,7 @@ export interface IOpenapiSchemaObject {
22
21
  V31: SchemaObject31;
23
22
  }
24
23
  export type TypeSecuritySchemes = Record<string, ((this: VonaApplication) => object) | object>;
25
- export interface IOpenApiOptions {
24
+ export interface IOpenapiOptions {
26
25
  public?: boolean;
27
26
  description?: string | ILocaleMagic;
28
27
  summary?: string | ILocaleMagic;
@@ -33,7 +32,7 @@ export interface IOpenApiOptions {
33
32
  exclude?: boolean;
34
33
  tags?: string[];
35
34
  operationId?: string;
36
- headers?: IOpenApiHeader[];
35
+ headers?: IOpenapiHeader[];
37
36
  setHeaders?: IResponseHeaders;
38
37
  }
39
38
  export type TypeResponseContentType = 'application/json' | 'application/xml' | 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain' | 'text/html' | 'application/octet-stream' | 'application/pdf' | 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp' | 'image/svg+xml' | 'image/bmp' | 'image/tiff' | 'image/vnd.microsoft.icon' | 'image/vnd.wap.wbmp' | 'image/x-icon' | 'image/x-jng' | 'image/x-ms-bmp' | 'image/x-portable-bitmap' | 'image/x-portable-graymap' | 'image/x-portable-pixmap' | 'image/x-xbitmap' | 'image/x-xpixmap' | 'image/x-xwindowdump' | 'image/bmp' | 'image/x-bmp' | 'image/x-xbitmap' | 'image/x-win-bitmap' | 'image/x-windows-bmp' | 'image/ms-bmp' | 'image/x-ms-bmp' | 'image/x-icon' | 'image/x-ico' | 'image/vnd.microsoft.icon' | 'image/ico' | 'image/icon' | 'text/css' | 'text/csv' | 'text/html' | 'text/javascript' | 'text/plain' | 'text/xml' | 'application/javascript' | 'application/ecmascript' | 'application/json' | 'application/ld+json' | 'application/manifest+json' | 'application/javascript' | 'application/x-javascript' | 'application/x-json' | 'application/x-ms-application';
@@ -3,4 +3,3 @@ import type z from 'zod';
3
3
  export type SchemaLikeCreate = (schema: any) => any;
4
4
  export type SchemaLike<T = unknown> = SchemaLikeCreate | z.ZodType<T> | Constructable;
5
5
  export type TypeDecoratorRules = Record<string, z.ZodType | undefined>;
6
- export declare const SymbolDecoratorRule: unique symbol;
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.15",
4
+ "version": "5.0.17",
5
5
  "title": "a-openapiutils",
6
6
  "vonaModule": {
7
7
  "dependencies": {}