UNPKG

denwa-nest-shared

Version:

Shared NestJS module for DTO validation, RBAC, TypeORM query building, and OpenAPI client

833 lines • 27.1 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Field, InputType, Int, ObjectType } from '@nestjs/graphql'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsArray, IsOptional, IsString, IsUUID, Length, ValidateNested } from 'class-validator'; import { ApiValidationProperty } from './decorators'; let Paginate = class Paginate { page; pages; previous; next; count; limit; }; __decorate([ ApiProperty({ example: '1', description: 'Страница', }), Field(() => Int), __metadata("design:type", Number) ], Paginate.prototype, "page", void 0); __decorate([ ApiProperty({ example: '10', description: 'Всего страниц', }), Field(() => Int), __metadata("design:type", Number) ], Paginate.prototype, "pages", void 0); __decorate([ ApiPropertyOptional({ example: '2', description: 'Предыдущая страница', }), Field(() => Int, { nullable: true }), __metadata("design:type", Number) ], Paginate.prototype, "previous", void 0); __decorate([ ApiPropertyOptional({ example: '3', description: 'Следующая страница', }), Field(() => Int, { nullable: true }), __metadata("design:type", Number) ], Paginate.prototype, "next", void 0); __decorate([ ApiProperty({ example: '1000', description: 'Количество', }), Field(() => Int), __metadata("design:type", Number) ], Paginate.prototype, "count", void 0); __decorate([ ApiProperty({ example: '100', description: 'Лимит записей', }), Field(() => Int), __metadata("design:type", Number) ], Paginate.prototype, "limit", void 0); Paginate = __decorate([ ObjectType() ], Paginate); export { Paginate }; let DeleteDto = class DeleteDto { id; }; __decorate([ ApiProperty({ example: '3422b448-2460-4fd2-9183-8000de6f8343', description: 'Уникальный идентификатор', }), Field(), IsUUID(), __metadata("design:type", String) ], DeleteDto.prototype, "id", void 0); DeleteDto = __decorate([ InputType() ], DeleteDto); export { DeleteDto }; export class ImageFileDto { imageName; originalFileExtension; entityId; fullPathExample; folder; fileExtensions; prefixes; } __decorate([ ApiProperty({ example: 'qwert', description: 'Название файла' }), IsString(), __metadata("design:type", String) ], ImageFileDto.prototype, "imageName", void 0); __decorate([ ApiProperty({ example: 'jpg', description: 'Расширение исходного файла' }), IsString(), __metadata("design:type", String) ], ImageFileDto.prototype, "originalFileExtension", void 0); __decorate([ ApiProperty({ example: 'qwert', description: 'Id сущности' }), IsUUID(), __metadata("design:type", String) ], ImageFileDto.prototype, "entityId", void 0); __decorate([ ApiProperty({ example: 'qwert/qwert.jpg', description: 'Пример пути к файлу' }), IsString(), __metadata("design:type", String) ], ImageFileDto.prototype, "fullPathExample", void 0); __decorate([ ApiProperty({ example: 'video', description: 'Внутренняя папка' }), IsOptional(), IsString(), __metadata("design:type", String) ], ImageFileDto.prototype, "folder", void 0); __decorate([ ApiProperty({ example: '[webp, jpg]', description: 'Расширения готовых файлов' }), IsOptional(), IsArray(), IsString({ each: true }), __metadata("design:type", Array) ], ImageFileDto.prototype, "fileExtensions", void 0); __decorate([ ApiProperty({ example: '[original, 1280x720]', description: 'Префиксы файла' }), IsOptional(), IsArray(), IsString({ each: true }), __metadata("design:type", Array) ], ImageFileDto.prototype, "prefixes", void 0); export class FileDto { name; fullName; extension; entityId; fullPathExample; folder; } __decorate([ ApiProperty({ example: 'qwert', description: 'Название файла' }), IsString(), __metadata("design:type", String) ], FileDto.prototype, "name", void 0); __decorate([ ApiProperty({ example: 'qwert.jpg', description: 'Полное название файла' }), IsString(), __metadata("design:type", String) ], FileDto.prototype, "fullName", void 0); __decorate([ ApiProperty({ example: 'jpg', description: 'Расширение исходного файла' }), IsString(), __metadata("design:type", String) ], FileDto.prototype, "extension", void 0); __decorate([ ApiProperty({ description: 'Id сущности' }), IsUUID(), __metadata("design:type", String) ], FileDto.prototype, "entityId", void 0); __decorate([ ApiProperty({ example: 'qwert/qwert.jpg', description: 'Пример пути к файлу' }), IsString(), __metadata("design:type", String) ], FileDto.prototype, "fullPathExample", void 0); __decorate([ ApiProperty({ example: 'video', description: 'Внутренняя папка' }), IsOptional(), IsString(), __metadata("design:type", String) ], FileDto.prototype, "folder", void 0); let OkRequestDto = class OkRequestDto { statusCode; message; }; __decorate([ ApiProperty({ example: '200', description: 'Статус код' }), Field(() => Int), __metadata("design:type", Number) ], OkRequestDto.prototype, "statusCode", void 0); __decorate([ ApiPropertyOptional({ example: 'Успех', description: 'Сообщение' }), Field({ nullable: true }), __metadata("design:type", String) ], OkRequestDto.prototype, "message", void 0); OkRequestDto = __decorate([ ObjectType() ], OkRequestDto); export { OkRequestDto }; let CreatedRequestDto = class CreatedRequestDto { statusCode; message; }; __decorate([ ApiProperty({ example: '201', description: 'Статус код' }), Field(() => Int), __metadata("design:type", Number) ], CreatedRequestDto.prototype, "statusCode", void 0); __decorate([ ApiPropertyOptional({ example: 'Успех', description: 'Сообщение' }), Field({ nullable: true }), __metadata("design:type", String) ], CreatedRequestDto.prototype, "message", void 0); CreatedRequestDto = __decorate([ ObjectType() ], CreatedRequestDto); export { CreatedRequestDto }; class ErrorDto { message; messages; error; } __decorate([ ApiPropertyOptional({ example: 'Ошибка', description: 'Сообщение' }), __metadata("design:type", String) ], ErrorDto.prototype, "message", void 0); __decorate([ ApiPropertyOptional({ example: '["Ошибка в поле name"]', description: 'Массив сообщений' }), __metadata("design:type", Array) ], ErrorDto.prototype, "messages", void 0); __decorate([ ApiPropertyOptional({ example: 'Bad Request', description: 'Сообщение ошибки' }), __metadata("design:type", String) ], ErrorDto.prototype, "error", void 0); export class BadRequestDto extends ErrorDto { statusCode; } __decorate([ ApiProperty({ example: '400', description: 'Статус код' }), __metadata("design:type", Number) ], BadRequestDto.prototype, "statusCode", void 0); export class UnauthorizedDto extends ErrorDto { statusCode; } __decorate([ ApiProperty({ example: '401', description: 'Статус код' }), __metadata("design:type", Number) ], UnauthorizedDto.prototype, "statusCode", void 0); export class ForbiddenDto extends ErrorDto { statusCode; } __decorate([ ApiProperty({ example: '403', description: 'Статус код' }), __metadata("design:type", Number) ], ForbiddenDto.prototype, "statusCode", void 0); export class NotFoundDto extends ErrorDto { statusCode; } __decorate([ ApiProperty({ example: '404', description: 'Статус код' }), __metadata("design:type", Number) ], NotFoundDto.prototype, "statusCode", void 0); export class MethodNotAllowedDto extends ErrorDto { statusCode; } __decorate([ ApiProperty({ example: '405', description: 'Статус код' }), __metadata("design:type", Number) ], MethodNotAllowedDto.prototype, "statusCode", void 0); export class InternalErrorDto extends ErrorDto { statusCode; } __decorate([ ApiProperty({ example: '500', description: 'Статус код' }), __metadata("design:type", Number) ], InternalErrorDto.prototype, "statusCode", void 0); export class BadGatewayDto extends ErrorDto { statusCode; } __decorate([ ApiProperty({ example: '502', description: 'Статус код' }), __metadata("design:type", Number) ], BadGatewayDto.prototype, "statusCode", void 0); let TempFilesDto = class TempFilesDto { tempName; }; __decorate([ ApiProperty({ example: 'test.jpg', description: 'Название файла в temp backet' }), Field(() => String), IsString(), Length(1, 256), __metadata("design:type", String) ], TempFilesDto.prototype, "tempName", void 0); TempFilesDto = __decorate([ InputType() ], TempFilesDto); export { TempFilesDto }; let TempImagesDto = class TempImagesDto extends TempFilesDto { altRU; altEN; altAR; }; __decorate([ ApiPropertyOptional({ example: 'Вид на Сочи', description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], TempImagesDto.prototype, "altRU", void 0); __decorate([ ApiPropertyOptional({ description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], TempImagesDto.prototype, "altEN", void 0); __decorate([ ApiPropertyOptional({ description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], TempImagesDto.prototype, "altAR", void 0); TempImagesDto = __decorate([ InputType() ], TempImagesDto); export { TempImagesDto }; let AddTempImagesDto = class AddTempImagesDto extends TempImagesDto { id; }; __decorate([ ApiProperty({ example: '3422b448-2460-4fd2-9183-8000de6f8343', description: 'Уникальный идентификатор', }), Field(), IsUUID(), __metadata("design:type", String) ], AddTempImagesDto.prototype, "id", void 0); AddTempImagesDto = __decorate([ InputType() ], AddTempImagesDto); export { AddTempImagesDto }; let AllFilesDto = class AllFilesDto { name; tempName; }; __decorate([ ApiProperty({ example: 'test', description: 'Название файла' }), Field(() => String, { nullable: true }), IsOptional(), IsString(), Length(1, 512), __metadata("design:type", String) ], AllFilesDto.prototype, "name", void 0); __decorate([ ApiProperty({ example: 'test.jpg', description: 'Название файла в temp backet' }), Field(() => String, { nullable: true }), IsOptional(), IsString(), Length(1, 512), __metadata("design:type", String) ], AllFilesDto.prototype, "tempName", void 0); AllFilesDto = __decorate([ InputType() ], AllFilesDto); export { AllFilesDto }; let AllImagesDto = class AllImagesDto extends AllFilesDto { altRU; altEN; altAR; }; __decorate([ ApiPropertyOptional({ example: 'Вид на Сочи', description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], AllImagesDto.prototype, "altRU", void 0); __decorate([ ApiPropertyOptional({ description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], AllImagesDto.prototype, "altEN", void 0); __decorate([ ApiPropertyOptional({ description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], AllImagesDto.prototype, "altAR", void 0); AllImagesDto = __decorate([ InputType() ], AllImagesDto); export { AllImagesDto }; let PreparedImageDto = class PreparedImageDto { name; fileExtensions; prefixes; originalFileExtension; entityId; fullPathExample; folder; altRU; altEN; altAR; }; __decorate([ ApiProperty({ example: 'qwer', description: 'Название файла' }), Field(), IsString(), __metadata("design:type", String) ], PreparedImageDto.prototype, "name", void 0); __decorate([ ApiProperty({ example: '[webp, jpg]', description: 'Расширения файла' }), Field(() => [String], { nullable: true }), IsOptional(), IsArray(), IsString({ each: true }), __metadata("design:type", Array) ], PreparedImageDto.prototype, "fileExtensions", void 0); __decorate([ ApiProperty({ example: '[original, 1280x720]', description: 'Префиксы файла' }), Field(() => [String], { nullable: true }), IsOptional(), IsArray(), IsString({ each: true }), __metadata("design:type", Array) ], PreparedImageDto.prototype, "prefixes", void 0); __decorate([ ApiProperty({ example: 'jpg', description: 'Расширение оригинального файла' }), Field(), IsString(), Length(1, 10), __metadata("design:type", String) ], PreparedImageDto.prototype, "originalFileExtension", void 0); __decorate([ ApiProperty({ example: '3422b448-2460-4fd2-9183-8000de6f8343', description: 'Уникальный идентификатор', }), Field(), IsUUID(), __metadata("design:type", String) ], PreparedImageDto.prototype, "entityId", void 0); __decorate([ ApiProperty({ example: 'qwert/qwert.jpg', description: 'Пример пути к файлу' }), Field(), IsString(), __metadata("design:type", String) ], PreparedImageDto.prototype, "fullPathExample", void 0); __decorate([ ApiProperty({ example: 'video', description: 'Внутренняя папка' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], PreparedImageDto.prototype, "folder", void 0); __decorate([ ApiPropertyOptional({ example: 'Яхта', description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], PreparedImageDto.prototype, "altRU", void 0); __decorate([ ApiProperty({ description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], PreparedImageDto.prototype, "altEN", void 0); __decorate([ ApiProperty({ description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], PreparedImageDto.prototype, "altAR", void 0); PreparedImageDto = __decorate([ ObjectType() ], PreparedImageDto); export { PreparedImageDto }; let PreparedFileDto = class PreparedFileDto { name; fullName; extension; entityId; fullPathExample; folder; }; __decorate([ ApiProperty({ example: 'qwert', description: 'Название файла' }), Field(() => String), IsString(), __metadata("design:type", String) ], PreparedFileDto.prototype, "name", void 0); __decorate([ ApiProperty({ example: 'qwert.jpg', description: 'Полное название файла' }), Field(() => String), IsString(), __metadata("design:type", String) ], PreparedFileDto.prototype, "fullName", void 0); __decorate([ ApiProperty({ example: 'jpg', description: 'Расширение исходного файла' }), Field(() => String), IsString(), __metadata("design:type", String) ], PreparedFileDto.prototype, "extension", void 0); __decorate([ ApiProperty({ description: 'Id сущности' }), Field(() => String), IsUUID(), __metadata("design:type", String) ], PreparedFileDto.prototype, "entityId", void 0); __decorate([ ApiProperty({ example: 'qwert/qwert.jpg', description: 'Пример пути к файлу' }), Field(() => String), IsString(), __metadata("design:type", String) ], PreparedFileDto.prototype, "fullPathExample", void 0); __decorate([ ApiProperty({ example: 'video', description: 'Внутренняя папка' }), Field(() => String, { nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], PreparedFileDto.prototype, "folder", void 0); PreparedFileDto = __decorate([ ObjectType() ], PreparedFileDto); export { PreparedFileDto }; let InputPreparedImageDto = class InputPreparedImageDto { name; fileExtensions; prefixes; originalFileExtension; entityId; fullPathExample; folder; altRU; altEN; altAR; }; __decorate([ ApiProperty({ example: 'qwer', description: 'Название файла' }), Field(), IsString(), __metadata("design:type", String) ], InputPreparedImageDto.prototype, "name", void 0); __decorate([ ApiProperty({ example: '[webp, jpg]', description: 'Расширения файла' }), Field(() => [String]), IsOptional(), IsArray(), IsString({ each: true }), __metadata("design:type", Array) ], InputPreparedImageDto.prototype, "fileExtensions", void 0); __decorate([ ApiProperty({ example: '[original, 1280x720]', description: 'Префиксы файла' }), Field(() => [String]), IsOptional(), IsArray(), IsString({ each: true }), __metadata("design:type", Array) ], InputPreparedImageDto.prototype, "prefixes", void 0); __decorate([ ApiProperty({ example: 'jpg', description: 'Расширение оригинального файла' }), Field(), IsString(), Length(1, 10), __metadata("design:type", String) ], InputPreparedImageDto.prototype, "originalFileExtension", void 0); __decorate([ ApiProperty({ example: '3422b448-2460-4fd2-9183-8000de6f8343', description: 'Уникальный идентификатор', }), Field(), IsUUID(), __metadata("design:type", String) ], InputPreparedImageDto.prototype, "entityId", void 0); __decorate([ ApiProperty({ example: 'qwert/qwert.jpg', description: 'Пример пути к файлу' }), Field(), IsString(), __metadata("design:type", String) ], InputPreparedImageDto.prototype, "fullPathExample", void 0); __decorate([ ApiProperty({ example: 'video', description: 'Внутренняя папка' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], InputPreparedImageDto.prototype, "folder", void 0); __decorate([ ApiProperty({ example: 'Яхта', description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], InputPreparedImageDto.prototype, "altRU", void 0); __decorate([ ApiProperty({ description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], InputPreparedImageDto.prototype, "altEN", void 0); __decorate([ ApiProperty({ description: 'Описание изображения' }), Field({ nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], InputPreparedImageDto.prototype, "altAR", void 0); InputPreparedImageDto = __decorate([ InputType() ], InputPreparedImageDto); export { InputPreparedImageDto }; let InputPreparedFileDto = class InputPreparedFileDto { name; fullName; extension; entityId; fullPathExample; folder; }; __decorate([ ApiProperty({ example: 'qwert', description: 'Название файла' }), Field(() => String), IsString(), __metadata("design:type", String) ], InputPreparedFileDto.prototype, "name", void 0); __decorate([ ApiProperty({ example: 'qwert.jpg', description: 'Полное название файла' }), Field(() => String), IsString(), __metadata("design:type", String) ], InputPreparedFileDto.prototype, "fullName", void 0); __decorate([ ApiProperty({ example: 'jpg', description: 'Расширение исходного файла' }), Field(() => String), IsString(), __metadata("design:type", String) ], InputPreparedFileDto.prototype, "extension", void 0); __decorate([ ApiProperty({ description: 'Id сущности' }), Field(() => String), IsUUID(), __metadata("design:type", String) ], InputPreparedFileDto.prototype, "entityId", void 0); __decorate([ ApiProperty({ example: 'qwert/qwert.jpg', description: 'Пример пути к файлу' }), Field(() => String), IsString(), __metadata("design:type", String) ], InputPreparedFileDto.prototype, "fullPathExample", void 0); __decorate([ ApiProperty({ example: 'video', description: 'Внутренняя папка' }), Field(() => String, { nullable: true }), IsOptional(), IsString(), __metadata("design:type", String) ], InputPreparedFileDto.prototype, "folder", void 0); InputPreparedFileDto = __decorate([ InputType() ], InputPreparedFileDto); export { InputPreparedFileDto }; let IdsDto = class IdsDto { ids; }; __decorate([ ApiValidationProperty({ type: 'string', example: '[3422b448-2460-4fd2-9183-8000de6f8343]', description: 'Массив с id', isArray: true, isUUID: true, }), __metadata("design:type", Array) ], IdsDto.prototype, "ids", void 0); IdsDto = __decorate([ InputType() ], IdsDto); export { IdsDto }; class AllImagesData { name; tempName; altRU; altEN; altAR; } __decorate([ ApiProperty({ description: 'Название фото' }), IsOptional(), IsString(), __metadata("design:type", String) ], AllImagesData.prototype, "name", void 0); __decorate([ ApiProperty({ description: 'Название нового фото' }), IsOptional(), IsString(), __metadata("design:type", String) ], AllImagesData.prototype, "tempName", void 0); __decorate([ ApiProperty({ description: 'Описание фото' }), IsOptional(), IsString(), __metadata("design:type", String) ], AllImagesData.prototype, "altRU", void 0); __decorate([ ApiProperty({ description: 'Описание фото' }), IsOptional(), IsString(), __metadata("design:type", String) ], AllImagesData.prototype, "altEN", void 0); __decorate([ ApiProperty({ description: 'Описание фото' }), IsOptional(), IsString(), __metadata("design:type", String) ], AllImagesData.prototype, "altAR", void 0); export class UpdateImagesRequest { id; allImages; images; } __decorate([ ApiProperty({ description: 'Id' }), IsUUID(), IsString(), __metadata("design:type", String) ], UpdateImagesRequest.prototype, "id", void 0); __decorate([ ApiProperty({ description: 'Информация о фотографиях' }), IsOptional(), IsArray(), ValidateNested({ each: true }), Type(() => AllImagesData), __metadata("design:type", Array) ], UpdateImagesRequest.prototype, "allImages", void 0); __decorate([ ApiProperty({ description: 'Данные картинок' }), IsOptional(), IsString(), __metadata("design:type", String) ], UpdateImagesRequest.prototype, "images", void 0); export class UpdateImagesResponse { statusCode; message; } __decorate([ ApiProperty({ example: '200', description: 'Статус код' }), __metadata("design:type", Number) ], UpdateImagesResponse.prototype, "statusCode", void 0); __decorate([ ApiProperty({ example: 'Фото обновлены', description: 'Сообщение' }), __metadata("design:type", String) ], UpdateImagesResponse.prototype, "message", void 0); class AllFilesData { name; tempName; } __decorate([ ApiProperty({ description: 'Название видео' }), IsOptional(), IsString(), __metadata("design:type", String) ], AllFilesData.prototype, "name", void 0); __decorate([ ApiProperty({ description: 'Название нового файла' }), IsOptional(), IsString(), __metadata("design:type", String) ], AllFilesData.prototype, "tempName", void 0); export class UpdateFilesRequest { id; allFiles; files; } __decorate([ ApiProperty({ description: 'Id' }), IsUUID(), IsString(), __metadata("design:type", String) ], UpdateFilesRequest.prototype, "id", void 0); __decorate([ ApiProperty({ description: 'Информация о файлах' }), IsOptional(), IsArray(), ValidateNested({ each: true }), Type(() => AllFilesData), __metadata("design:type", Array) ], UpdateFilesRequest.prototype, "allFiles", void 0); __decorate([ ApiProperty({ description: 'Данные файлов' }), IsOptional(), IsString(), __metadata("design:type", String) ], UpdateFilesRequest.prototype, "files", void 0); export class UpdateFilesResponse { statusCode; message; } __decorate([ ApiProperty({ example: '200', description: 'Статус код' }), __metadata("design:type", Number) ], UpdateFilesResponse.prototype, "statusCode", void 0); __decorate([ ApiProperty({ example: 'Файлы обновлены', description: 'Сообщение' }), __metadata("design:type", String) ], UpdateFilesResponse.prototype, "message", void 0); let SortFieldDto = class SortFieldDto { field; order; }; __decorate([ ApiValidationProperty({ type: 'string', }), __metadata("design:type", String) ], SortFieldDto.prototype, "field", void 0); __decorate([ ApiValidationProperty({ type: 'string', }), __metadata("design:type", String) ], SortFieldDto.prototype, "order", void 0); SortFieldDto = __decorate([ InputType() ], SortFieldDto); export { SortFieldDto }; //# sourceMappingURL=dto.js.map