denwa-nest-shared 1.0.15 → 1.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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.17](https://github.com/web-bee-ru/openapi-axios/compare/v1.0.16...v1.0.17) (2025-03-18)
6
+
7
+ ### [1.0.16](https://github.com/web-bee-ru/openapi-axios/compare/v1.0.15...v1.0.16) (2025-03-18)
8
+
5
9
  ### [1.0.15](https://github.com/web-bee-ru/openapi-axios/compare/v1.0.14...v1.0.15) (2025-03-18)
6
10
 
7
11
  ### [1.0.14](https://github.com/web-bee-ru/openapi-axios/compare/v1.0.13...v1.0.14) (2025-03-10)
package/cjs/decorators.js CHANGED
@@ -18,7 +18,7 @@ const ApiProperty = ({ type, enumObject, min, max, example, description, isOptio
18
18
  }
19
19
  switch (type) {
20
20
  case 'int':
21
- decorators.push((0, graphql_1.Field)(() => graphql_1.Int, { nullable: isOptional }));
21
+ decorators.push((0, graphql_1.Field)(() => (isArray ? [graphql_1.Int] : graphql_1.Int), { nullable: isOptional }));
22
22
  if (isOptional)
23
23
  decorators.push((0, class_validator_1.IsOptional)());
24
24
  if (isArray)
@@ -30,7 +30,7 @@ const ApiProperty = ({ type, enumObject, min, max, example, description, isOptio
30
30
  decorators.push((0, class_validator_1.Max)(max, { each: isArray }));
31
31
  break;
32
32
  case 'float':
33
- decorators.push((0, graphql_1.Field)(() => graphql_1.Float, { nullable: isOptional }));
33
+ decorators.push((0, graphql_1.Field)(() => (isArray ? [graphql_1.Float] : graphql_1.Float), { nullable: isOptional }));
34
34
  if (isOptional)
35
35
  decorators.push((0, class_validator_1.IsOptional)());
36
36
  if (isArray)
@@ -42,7 +42,7 @@ const ApiProperty = ({ type, enumObject, min, max, example, description, isOptio
42
42
  decorators.push((0, class_validator_1.Max)(max, { each: isArray }));
43
43
  break;
44
44
  case 'date':
45
- decorators.push((0, graphql_1.Field)(() => Date, { nullable: isOptional }));
45
+ decorators.push((0, graphql_1.Field)(() => (isArray ? [Date] : Date), { nullable: isOptional }));
46
46
  if (isOptional)
47
47
  decorators.push((0, class_validator_1.IsOptional)());
48
48
  if (isArray)
@@ -57,7 +57,12 @@ const ApiProperty = ({ type, enumObject, min, max, example, description, isOptio
57
57
  break;
58
58
  case 'string':
59
59
  default:
60
- decorators.push((0, graphql_1.Field)(() => String, { nullable: isOptional }));
60
+ if (enumObject) {
61
+ decorators.push((0, graphql_1.Field)(() => (isArray ? [enumObject] : enumObject), { nullable: isOptional }));
62
+ }
63
+ else {
64
+ decorators.push((0, graphql_1.Field)(() => (isArray ? [String] : String), { nullable: isOptional }));
65
+ }
61
66
  if (isOptional)
62
67
  decorators.push((0, class_validator_1.IsOptional)());
63
68
  if (isArray)
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AACjD,6CAAoD;AACpD,6CAAyF;AACzF,qDAiByB;AAElB,MAAM,WAAW,GAAG,CAAC,EAC1B,IAAI,EACJ,UAAU,EACV,GAAG,EACH,GAAG,EACH,OAAO,EACP,WAAW,EACX,UAAU,GAAG,KAAK,EAClB,MAAM,GAAG,KAAK,EACd,OAAO,GAAG,KAAK,EACf,MAAM,GAAG,KAAK,EACd,KAAK,GAAG,KAAK,EACb,UAAU,GAAG,KAAK,EAClB,UAAU,GAAG,KAAK,GAgBnB,EAIU,EAAE;IACX,MAAM,UAAU,GAAG,EAAE,CAAC;IAEtB,IAAI,UAAU,EAAE,CAAC;QACf,UAAU,CAAC,IAAI,CACb,IAAA,6BAAmB,EAAC;YAClB,OAAO;YACP,WAAW;SACZ,CAAC,CACH,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,IAAI,CAAC,IAAA,qBAAkB,EAAC,E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,CAAC,CAAC;YAE7C,IAAI,MAAM;gBAAE,UAAU,CAAC,IAAI,CAAC,IAAA,wBAAM,GAAE,CAAC,CAAC;YACtC,IAAI,UAAU;gBAAE,UAAU,CAAC,IAAI,CAAC,IAAA,4BAAU,GAAE,CAAC,CAAC;YAC9C,IAAI,UAAU;gBAAE,UAAU,CAAC,IAAI,CAAC,IAAA,4BAAU,GAAE,CAAC,CAAC;YAC9C,IAAI,GAAG;gBAAE,UAAU,CAAC,IAAI,CAAC,IAAA,2BAAS,EAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YAC5D,IAAI,GAAG;gBAAE,UAAU,CAAC,IAAI,CAAC,IAAA,2BAAS,EAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YAC5D,IAAI,UAAU;gBAAE,UAAU,CAAC,IAAI,CAAC,IAAA,wBAAM,EAAC,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YACvE,IAAI,MAAM;gBAAE,UAAU,CAAC,IAAI,CAAC,IAAA,wBAAM,GAAE,CAAC,CAAC;YACtC,IAAI,KAAK;gBAAE,UAAU,CAAC,IAAI,CAAC,IAAA,uBAAK,GAAE,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,IAAA,wBAAe,EAAC,GAAG,UAAU,CAAC,CAAC;AACxC,CAAC,CAAC;AAzGW,QAAA,WAAW,eAyGtB","sourcesContent":["import { applyDecorators } from '@nestjs/common';\nimport { Field, Float, Int } from '@nestjs/graphql';\nimport { ApiProperty as SwaggerApiProperty, ApiPropertyOptional } from '@nestjs/swagger';\nimport {\n IsArray,\n IsBoolean,\n IsDate,\n IsEnum,\n IsJSON,\n IsNegative,\n IsNumber,\n IsOptional,\n IsPositive,\n IsString,\n IsUrl,\n IsUUID,\n Max,\n MaxLength,\n Min,\n MinLength,\n} from 'class-validator';\n\nexport const ApiProperty = ({\n type,\n enumObject,\n min,\n max,\n example,\n description,\n isOptional = false,\n isUUID = false,\n isArray = false,\n isJson = false,\n isUrl = false,\n isPositive = false,\n isNegative = false,\n}: {\n type: 'string' | 'int' | 'float' | 'date' | 'boolean';\n enumObject?: object;\n min?: number;\n max?: number;\n example?: string;\n description?: string;\n isOptional?: boolean;\n isUUID?: boolean;\n isArray?: boolean;\n isJson?: boolean;\n isUrl?: boolean;\n isPositive?: boolean;\n isNegative?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n}): (<TFunction extends Function, Y>(\n target: TFunction | object,\n propertyKey?: string | symbol,\n descriptor?: TypedPropertyDescriptor<Y>,\n) => void) => {\n const decorators = [];\n\n if (isOptional) {\n decorators.push(\n ApiPropertyOptional({\n example,\n description,\n }),\n );\n } else {\n decorators.push(SwaggerApiProperty({ example, description }));\n }\n\n switch (type) {\n case 'int':\n decorators.push(Field(() => Int, { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n if (isArray) decorators.push(IsArray());\n\n decorators.push(IsNumber());\n\n if (min) decorators.push(Min(min, { each: isArray }));\n if (max) decorators.push(Max(max, { each: isArray }));\n\n break;\n case 'float':\n decorators.push(Field(() => Float, { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n if (isArray) decorators.push(IsArray());\n\n decorators.push(IsNumber());\n\n if (min) decorators.push(Min(min, { each: isArray }));\n if (max) decorators.push(Max(max, { each: isArray }));\n\n break;\n case 'date':\n decorators.push(Field(() => Date, { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n if (isArray) decorators.push(IsArray());\n\n decorators.push(IsDate({ each: isArray }));\n break;\n case 'boolean':\n decorators.push(Field({ nullable: isOptional }));\n if (isOptional) decorators.push(IsOptional());\n decorators.push(IsBoolean());\n break;\n case 'string':\n default:\n decorators.push(Field(() => String, { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n if (isArray) decorators.push(IsArray());\n\n decorators.push(IsString({ each: isArray }));\n\n if (isUUID) decorators.push(IsUUID());\n if (isPositive) decorators.push(IsPositive());\n if (isNegative) decorators.push(IsNegative());\n if (min) decorators.push(MinLength(min, { each: isArray }));\n if (max) decorators.push(MaxLength(max, { each: isArray }));\n if (enumObject) decorators.push(IsEnum(enumObject, { each: isArray }));\n if (isJson) decorators.push(IsJSON());\n if (isUrl) decorators.push(IsUrl());\n }\n\n return applyDecorators(...decorators);\n};\n"]}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AACjD,6CAAoD;AACpD,6CAAyF;AACzF,qDAiByB;AAElB,MAAM,WAAW,GAAG,CAAC,EAC1B,IAAI,EACJ,UAAU,EACV,GAAG,EACH,GAAG,EACH,OAAO,EACP,WAAW,EACX,UAAU,GAAG,KAAK,EAClB,MAAM,GAAG,KAAK,EACd,OAAO,GAAG,KAAK,EACf,MAAM,GAAG,KAAK,EACd,KAAK,GAAG,KAAK,EACb,UAAU,GAAG,KAAK,EAClB,UAAU,GAAG,KAAK,GAgBnB,EAIU,EAAE;IACX,MAAM,UAAU,GAAG,EAAE,CAAC;IAEtB,IAAI,UAAU,EAAE,CAAC;QACf,UAAU,CAAC,IAAI,CACb,IAAA,6BAAmB,EAAC;YAClB,OAAO;YACP,WAAW;SACZ,CAAC,CACH,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,IAAI,CAAC,IAAA,qBAAkB,EAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,KAAK;YACR,UAAU,CAAC,IAAI,CAAC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,aAAG,CAAC,CAAC,CAAC,CAAC,aAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;YAEhF,IAAI,UAAU;gBA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Property, ApiPropertyOptional } from '@nestjs/swagger';\nimport {\n IsArray,\n IsBoolean,\n IsDate,\n IsEnum,\n IsJSON,\n IsNegative,\n IsNumber,\n IsOptional,\n IsPositive,\n IsString,\n IsUrl,\n IsUUID,\n Max,\n MaxLength,\n Min,\n MinLength,\n} from 'class-validator';\n\nexport const ApiProperty = ({\n type,\n enumObject,\n min,\n max,\n example,\n description,\n isOptional = false,\n isUUID = false,\n isArray = false,\n isJson = false,\n isUrl = false,\n isPositive = false,\n isNegative = false,\n}: {\n type: 'string' | 'int' | 'float' | 'date' | 'boolean';\n enumObject?: object;\n min?: number;\n max?: number;\n example?: string;\n description?: string;\n isOptional?: boolean;\n isUUID?: boolean;\n isArray?: boolean;\n isJson?: boolean;\n isUrl?: boolean;\n isPositive?: boolean;\n isNegative?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n}): (<TFunction extends Function, Y>(\n target: TFunction | object,\n propertyKey?: string | symbol,\n descriptor?: TypedPropertyDescriptor<Y>,\n) => void) => {\n const decorators = [];\n\n if (isOptional) {\n decorators.push(\n ApiPropertyOptional({\n example,\n description,\n }),\n );\n } else {\n decorators.push(SwaggerApiProperty({ example, description }));\n }\n\n switch (type) {\n case 'int':\n decorators.push(Field(() => (isArray ? [Int] : Int), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n if (isArray) decorators.push(IsArray());\n\n decorators.push(IsNumber());\n\n if (min) decorators.push(Min(min, { each: isArray }));\n if (max) decorators.push(Max(max, { each: isArray }));\n\n break;\n case 'float':\n decorators.push(Field(() => (isArray ? [Float] : Float), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n if (isArray) decorators.push(IsArray());\n\n decorators.push(IsNumber());\n\n if (min) decorators.push(Min(min, { each: isArray }));\n if (max) decorators.push(Max(max, { each: isArray }));\n\n break;\n case 'date':\n decorators.push(Field(() => (isArray ? [Date] : Date), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n if (isArray) decorators.push(IsArray());\n\n decorators.push(IsDate({ each: isArray }));\n break;\n case 'boolean':\n decorators.push(Field({ nullable: isOptional }));\n if (isOptional) decorators.push(IsOptional());\n decorators.push(IsBoolean());\n break;\n case 'string':\n default:\n if (enumObject) {\n decorators.push(\n Field(() => (isArray ? [enumObject] : enumObject), { nullable: isOptional }),\n );\n } else {\n decorators.push(Field(() => (isArray ? [String] : String), { nullable: isOptional }));\n }\n\n if (isOptional) decorators.push(IsOptional());\n if (isArray) decorators.push(IsArray());\n\n decorators.push(IsString({ each: isArray }));\n\n if (isUUID) decorators.push(IsUUID());\n if (isPositive) decorators.push(IsPositive());\n if (isNegative) decorators.push(IsNegative());\n if (min) decorators.push(MinLength(min, { each: isArray }));\n if (max) decorators.push(MaxLength(max, { each: isArray }));\n if (enumObject) decorators.push(IsEnum(enumObject, { each: isArray }));\n if (isJson) decorators.push(IsJSON());\n if (isUrl) decorators.push(IsUrl());\n }\n\n return applyDecorators(...decorators);\n};\n"]}