@globalart/nestjs-swagger 1.2.4 → 1.2.6

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.d.ts CHANGED
@@ -1,3 +1,41 @@
1
- export * from "./constants";
2
- export * from "./decorators";
3
- export * from "./interfaces";
1
+ //#region src/constants.d.ts
2
+ declare const API_RESPONSE_DESCRIPTION = "If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text";
3
+ declare const ERROR_DESCRIPTIONS: {
4
+ BAD_REQUEST: string;
5
+ UNAUTHORIZED: string;
6
+ FORBIDDEN: string;
7
+ NOT_FOUND: string;
8
+ CONFLICT: string;
9
+ UNPROCESSABLE_ENTITY: string;
10
+ RATE_LIMIT_EXCEEDED: string;
11
+ INTERNAL_SERVER_ERROR: string;
12
+ SERVICE_UNAVAILABLE: string;
13
+ };
14
+ //#endregion
15
+ //#region src/interfaces/index.d.ts
16
+ interface SwaggerDocumentationErrorStatus {
17
+ error400Description?: string;
18
+ error401Description?: string;
19
+ error403Description?: string;
20
+ error404Description?: string;
21
+ error409Description?: string;
22
+ error422Description?: string;
23
+ error429Description?: string;
24
+ error500Description?: string;
25
+ error503Description?: string;
26
+ }
27
+ interface SwaggerDocumentationOptions extends SwaggerDocumentationErrorStatus {
28
+ endpointSummary: string;
29
+ endpointDescription?: string;
30
+ operationId?: string;
31
+ responseDto?: any;
32
+ isArray?: boolean;
33
+ isPaginated?: boolean;
34
+ deprecated?: boolean;
35
+ }
36
+ //#endregion
37
+ //#region src/decorators/index.d.ts
38
+ declare const SwaggerDocumentation: (data: SwaggerDocumentationOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
39
+ //#endregion
40
+ export { API_RESPONSE_DESCRIPTION, ERROR_DESCRIPTIONS, SwaggerDocumentation, SwaggerDocumentationErrorStatus, SwaggerDocumentationOptions };
41
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,19 +1,119 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1
+ import { applyDecorators } from "@nestjs/common";
2
+ import { ApiBadRequestResponse, ApiConflictResponse, ApiExtraModels, ApiForbiddenResponse, ApiInternalServerErrorResponse, ApiNotFoundResponse, ApiOkResponse, ApiOperation, ApiProperty, ApiServiceUnavailableResponse, ApiTooManyRequestsResponse, ApiUnauthorizedResponse, ApiUnprocessableEntityResponse, getSchemaPath } from "@nestjs/swagger";
3
+ import { createHash } from "crypto";
4
+
5
+ //#region rolldown:runtime
6
+ var __create = Object.create;
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __commonJS = (cb, mod) => function() {
13
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
14
  };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./constants"), exports);
18
- __exportStar(require("./decorators"), exports);
19
- __exportStar(require("./interfaces"), exports);
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
17
+ key = keys[i];
18
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: ((k) => from[k]).bind(null, key),
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
28
+ }) : target, mod));
29
+
30
+ //#endregion
31
+ //#region src/constants.ts
32
+ const API_RESPONSE_DESCRIPTION = "If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text";
33
+ const ERROR_DESCRIPTIONS = {
34
+ BAD_REQUEST: "Invalid request data or parameters",
35
+ UNAUTHORIZED: "Authentication required",
36
+ FORBIDDEN: "Access denied",
37
+ NOT_FOUND: "Resource not found",
38
+ CONFLICT: "Resource already exists or conflict detected",
39
+ UNPROCESSABLE_ENTITY: "Validation error",
40
+ RATE_LIMIT_EXCEEDED: "Rate limit exceeded. Too many requests",
41
+ INTERNAL_SERVER_ERROR: "Internal server error",
42
+ SERVICE_UNAVAILABLE: "Service temporarily unavailable"
43
+ };
44
+
45
+ //#endregion
46
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.87.0/node_modules/@oxc-project/runtime/src/helpers/decorateMetadata.js
47
+ var require_decorateMetadata = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.87.0/node_modules/@oxc-project/runtime/src/helpers/decorateMetadata.js": ((exports, module) => {
48
+ function __decorateMetadata(k, v) {
49
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
50
+ }
51
+ module.exports = __decorateMetadata, module.exports.__esModule = true, module.exports["default"] = module.exports;
52
+ }) });
53
+
54
+ //#endregion
55
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.87.0/node_modules/@oxc-project/runtime/src/helpers/decorate.js
56
+ var require_decorate = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.87.0/node_modules/@oxc-project/runtime/src/helpers/decorate.js": ((exports, module) => {
57
+ function __decorate(decorators, target, key, desc) {
58
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
59
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
60
+ 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;
61
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
62
+ }
63
+ module.exports = __decorate, module.exports.__esModule = true, module.exports["default"] = module.exports;
64
+ }) });
65
+
66
+ //#endregion
67
+ //#region src/dtos/index.ts
68
+ var import_decorateMetadata = /* @__PURE__ */ __toESM(require_decorateMetadata(), 1);
69
+ var import_decorate = /* @__PURE__ */ __toESM(require_decorate(), 1);
70
+ var PaginatedResponseDto = class {
71
+ data;
72
+ totalCount;
73
+ offset;
74
+ limit;
75
+ };
76
+ (0, import_decorate.default)([ApiProperty(), (0, import_decorateMetadata.default)("design:type", Number)], PaginatedResponseDto.prototype, "totalCount", void 0);
77
+ (0, import_decorate.default)([ApiProperty(), (0, import_decorateMetadata.default)("design:type", Number)], PaginatedResponseDto.prototype, "offset", void 0);
78
+ (0, import_decorate.default)([ApiProperty(), (0, import_decorateMetadata.default)("design:type", Number)], PaginatedResponseDto.prototype, "limit", void 0);
79
+
80
+ //#endregion
81
+ //#region src/decorators/index.ts
82
+ const SwaggerDocumentation = (data) => {
83
+ const operationId = data.operationId || createHash("md5").update(`${data.endpointSummary}`).digest("hex");
84
+ const decorators = [ApiOperation({
85
+ operationId,
86
+ description: data.endpointDescription,
87
+ summary: data.endpointSummary,
88
+ deprecated: data.deprecated
89
+ })];
90
+ if (data.error400Description) decorators.push(ApiBadRequestResponse({ description: data.error400Description }));
91
+ if (data.error401Description) decorators.push(ApiUnauthorizedResponse({ description: data.error401Description }));
92
+ if (data.error403Description) decorators.push(ApiForbiddenResponse({ description: data.error403Description }));
93
+ if (data.error404Description) decorators.push(ApiNotFoundResponse({ description: data.error404Description }));
94
+ if (data.error409Description) decorators.push(ApiConflictResponse({ description: data.error409Description }));
95
+ if (data.error422Description) decorators.push(ApiUnprocessableEntityResponse({ description: data.error422Description }));
96
+ if (data.error429Description) decorators.push(ApiTooManyRequestsResponse({ description: data.error429Description }));
97
+ if (data.error500Description) decorators.push(ApiInternalServerErrorResponse({ description: data.error500Description }));
98
+ if (data.error503Description) decorators.push(ApiServiceUnavailableResponse({ description: data.error503Description }));
99
+ if (data.isPaginated && data.responseDto) decorators.push(ApiOkResponse({
100
+ schema: { allOf: [{ $ref: getSchemaPath(PaginatedResponseDto) }, { properties: { data: {
101
+ type: "array",
102
+ items: { $ref: getSchemaPath(data.responseDto) }
103
+ } } }] },
104
+ description: API_RESPONSE_DESCRIPTION
105
+ }), ApiExtraModels(data.responseDto, PaginatedResponseDto));
106
+ else if (data.responseDto) decorators.push(ApiOkResponse({
107
+ schema: data.isArray ? {
108
+ type: "array",
109
+ items: { $ref: getSchemaPath(data.responseDto) }
110
+ } : { $ref: getSchemaPath(data.responseDto) },
111
+ description: API_RESPONSE_DESCRIPTION
112
+ }), ApiExtraModels(data.responseDto));
113
+ else decorators.push(ApiOkResponse({ description: API_RESPONSE_DESCRIPTION }));
114
+ return applyDecorators(...decorators);
115
+ };
116
+
117
+ //#endregion
118
+ export { API_RESPONSE_DESCRIPTION, ERROR_DESCRIPTIONS, SwaggerDocumentation };
119
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/constants.ts","../../../node_modules/.pnpm/@oxc-project+runtime@0.87.0/node_modules/@oxc-project/runtime/src/helpers/decorateMetadata.js","../../../node_modules/.pnpm/@oxc-project+runtime@0.87.0/node_modules/@oxc-project/runtime/src/helpers/decorate.js","../src/dtos/index.ts","../src/decorators/index.ts"],"sourcesContent":["export const API_RESPONSE_DESCRIPTION =\n \"If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text\";\n\nexport const ERROR_DESCRIPTIONS = {\n BAD_REQUEST: \"Invalid request data or parameters\",\n UNAUTHORIZED: \"Authentication required\",\n FORBIDDEN: \"Access denied\",\n NOT_FOUND: \"Resource not found\",\n CONFLICT: \"Resource already exists or conflict detected\",\n UNPROCESSABLE_ENTITY: \"Validation error\",\n RATE_LIMIT_EXCEEDED: \"Rate limit exceeded. Too many requests\",\n INTERNAL_SERVER_ERROR: \"Internal server error\",\n SERVICE_UNAVAILABLE: \"Service temporarily unavailable\",\n};\n","// Copy from https://github.com/microsoft/TypeScript/blob/d85767abfd83880cea17cea70f9913e9c4496dcc/src/compiler/factory/emitHelpers.ts#L744-L753\n\nfunction __decorateMetadata(k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};\n\n(module.exports = __decorateMetadata),\n (module.exports.__esModule = true),\n (module.exports[\"default\"] = module.exports);\n","// Copy from https://github.com/microsoft/TypeScript/blob/d85767abfd83880cea17cea70f9913e9c4496dcc/src/compiler/factory/emitHelpers.ts#L730-L742\n\nfunction __decorate(decorators, target, key, desc) {\n var c = arguments.length,\n r =\n c < 3\n ? target\n : desc === null\n ? (desc = Object.getOwnPropertyDescriptor(target, key))\n : desc,\n d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\")\n r = Reflect.decorate(decorators, target, key, desc);\n else\n for (var i = decorators.length - 1; i >= 0; i--)\n if ((d = decorators[i]))\n r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\n(module.exports = __decorate),\n (module.exports.__esModule = true),\n (module.exports[\"default\"] = module.exports);\n","import { ApiProperty } from \"@nestjs/swagger\";\n\nexport class PaginatedResponseDto<T> {\n data!: T[];\n\n @ApiProperty()\n totalCount!: number;\n\n @ApiProperty()\n offset!: number;\n\n @ApiProperty()\n limit!: number;\n}\n","import { applyDecorators } from \"@nestjs/common\";\nimport {\n ApiBadRequestResponse,\n ApiConflictResponse,\n ApiExtraModels,\n ApiForbiddenResponse,\n ApiInternalServerErrorResponse,\n ApiNotFoundResponse,\n ApiOkResponse,\n ApiOperation,\n ApiServiceUnavailableResponse,\n ApiTooManyRequestsResponse,\n ApiUnauthorizedResponse,\n ApiUnprocessableEntityResponse,\n getSchemaPath,\n} from \"@nestjs/swagger\";\nimport { API_RESPONSE_DESCRIPTION } from \"../constants\";\nimport { PaginatedResponseDto } from \"../dtos\";\nimport { SwaggerDocumentationOptions } from \"../interfaces\";\nimport { createHash } from \"crypto\";\n\n// SwaggerDocumentation is a decorator function to generate Swagger documentation for endpoints based on the provided options.\nexport const SwaggerDocumentation = (data: SwaggerDocumentationOptions) => {\n const operationId =\n data.operationId ||\n createHash(\"md5\").update(`${data.endpointSummary}`).digest(\"hex\");\n\n const decorators = [\n ApiOperation({\n operationId,\n description: data.endpointDescription,\n summary: data.endpointSummary,\n deprecated: data.deprecated,\n }),\n ];\n\n if (data.error400Description) {\n decorators.push(\n ApiBadRequestResponse({\n description: data.error400Description,\n })\n );\n }\n\n if (data.error401Description) {\n decorators.push(\n ApiUnauthorizedResponse({\n description: data.error401Description,\n })\n );\n }\n\n if (data.error403Description) {\n decorators.push(\n ApiForbiddenResponse({\n description: data.error403Description,\n })\n );\n }\n\n if (data.error404Description) {\n decorators.push(\n ApiNotFoundResponse({\n description: data.error404Description,\n })\n );\n }\n\n if (data.error409Description) {\n decorators.push(\n ApiConflictResponse({\n description: data.error409Description,\n })\n );\n }\n\n if (data.error422Description) {\n decorators.push(\n ApiUnprocessableEntityResponse({\n description: data.error422Description,\n })\n );\n }\n\n if (data.error429Description) {\n decorators.push(\n ApiTooManyRequestsResponse({\n description: data.error429Description,\n })\n );\n }\n\n if (data.error500Description) {\n decorators.push(\n ApiInternalServerErrorResponse({\n description: data.error500Description,\n })\n );\n }\n\n if (data.error503Description) {\n decorators.push(\n ApiServiceUnavailableResponse({\n description: data.error503Description,\n })\n );\n }\n\n if (data.isPaginated && data.responseDto) {\n decorators.push(\n ApiOkResponse({\n schema: {\n allOf: [\n { $ref: getSchemaPath(PaginatedResponseDto) },\n {\n properties: {\n data: {\n type: \"array\",\n items: {\n $ref: getSchemaPath(data.responseDto),\n },\n },\n },\n },\n ],\n },\n description: API_RESPONSE_DESCRIPTION,\n }),\n ApiExtraModels(data.responseDto, PaginatedResponseDto)\n );\n } else if (data.responseDto) {\n decorators.push(\n ApiOkResponse({\n schema: data.isArray\n ? {\n type: \"array\",\n items: { $ref: getSchemaPath(data.responseDto) },\n }\n : { $ref: getSchemaPath(data.responseDto) },\n description: API_RESPONSE_DESCRIPTION,\n }),\n ApiExtraModels(data.responseDto)\n );\n } else {\n decorators.push(\n ApiOkResponse({\n description: API_RESPONSE_DESCRIPTION,\n })\n );\n }\n\n return applyDecorators(...decorators);\n};\n"],"x_google_ignoreList":[1,2],"mappings":"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"}
package/package.json CHANGED
@@ -1,28 +1,27 @@
1
1
  {
2
2
  "name": "@globalart/nestjs-swagger",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "A simple documentation builder for NestJS Swagger Module",
5
5
  "author": {
6
6
  "name": "GlobalArt, Inc"
7
7
  },
8
8
  "license": "MIT",
9
- "main": "./dist/index.js",
10
- "types": "./dist/index.d.ts",
9
+ "type": "module",
11
10
  "files": [
12
11
  "dist",
13
12
  "README.md",
14
13
  "LICENSE"
15
14
  ],
15
+ "main": "./dist/index.js",
16
+ "module": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
16
18
  "exports": {
17
- ".": {
18
- "require": "./dist/index.js",
19
- "import": "./dist/index.js",
20
- "types": "./dist/index.d.ts"
21
- }
19
+ ".": "./dist/index.js",
20
+ "./package.json": "./package.json"
22
21
  },
23
22
  "repository": {
24
23
  "type": "git",
25
- "url": "git+https://github.com/GlobalArtInc/nestjs-toolkit.git#main"
24
+ "url": "git+https://github.com/GlobalArtInc/ecosystem.git#main"
26
25
  },
27
26
  "keywords": [
28
27
  "nestjs",
@@ -34,22 +33,23 @@
34
33
  "test": "jest --runInBand --passWithNoTests",
35
34
  "test:cov": "jest --coverage --passWithNoTests",
36
35
  "coveralls": "yarn run test:cov --coverageReporters=text-lcov | coveralls",
37
- "build": "rm -rf ./dist && tsc",
36
+ "build": "tsdown",
37
+ "build:watch": "tsdown --watch",
38
38
  "prepublishOnly": "npm run build",
39
39
  "publish:dev": "npm publish --access public --tag dev",
40
40
  "publish:npm": "release-it"
41
41
  },
42
42
  "dependencies": {
43
- "@nestjs/common": "^11.1.3",
44
- "@nestjs/core": "^11.1.3",
43
+ "@nestjs/common": "^11.1.6",
44
+ "@nestjs/core": "^11.1.6",
45
45
  "@nestjs/swagger": "^11.2.0",
46
- "@nestjs/testing": "^11.1.3",
46
+ "@nestjs/testing": "^11.1.6",
47
47
  "@nestjs/typeorm": "^11.0.0",
48
48
  "mysql": "^2.18.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/jest": "^30.0.0",
52
- "@types/node": "^24.0.7",
52
+ "@types/node": "^24.3.0",
53
53
  "coveralls": "^3.1.1",
54
54
  "jest": "^30.0.3",
55
55
  "prettier": "^3.6.2",
@@ -58,8 +58,9 @@
58
58
  "rxjs": "^7.8.2",
59
59
  "ts-jest": "^29.4.0",
60
60
  "ts-node": "^10.9.2",
61
- "typeorm": "0.3.25",
62
- "typescript": "^5.8.3"
61
+ "typeorm": "0.3.26",
62
+ "tsdown": "0.15.7",
63
+ "typescript": "^5.9.2"
63
64
  },
64
65
  "jest": {
65
66
  "coveragePathIgnorePatterns": [
@@ -1,12 +0,0 @@
1
- export declare const API_RESPONSE_DESCRIPTION = "If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text";
2
- export declare const ERROR_DESCRIPTIONS: {
3
- BAD_REQUEST: string;
4
- UNAUTHORIZED: string;
5
- FORBIDDEN: string;
6
- NOT_FOUND: string;
7
- CONFLICT: string;
8
- UNPROCESSABLE_ENTITY: string;
9
- RATE_LIMIT_EXCEEDED: string;
10
- INTERNAL_SERVER_ERROR: string;
11
- SERVICE_UNAVAILABLE: string;
12
- };
package/dist/constants.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ERROR_DESCRIPTIONS = exports.API_RESPONSE_DESCRIPTION = void 0;
4
- exports.API_RESPONSE_DESCRIPTION = "If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text";
5
- exports.ERROR_DESCRIPTIONS = {
6
- BAD_REQUEST: "Invalid request data or parameters",
7
- UNAUTHORIZED: "Authentication required",
8
- FORBIDDEN: "Access denied",
9
- NOT_FOUND: "Resource not found",
10
- CONFLICT: "Resource already exists or conflict detected",
11
- UNPROCESSABLE_ENTITY: "Validation error",
12
- RATE_LIMIT_EXCEEDED: "Rate limit exceeded. Too many requests",
13
- INTERNAL_SERVER_ERROR: "Internal server error",
14
- SERVICE_UNAVAILABLE: "Service temporarily unavailable",
15
- };
@@ -1,2 +0,0 @@
1
- import { SwaggerDocumentationOptions } from "../interfaces";
2
- export declare const SwaggerDocumentation: (data: SwaggerDocumentationOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SwaggerDocumentation = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const swagger_1 = require("@nestjs/swagger");
6
- const constants_1 = require("../constants");
7
- const dtos_1 = require("../dtos");
8
- // SwaggerDocumentation is a decorator function to generate Swagger documentation for endpoints based on the provided options.
9
- const SwaggerDocumentation = (data) => {
10
- const decorators = [
11
- (0, swagger_1.ApiOperation)({
12
- description: data.endpointDescription,
13
- summary: data.endpointSummary,
14
- }),
15
- ];
16
- if (data.error400Description) {
17
- decorators.push((0, swagger_1.ApiBadRequestResponse)({
18
- description: data.error400Description,
19
- }));
20
- }
21
- if (data.error401Description) {
22
- decorators.push((0, swagger_1.ApiUnauthorizedResponse)({
23
- description: data.error401Description,
24
- }));
25
- }
26
- if (data.error403Description) {
27
- decorators.push((0, swagger_1.ApiForbiddenResponse)({
28
- description: data.error403Description,
29
- }));
30
- }
31
- if (data.error404Description) {
32
- decorators.push((0, swagger_1.ApiNotFoundResponse)({
33
- description: data.error404Description,
34
- }));
35
- }
36
- if (data.error409Description) {
37
- decorators.push((0, swagger_1.ApiConflictResponse)({
38
- description: data.error409Description,
39
- }));
40
- }
41
- if (data.error422Description) {
42
- decorators.push((0, swagger_1.ApiUnprocessableEntityResponse)({
43
- description: data.error422Description,
44
- }));
45
- }
46
- if (data.error429Description) {
47
- decorators.push((0, swagger_1.ApiTooManyRequestsResponse)({
48
- description: data.error429Description,
49
- }));
50
- }
51
- if (data.error500Description) {
52
- decorators.push((0, swagger_1.ApiInternalServerErrorResponse)({
53
- description: data.error500Description,
54
- }));
55
- }
56
- if (data.error503Description) {
57
- decorators.push((0, swagger_1.ApiServiceUnavailableResponse)({
58
- description: data.error503Description,
59
- }));
60
- }
61
- if (data.isPaginated && data.responseDto) {
62
- decorators.push((0, swagger_1.ApiOkResponse)({
63
- schema: {
64
- allOf: [
65
- { $ref: (0, swagger_1.getSchemaPath)(dtos_1.PaginatedResponseDto) },
66
- {
67
- properties: {
68
- data: {
69
- type: "array",
70
- items: {
71
- $ref: (0, swagger_1.getSchemaPath)(data.responseDto),
72
- },
73
- },
74
- },
75
- },
76
- ],
77
- },
78
- description: constants_1.API_RESPONSE_DESCRIPTION,
79
- }), (0, swagger_1.ApiExtraModels)(data.responseDto, dtos_1.PaginatedResponseDto));
80
- }
81
- else if (data.responseDto) {
82
- decorators.push((0, swagger_1.ApiOkResponse)({
83
- schema: data.isArray
84
- ? {
85
- type: "array",
86
- items: { $ref: (0, swagger_1.getSchemaPath)(data.responseDto) },
87
- }
88
- : { $ref: (0, swagger_1.getSchemaPath)(data.responseDto) },
89
- description: constants_1.API_RESPONSE_DESCRIPTION,
90
- }), (0, swagger_1.ApiExtraModels)(data.responseDto));
91
- }
92
- else {
93
- decorators.push((0, swagger_1.ApiOkResponse)({
94
- description: constants_1.API_RESPONSE_DESCRIPTION,
95
- }));
96
- }
97
- return (0, common_1.applyDecorators)(...decorators);
98
- };
99
- exports.SwaggerDocumentation = SwaggerDocumentation;
@@ -1,6 +0,0 @@
1
- export declare class PaginatedResponseDto<T> {
2
- data: T[];
3
- totalCount: number;
4
- offset: number;
5
- limit: number;
6
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PaginatedResponseDto = void 0;
13
- const swagger_1 = require("@nestjs/swagger");
14
- class PaginatedResponseDto {
15
- data;
16
- totalCount;
17
- offset;
18
- limit;
19
- }
20
- exports.PaginatedResponseDto = PaginatedResponseDto;
21
- __decorate([
22
- (0, swagger_1.ApiProperty)(),
23
- __metadata("design:type", Number)
24
- ], PaginatedResponseDto.prototype, "totalCount", void 0);
25
- __decorate([
26
- (0, swagger_1.ApiProperty)(),
27
- __metadata("design:type", Number)
28
- ], PaginatedResponseDto.prototype, "offset", void 0);
29
- __decorate([
30
- (0, swagger_1.ApiProperty)(),
31
- __metadata("design:type", Number)
32
- ], PaginatedResponseDto.prototype, "limit", void 0);
@@ -1,18 +0,0 @@
1
- export interface SwaggerDocumentationErrorStatus {
2
- error400Description?: string;
3
- error401Description?: string;
4
- error403Description?: string;
5
- error404Description?: string;
6
- error409Description?: string;
7
- error422Description?: string;
8
- error429Description?: string;
9
- error500Description?: string;
10
- error503Description?: string;
11
- }
12
- export interface SwaggerDocumentationOptions extends SwaggerDocumentationErrorStatus {
13
- endpointDescription?: string;
14
- endpointSummary?: string;
15
- responseDto?: any;
16
- isArray?: boolean;
17
- isPaginated?: boolean;
18
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });