denwa-nest-shared 1.0.14 → 1.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
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.15](https://github.com/web-bee-ru/openapi-axios/compare/v1.0.14...v1.0.15) (2025-03-18)
6
+
5
7
  ### [1.0.14](https://github.com/web-bee-ru/openapi-axios/compare/v1.0.13...v1.0.14) (2025-03-10)
6
8
 
7
9
  ### [1.0.13](https://github.com/web-bee-ru/openapi-axios/compare/v1.0.12...v1.0.13) (2025-03-10)
@@ -0,0 +1,15 @@
1
+ export declare const ApiProperty: ({ type, enumObject, min, max, example, description, isOptional, isUUID, isArray, isJson, isUrl, isPositive, isNegative, }: {
2
+ type: "string" | "int" | "float" | "date" | "boolean";
3
+ enumObject?: object;
4
+ min?: number;
5
+ max?: number;
6
+ example?: string;
7
+ description?: string;
8
+ isOptional?: boolean;
9
+ isUUID?: boolean;
10
+ isArray?: boolean;
11
+ isJson?: boolean;
12
+ isUrl?: boolean;
13
+ isPositive?: boolean;
14
+ isNegative?: boolean;
15
+ }) => (<TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void);
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiProperty = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const graphql_1 = require("@nestjs/graphql");
6
+ const swagger_1 = require("@nestjs/swagger");
7
+ const class_validator_1 = require("class-validator");
8
+ const ApiProperty = ({ type, enumObject, min, max, example, description, isOptional = false, isUUID = false, isArray = false, isJson = false, isUrl = false, isPositive = false, isNegative = false, }) => {
9
+ const decorators = [];
10
+ if (isOptional) {
11
+ decorators.push((0, swagger_1.ApiPropertyOptional)({
12
+ example,
13
+ description,
14
+ }));
15
+ }
16
+ else {
17
+ decorators.push((0, swagger_1.ApiProperty)({ example, description }));
18
+ }
19
+ switch (type) {
20
+ case 'int':
21
+ decorators.push((0, graphql_1.Field)(() => graphql_1.Int, { nullable: isOptional }));
22
+ if (isOptional)
23
+ decorators.push((0, class_validator_1.IsOptional)());
24
+ if (isArray)
25
+ decorators.push((0, class_validator_1.IsArray)());
26
+ decorators.push((0, class_validator_1.IsNumber)());
27
+ if (min)
28
+ decorators.push((0, class_validator_1.Min)(min, { each: isArray }));
29
+ if (max)
30
+ decorators.push((0, class_validator_1.Max)(max, { each: isArray }));
31
+ break;
32
+ case 'float':
33
+ decorators.push((0, graphql_1.Field)(() => graphql_1.Float, { nullable: isOptional }));
34
+ if (isOptional)
35
+ decorators.push((0, class_validator_1.IsOptional)());
36
+ if (isArray)
37
+ decorators.push((0, class_validator_1.IsArray)());
38
+ decorators.push((0, class_validator_1.IsNumber)());
39
+ if (min)
40
+ decorators.push((0, class_validator_1.Min)(min, { each: isArray }));
41
+ if (max)
42
+ decorators.push((0, class_validator_1.Max)(max, { each: isArray }));
43
+ break;
44
+ case 'date':
45
+ decorators.push((0, graphql_1.Field)(() => Date, { nullable: isOptional }));
46
+ if (isOptional)
47
+ decorators.push((0, class_validator_1.IsOptional)());
48
+ if (isArray)
49
+ decorators.push((0, class_validator_1.IsArray)());
50
+ decorators.push((0, class_validator_1.IsDate)({ each: isArray }));
51
+ break;
52
+ case 'boolean':
53
+ decorators.push((0, graphql_1.Field)({ nullable: isOptional }));
54
+ if (isOptional)
55
+ decorators.push((0, class_validator_1.IsOptional)());
56
+ decorators.push((0, class_validator_1.IsBoolean)());
57
+ break;
58
+ case 'string':
59
+ default:
60
+ decorators.push((0, graphql_1.Field)(() => String, { nullable: isOptional }));
61
+ if (isOptional)
62
+ decorators.push((0, class_validator_1.IsOptional)());
63
+ if (isArray)
64
+ decorators.push((0, class_validator_1.IsArray)());
65
+ decorators.push((0, class_validator_1.IsString)({ each: isArray }));
66
+ if (isUUID)
67
+ decorators.push((0, class_validator_1.IsUUID)());
68
+ if (isPositive)
69
+ decorators.push((0, class_validator_1.IsPositive)());
70
+ if (isNegative)
71
+ decorators.push((0, class_validator_1.IsNegative)());
72
+ if (min)
73
+ decorators.push((0, class_validator_1.MinLength)(min, { each: isArray }));
74
+ if (max)
75
+ decorators.push((0, class_validator_1.MaxLength)(max, { each: isArray }));
76
+ if (enumObject)
77
+ decorators.push((0, class_validator_1.IsEnum)(enumObject, { each: isArray }));
78
+ if (isJson)
79
+ decorators.push((0, class_validator_1.IsJSON)());
80
+ if (isUrl)
81
+ decorators.push((0, class_validator_1.IsUrl)());
82
+ }
83
+ return (0, common_1.applyDecorators)(...decorators);
84
+ };
85
+ exports.ApiProperty = ApiProperty;
86
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +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,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC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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"]}
package/cjs/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './lib';
3
3
  export * from './types';
4
4
  export * from './const';
5
5
  export * from './validation';
6
+ export * from './decorators';
package/cjs/index.js CHANGED
@@ -19,4 +19,5 @@ __exportStar(require("./lib"), exports);
19
19
  __exportStar(require("./types"), exports);
20
20
  __exportStar(require("./const"), exports);
21
21
  __exportStar(require("./validation"), exports);
22
+ __exportStar(require("./decorators"), exports);
22
23
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,wCAAsB;AACtB,0CAAwB;AACxB,0CAAwB;AACxB,+CAA6B","sourcesContent":["export * from './dto';\nexport * from './lib';\nexport * from './types';\nexport * from './const';\nexport * from './validation';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,wCAAsB;AACtB,0CAAwB;AACxB,0CAAwB;AACxB,+CAA6B;AAC7B,+CAA6B","sourcesContent":["export * from './dto';\nexport * from './lib';\nexport * from './types';\nexport * from './const';\nexport * from './validation';\nexport * from './decorators';\n"]}