@alba-cars/common-modules
Version:
A package containing DTOs, validation classes and common modules and interfaces for Alba Cars
467 lines (466 loc) • 18.3 kB
JavaScript
;
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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateReviewShowPublicDTO = exports.CreateReviewDTO = exports.UpdateReviewDTO = exports.ReviewOptions = exports.ReviewFilter = exports.ReviewGetDTO = exports.GoogleReviewResponseDTO = exports.SaveGoogleReviewDTO = exports.FetchGoogleReviewsDTO = exports.GoogleReviewDTO = exports.ReviewDTO = void 0;
const class_validator_1 = require("class-validator");
const class_transformer_1 = require("class-transformer");
const enums_1 = require("../enums");
class ReviewDTO {
}
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsNotEmpty)(),
__metadata("design:type", String)
], ReviewDTO.prototype, "id", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.Length)(1, 100),
__metadata("design:type", String)
], ReviewDTO.prototype, "username", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], ReviewDTO.prototype, "photo", void 0);
__decorate([
(0, class_validator_1.IsEnum)(enums_1.ReviewPlatform),
__metadata("design:type", String)
], ReviewDTO.prototype, "platform", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.Length)(1, 1000),
__metadata("design:type", String)
], ReviewDTO.prototype, "comment", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(1),
(0, class_validator_1.Max)(5),
__metadata("design:type", Number)
], ReviewDTO.prototype, "minRating", void 0);
__decorate([
(0, class_validator_1.IsBoolean)(),
__metadata("design:type", Boolean)
], ReviewDTO.prototype, "showPublic", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewDTO.prototype, "placeId", void 0);
__decorate([
(0, class_transformer_1.Type)(() => Date),
(0, class_validator_1.IsDate)(),
__metadata("design:type", Date)
], ReviewDTO.prototype, "createdAt", void 0);
__decorate([
(0, class_transformer_1.Type)(() => Date),
(0, class_validator_1.IsDate)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Date)
], ReviewDTO.prototype, "updatedAt", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewDTO.prototype, "authorUrl", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewDTO.prototype, "profilePhotoUrl", void 0);
exports.ReviewDTO = ReviewDTO;
class GoogleReviewDTO {
}
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.Length)(1, 100),
__metadata("design:type", String)
], GoogleReviewDTO.prototype, "authorName", void 0);
__decorate([
(0, class_validator_1.IsUrl)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], GoogleReviewDTO.prototype, "authorUrl", void 0);
__decorate([
(0, class_validator_1.IsUrl)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], GoogleReviewDTO.prototype, "profilePhotoUrl", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(1),
(0, class_validator_1.Max)(5),
__metadata("design:type", Number)
], GoogleReviewDTO.prototype, "rating", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.Length)(1, 1000),
__metadata("design:type", String)
], GoogleReviewDTO.prototype, "text", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
__metadata("design:type", Number)
], GoogleReviewDTO.prototype, "time", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], GoogleReviewDTO.prototype, "relativeTimeDescription", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], GoogleReviewDTO.prototype, "placeId", void 0);
exports.GoogleReviewDTO = GoogleReviewDTO;
class FetchGoogleReviewsDTO {
constructor() {
this.fetch = false;
}
}
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.Length)(1, 100),
__metadata("design:type", String)
], FetchGoogleReviewsDTO.prototype, "placeId", void 0);
__decorate([
(0, class_validator_1.IsBoolean)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Boolean)
], FetchGoogleReviewsDTO.prototype, "fetch", void 0);
exports.FetchGoogleReviewsDTO = FetchGoogleReviewsDTO;
class SaveGoogleReviewDTO {
constructor() {
this.showPublic = true;
}
}
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.Length)(1, 100),
__metadata("design:type", String)
], SaveGoogleReviewDTO.prototype, "username", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(1),
(0, class_validator_1.Max)(5),
__metadata("design:type", Number)
], SaveGoogleReviewDTO.prototype, "rating", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.Length)(1, 1000),
__metadata("design:type", String)
], SaveGoogleReviewDTO.prototype, "comment", void 0);
__decorate([
(0, class_transformer_1.Type)(() => Date),
(0, class_validator_1.IsDate)(),
__metadata("design:type", Date)
], SaveGoogleReviewDTO.prototype, "date", void 0);
__decorate([
(0, class_validator_1.IsBoolean)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Boolean)
], SaveGoogleReviewDTO.prototype, "showPublic", void 0);
exports.SaveGoogleReviewDTO = SaveGoogleReviewDTO;
class GoogleReviewResponseDTO {
}
exports.GoogleReviewResponseDTO = GoogleReviewResponseDTO;
class ReviewGetDTO {
validate() {
const errors = (0, class_validator_1.validateSync)(this);
return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
}
static fromPlain(plain) {
return (0, class_transformer_1.plainToClass)(ReviewGetDTO, plain);
}
static toPlain(entity) {
return (0, class_transformer_1.instanceToPlain)(entity);
}
}
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewGetDTO.prototype, "id", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewGetDTO.prototype, "placeId", void 0);
__decorate([
(0, class_validator_1.IsEnum)(enums_1.ReviewPlatform),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewGetDTO.prototype, "platform", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewGetDTO.prototype, "comment", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewGetDTO.prototype, "username", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], ReviewGetDTO.prototype, "photo", void 0);
__decorate([
(0, class_validator_1.IsBoolean)(),
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Transform)(({ value }) => {
if (value === 'true')
return true;
if (value === 'false')
return false;
return value;
}),
__metadata("design:type", Boolean)
], ReviewGetDTO.prototype, "showPublic", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(1),
(0, class_validator_1.Max)(5),
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : undefined),
__metadata("design:type", Number)
], ReviewGetDTO.prototype, "minRating", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(1),
(0, class_validator_1.Max)(5),
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : undefined),
__metadata("design:type", Number)
], ReviewGetDTO.prototype, "maxRating", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(0),
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : undefined),
__metadata("design:type", Number)
], ReviewGetDTO.prototype, "skip", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(1),
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : undefined),
__metadata("design:type", Number)
], ReviewGetDTO.prototype, "take", void 0);
exports.ReviewGetDTO = ReviewGetDTO;
class ReviewFilter {
}
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewFilter.prototype, "id", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewFilter.prototype, "placeId", void 0);
__decorate([
(0, class_validator_1.IsEnum)(enums_1.ReviewPlatform),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewFilter.prototype, "platform", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewFilter.prototype, "comment", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewFilter.prototype, "username", void 0);
__decorate([
(0, class_validator_1.IsBoolean)(),
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Transform)(({ value }) => (value === 'true' ? true : value === 'false' ? false : value)),
__metadata("design:type", Boolean)
], ReviewFilter.prototype, "showPublic", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewFilter.prototype, "search", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(1),
(0, class_validator_1.Max)(5),
(0, class_transformer_1.Transform)(({ value }) => (value ? Number(value) : undefined)),
__metadata("design:type", Number)
], ReviewFilter.prototype, "minRating", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(1),
(0, class_validator_1.Max)(5),
(0, class_transformer_1.Transform)(({ value }) => (value ? Number(value) : undefined)),
__metadata("design:type", Number)
], ReviewFilter.prototype, "maxRating", void 0);
exports.ReviewFilter = ReviewFilter;
class ReviewOptions {
}
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(0),
(0, class_transformer_1.Transform)(({ value }) => (value ? Number(value) : undefined)),
__metadata("design:type", Number)
], ReviewOptions.prototype, "skip", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(1),
(0, class_transformer_1.Transform)(({ value }) => (value ? Number(value) : undefined)),
__metadata("design:type", Number)
], ReviewOptions.prototype, "take", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewOptions.prototype, "orderBy", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ReviewOptions.prototype, "orderDirection", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(1),
(0, class_transformer_1.Transform)(({ value }) => (value ? Number(value) : undefined)),
__metadata("design:type", Number)
], ReviewOptions.prototype, "page", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(1),
(0, class_transformer_1.Transform)(({ value }) => (value ? Number(value) : undefined)),
__metadata("design:type", Number)
], ReviewOptions.prototype, "limit", void 0);
exports.ReviewOptions = ReviewOptions;
class UpdateReviewDTO {
}
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsNotEmpty)(),
__metadata("design:type", String)
], UpdateReviewDTO.prototype, "id", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Length)(1, 100),
__metadata("design:type", String)
], UpdateReviewDTO.prototype, "username", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], UpdateReviewDTO.prototype, "photo", void 0);
__decorate([
(0, class_validator_1.IsEnum)(enums_1.ReviewPlatform),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], UpdateReviewDTO.prototype, "platform", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Length)(1, 1000),
__metadata("design:type", String)
], UpdateReviewDTO.prototype, "comment", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(1),
(0, class_validator_1.Max)(5),
__metadata("design:type", Number)
], UpdateReviewDTO.prototype, "rating", void 0);
__decorate([
(0, class_validator_1.IsBoolean)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Boolean)
], UpdateReviewDTO.prototype, "showPublic", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], UpdateReviewDTO.prototype, "placeId", void 0);
__decorate([
(0, class_transformer_1.Type)(() => Date),
(0, class_validator_1.IsDate)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Date)
], UpdateReviewDTO.prototype, "updatedAt", void 0);
exports.UpdateReviewDTO = UpdateReviewDTO;
class CreateReviewDTO {
}
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Length)(1, 100),
__metadata("design:type", String)
], CreateReviewDTO.prototype, "username", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateReviewDTO.prototype, "photo", void 0);
__decorate([
(0, class_validator_1.IsEnum)(enums_1.ReviewPlatform),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], CreateReviewDTO.prototype, "platform", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Length)(1, 1000),
__metadata("design:type", String)
], CreateReviewDTO.prototype, "comment", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.Min)(1),
(0, class_validator_1.Max)(5),
__metadata("design:type", Number)
], CreateReviewDTO.prototype, "rating", void 0);
__decorate([
(0, class_validator_1.IsBoolean)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Boolean)
], CreateReviewDTO.prototype, "showPublic", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], CreateReviewDTO.prototype, "placeId", void 0);
__decorate([
(0, class_transformer_1.Type)(() => Date),
(0, class_validator_1.IsDate)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Date)
], CreateReviewDTO.prototype, "date", void 0);
exports.CreateReviewDTO = CreateReviewDTO;
class UpdateReviewShowPublicDTO {
}
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsNotEmpty)(),
__metadata("design:type", String)
], UpdateReviewShowPublicDTO.prototype, "id", void 0);
__decorate([
(0, class_validator_1.IsBoolean)(),
(0, class_validator_1.IsNotEmpty)(),
__metadata("design:type", Boolean)
], UpdateReviewShowPublicDTO.prototype, "showPublic", void 0);
exports.UpdateReviewShowPublicDTO = UpdateReviewShowPublicDTO;