Deploy via committed dist: local Nest build, server runs with .env

Build on the developer machine without Docker, commit dist/, and run on the server with Dockerfile.dist plus compose env_file.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-05 21:35:22 +03:30
co-authored by Cursor
parent 67cfc17079
commit cbcea58e94
199 changed files with 10895 additions and 4 deletions
+36
View File
@@ -0,0 +1,36 @@
export declare class CreateProductDto {
companyId: string;
catalogId: string;
name: string;
code: string;
productCode?: string;
color: string;
description?: string;
minMeterage?: number;
orderMultiplier?: number;
orderStep?: number;
basePrice?: number | null;
price?: number | null;
stock?: number | null;
internalStock?: number | null;
isActive?: boolean;
}
export declare class UpdateProductDto {
catalogId?: string;
name?: string;
code?: string;
productCode?: string;
color?: string;
description?: string | null;
minMeterage?: number;
orderMultiplier?: number;
orderStep?: number;
basePrice?: number | null;
price?: number | null;
stock?: number | null;
internalStock?: number | null;
isActive?: boolean;
}
export declare class SetProductActiveDto {
isActive: boolean;
}
+231
View File
@@ -0,0 +1,231 @@
"use strict";
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.SetProductActiveDto = exports.UpdateProductDto = exports.CreateProductDto = void 0;
const class_validator_1 = require("class-validator");
const class_transformer_1 = require("class-transformer");
class CreateProductDto {
companyId;
catalogId;
name;
code;
productCode;
color;
description;
minMeterage;
orderMultiplier;
orderStep;
basePrice;
price;
stock;
internalStock;
isActive;
}
exports.CreateProductDto = CreateProductDto;
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateProductDto.prototype, "companyId", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateProductDto.prototype, "catalogId", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.MinLength)(1),
__metadata("design:type", String)
], CreateProductDto.prototype, "name", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.MinLength)(1),
__metadata("design:type", String)
], CreateProductDto.prototype, "code", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateProductDto.prototype, "productCode", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.MinLength)(1),
__metadata("design:type", String)
], CreateProductDto.prototype, "color", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateProductDto.prototype, "description", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
__metadata("design:type", Number)
], CreateProductDto.prototype, "minMeterage", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0.001),
__metadata("design:type", Number)
], CreateProductDto.prototype, "orderMultiplier", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0.001),
__metadata("design:type", Number)
], CreateProductDto.prototype, "orderStep", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
__metadata("design:type", Object)
], CreateProductDto.prototype, "basePrice", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
__metadata("design:type", Object)
], CreateProductDto.prototype, "price", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
__metadata("design:type", Object)
], CreateProductDto.prototype, "stock", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
__metadata("design:type", Object)
], CreateProductDto.prototype, "internalStock", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsBoolean)(),
__metadata("design:type", Boolean)
], CreateProductDto.prototype, "isActive", void 0);
class UpdateProductDto {
catalogId;
name;
code;
productCode;
color;
description;
minMeterage;
orderMultiplier;
orderStep;
basePrice;
price;
stock;
internalStock;
isActive;
}
exports.UpdateProductDto = UpdateProductDto;
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], UpdateProductDto.prototype, "catalogId", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
(0, class_validator_1.MinLength)(1),
__metadata("design:type", String)
], UpdateProductDto.prototype, "name", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
(0, class_validator_1.MinLength)(1),
__metadata("design:type", String)
], UpdateProductDto.prototype, "code", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], UpdateProductDto.prototype, "productCode", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], UpdateProductDto.prototype, "color", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", Object)
], UpdateProductDto.prototype, "description", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
__metadata("design:type", Number)
], UpdateProductDto.prototype, "minMeterage", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0.001),
__metadata("design:type", Number)
], UpdateProductDto.prototype, "orderMultiplier", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0.001),
__metadata("design:type", Number)
], UpdateProductDto.prototype, "orderStep", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
__metadata("design:type", Object)
], UpdateProductDto.prototype, "basePrice", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
__metadata("design:type", Object)
], UpdateProductDto.prototype, "price", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
__metadata("design:type", Object)
], UpdateProductDto.prototype, "stock", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
__metadata("design:type", Object)
], UpdateProductDto.prototype, "internalStock", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsBoolean)(),
__metadata("design:type", Boolean)
], UpdateProductDto.prototype, "isActive", void 0);
class SetProductActiveDto {
isActive;
}
exports.SetProductActiveDto = SetProductActiveDto;
__decorate([
(0, class_validator_1.IsBoolean)(),
__metadata("design:type", Boolean)
], SetProductActiveDto.prototype, "isActive", void 0);
//# sourceMappingURL=product.dto.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"product.dto.js","sourceRoot":"","sources":["../../../src/products/dto/product.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAOyB;AACzB,yDAAyC;AAEzC,MAAa,gBAAgB;IAE3B,SAAS,CAAU;IAGnB,SAAS,CAAU;IAInB,IAAI,CAAU;IAId,IAAI,CAAU;IAKd,WAAW,CAAU;IAIrB,KAAK,CAAU;IAIf,WAAW,CAAU;IAMrB,WAAW,CAAU;IAMrB,eAAe,CAAU;IAOzB,SAAS,CAAU;IAMnB,SAAS,CAAiB;IAO1B,KAAK,CAAiB;IAMtB,KAAK,CAAiB;IAOtB,aAAa,CAAiB;IAI9B,QAAQ,CAAW;CACpB;AA5ED,4CA4EC;AA1EC;IADC,IAAA,0BAAQ,GAAE;;mDACQ;AAGnB;IADC,IAAA,0BAAQ,GAAE;;mDACQ;AAInB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,CAAC,CAAC;;8CACC;AAId;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,CAAC,CAAC;;8CACC;AAKd;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACU;AAIrB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,CAAC,CAAC;;+CACE;AAIf;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACU;AAMrB;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,CAAC;;qDACc;AAMrB;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EA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AAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,CAAC;;+CACe;AAMtB;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,CAAC;;uDACuB;AAI9B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;kDACO;AAGrB,MAAa,mBAAmB;IAE9B,QAAQ,CAAW;CACpB;AAHD,kDAGC;AADC;IADC,IAAA,2BAAS,GAAE;;qDACO"}
+121
View File
@@ -0,0 +1,121 @@
import { ProductsService } from './products.service';
import { CreateProductDto, SetProductActiveDto, UpdateProductDto } from './dto/product.dto';
export declare class ProductsController {
private readonly productsService;
constructor(productsService: ProductsService);
findAll(catalogId?: string, companyId?: string, color?: string, activeOnly?: string): Promise<{
id: string;
companyId: string;
companyName: string;
catalogId: string;
catalogCode: string;
catalogName: string;
name: string;
code: string;
productCode: string;
color: string;
description: string | undefined;
minMeterage: number;
orderMultiplier: number;
orderStep: number;
basePrice: number | null;
price: number | null;
stock: number | null;
internalStock: number;
isActive: boolean;
createdAt: string;
updatedAt: string;
}[]>;
findOne(id: string): Promise<{
id: string;
companyId: string;
companyName: string;
catalogId: string;
catalogCode: string;
catalogName: string;
name: string;
code: string;
productCode: string;
color: string;
description: string | undefined;
minMeterage: number;
orderMultiplier: number;
orderStep: number;
basePrice: number | null;
price: number | null;
stock: number | null;
internalStock: number;
isActive: boolean;
createdAt: string;
updatedAt: string;
}>;
create(dto: CreateProductDto): Promise<{
id: string;
companyId: string;
companyName: string;
catalogId: string;
catalogCode: string;
catalogName: string;
name: string;
code: string;
productCode: string;
color: string;
description: string | undefined;
minMeterage: number;
orderMultiplier: number;
orderStep: number;
basePrice: number | null;
price: number | null;
stock: number | null;
internalStock: number;
isActive: boolean;
createdAt: string;
updatedAt: string;
}>;
update(id: string, dto: UpdateProductDto): Promise<{
id: string;
companyId: string;
companyName: string;
catalogId: string;
catalogCode: string;
catalogName: string;
name: string;
code: string;
productCode: string;
color: string;
description: string | undefined;
minMeterage: number;
orderMultiplier: number;
orderStep: number;
basePrice: number | null;
price: number | null;
stock: number | null;
internalStock: number;
isActive: boolean;
createdAt: string;
updatedAt: string;
}>;
setActive(id: string, dto: SetProductActiveDto): Promise<{
id: string;
companyId: string;
companyName: string;
catalogId: string;
catalogCode: string;
catalogName: string;
name: string;
code: string;
productCode: string;
color: string;
description: string | undefined;
minMeterage: number;
orderMultiplier: number;
orderStep: number;
basePrice: number | null;
price: number | null;
stock: number | null;
internalStock: number;
isActive: boolean;
createdAt: string;
updatedAt: string;
}>;
}
+96
View File
@@ -0,0 +1,96 @@
"use strict";
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);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductsController = void 0;
const common_1 = require("@nestjs/common");
const products_service_1 = require("./products.service");
const auth_decorators_1 = require("../common/decorators/auth.decorators");
const product_dto_1 = require("./dto/product.dto");
let ProductsController = class ProductsController {
productsService;
constructor(productsService) {
this.productsService = productsService;
}
findAll(catalogId, companyId, color, activeOnly) {
return this.productsService.findAll({
catalogId,
companyId,
color,
activeOnly: activeOnly === 'true' || activeOnly === '1',
});
}
findOne(id) {
return this.productsService.findOne(id);
}
create(dto) {
return this.productsService.create(dto);
}
update(id, dto) {
return this.productsService.update(id, dto);
}
setActive(id, dto) {
return this.productsService.setActive(id, dto.isActive);
}
};
exports.ProductsController = ProductsController;
__decorate([
(0, auth_decorators_1.AuthType)('any'),
(0, common_1.Get)(),
__param(0, (0, common_1.Query)('catalogId')),
__param(1, (0, common_1.Query)('companyId')),
__param(2, (0, common_1.Query)('color')),
__param(3, (0, common_1.Query)('activeOnly')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String, String, String]),
__metadata("design:returntype", void 0)
], ProductsController.prototype, "findAll", null);
__decorate([
(0, auth_decorators_1.AuthType)('any'),
(0, common_1.Get)(':id'),
__param(0, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], ProductsController.prototype, "findOne", null);
__decorate([
(0, auth_decorators_1.AuthType)('admin'),
(0, common_1.Post)(),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [product_dto_1.CreateProductDto]),
__metadata("design:returntype", void 0)
], ProductsController.prototype, "create", null);
__decorate([
(0, auth_decorators_1.AuthType)('admin'),
(0, common_1.Patch)(':id'),
__param(0, (0, common_1.Param)('id')),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, product_dto_1.UpdateProductDto]),
__metadata("design:returntype", void 0)
], ProductsController.prototype, "update", null);
__decorate([
(0, auth_decorators_1.AuthType)('admin'),
(0, common_1.Patch)(':id/active'),
__param(0, (0, common_1.Param)('id')),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, product_dto_1.SetProductActiveDto]),
__metadata("design:returntype", void 0)
], ProductsController.prototype, "setActive", null);
exports.ProductsController = ProductsController = __decorate([
(0, common_1.Controller)('products'),
__metadata("design:paramtypes", [products_service_1.ProductsService])
], ProductsController);
//# sourceMappingURL=products.controller.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"products.controller.js","sourceRoot":"","sources":["../../src/products/products.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,yDAAqD;AACrD,0EAAgE;AAChE,mDAI2B;AAGpB,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACA;IAA7B,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IAAG,CAAC;IAIjE,OAAO,CACe,SAAkB,EAClB,SAAkB,EACtB,KAAc,EACT,UAAmB;QAExC,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;YAClC,SAAS;YACT,SAAS;YACT,KAAK;YACL,UAAU,EAAE,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,GAAG;SACxD,CAAC,CAAC;IACL,CAAC;IAID,OAAO,CAAc,EAAU;QAC7B,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IAID,MAAM,CAAS,GAAqB;QAClC,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;IAID,MAAM,CAAc,EAAU,EAAU,GAAqB;QAC3D,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC;IAID,SAAS,CAAc,EAAU,EAAU,GAAwB;QACjE,OAAO,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AA1CY,gDAAkB;AAK7B;IAFC,IAAA,0BAAQ,EAAC,KAAK,CAAC;IACf,IAAA,YAAG,GAAE;IAEH,WAAA,IAAA,cAAK,EAAC,WAAW,CAAC,CAAA;IAClB,WAAA,IAAA,cAAK,EAAC,WAAW,CAAC,CAAA;IAClB,WAAA,IAAA,cAAK,EAAC,OAAO,CAAC,CAAA;IACd,WAAA,IAAA,cAAK,EAAC,YAAY,CAAC,CAAA;;;;iDAQrB;AAID;IAFC,IAAA,0BAAQ,EAAC,KAAK,CAAC;IACf,IAAA,YAAG,EAAC,KAAK,CAAC;IACF,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;iDAEnB;AAID;IAFC,IAAA,0BAAQ,EAAC,OAAO,CAAC;IACjB,IAAA,aAAI,GAAE;IACC,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,8BAAgB;;gDAEnC;AAID;IAFC,IAAA,0BAAQ,EAAC,OAAO,CAAC;IACjB,IAAA,cAAK,EAAC,KAAK,CAAC;IACL,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,8BAAgB;;gDAE5D;AAID;IAFC,IAAA,0BAAQ,EAAC,OAAO,CAAC;IACjB,IAAA,cAAK,EAAC,YAAY,CAAC;IACT,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,iCAAmB;;mDAElE;6BAzCU,kBAAkB;IAD9B,IAAA,mBAAU,EAAC,UAAU,CAAC;qCAEyB,kCAAe;GADlD,kBAAkB,CA0C9B"}
+2
View File
@@ -0,0 +1,2 @@
export declare class ProductsModule {
}
+23
View File
@@ -0,0 +1,23 @@
"use strict";
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductsModule = void 0;
const common_1 = require("@nestjs/common");
const products_controller_1 = require("./products.controller");
const products_service_1 = require("./products.service");
let ProductsModule = class ProductsModule {
};
exports.ProductsModule = ProductsModule;
exports.ProductsModule = ProductsModule = __decorate([
(0, common_1.Module)({
controllers: [products_controller_1.ProductsController],
providers: [products_service_1.ProductsService],
exports: [products_service_1.ProductsService],
})
], ProductsModule);
//# sourceMappingURL=products.module.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"products.module.js","sourceRoot":"","sources":["../../src/products/products.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,+DAA2D;AAC3D,yDAAqD;AAO9C,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAAjB,wCAAc;yBAAd,cAAc;IAL1B,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,wCAAkB,CAAC;QACjC,SAAS,EAAE,CAAC,kCAAe,CAAC;QAC5B,OAAO,EAAE,CAAC,kCAAe,CAAC;KAC3B,CAAC;GACW,cAAc,CAAG"}
+129
View File
@@ -0,0 +1,129 @@
import { PrismaService } from '../prisma/prisma.service';
import { CreateProductDto, UpdateProductDto } from './dto/product.dto';
export declare class ProductsService {
private readonly prisma;
constructor(prisma: PrismaService);
findAll(filters: {
catalogId?: string;
companyId?: string;
color?: string;
activeOnly?: boolean;
}): Promise<{
id: string;
companyId: string;
companyName: string;
catalogId: string;
catalogCode: string;
catalogName: string;
name: string;
code: string;
productCode: string;
color: string;
description: string | undefined;
minMeterage: number;
orderMultiplier: number;
orderStep: number;
basePrice: number | null;
price: number | null;
stock: number | null;
internalStock: number;
isActive: boolean;
createdAt: string;
updatedAt: string;
}[]>;
findOne(id: string): Promise<{
id: string;
companyId: string;
companyName: string;
catalogId: string;
catalogCode: string;
catalogName: string;
name: string;
code: string;
productCode: string;
color: string;
description: string | undefined;
minMeterage: number;
orderMultiplier: number;
orderStep: number;
basePrice: number | null;
price: number | null;
stock: number | null;
internalStock: number;
isActive: boolean;
createdAt: string;
updatedAt: string;
}>;
create(dto: CreateProductDto): Promise<{
id: string;
companyId: string;
companyName: string;
catalogId: string;
catalogCode: string;
catalogName: string;
name: string;
code: string;
productCode: string;
color: string;
description: string | undefined;
minMeterage: number;
orderMultiplier: number;
orderStep: number;
basePrice: number | null;
price: number | null;
stock: number | null;
internalStock: number;
isActive: boolean;
createdAt: string;
updatedAt: string;
}>;
update(id: string, dto: UpdateProductDto): Promise<{
id: string;
companyId: string;
companyName: string;
catalogId: string;
catalogCode: string;
catalogName: string;
name: string;
code: string;
productCode: string;
color: string;
description: string | undefined;
minMeterage: number;
orderMultiplier: number;
orderStep: number;
basePrice: number | null;
price: number | null;
stock: number | null;
internalStock: number;
isActive: boolean;
createdAt: string;
updatedAt: string;
}>;
setActive(id: string, isActive: boolean): Promise<{
id: string;
companyId: string;
companyName: string;
catalogId: string;
catalogCode: string;
catalogName: string;
name: string;
code: string;
productCode: string;
color: string;
description: string | undefined;
minMeterage: number;
orderMultiplier: number;
orderStep: number;
basePrice: number | null;
price: number | null;
stock: number | null;
internalStock: number;
isActive: boolean;
createdAt: string;
updatedAt: string;
}>;
private pickNumber;
private ensure;
private map;
}
+196
View File
@@ -0,0 +1,196 @@
"use strict";
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.ProductsService = void 0;
const common_1 = require("@nestjs/common");
const client_1 = require("@prisma/client");
const prisma_service_1 = require("../prisma/prisma.service");
let ProductsService = class ProductsService {
prisma;
constructor(prisma) {
this.prisma = prisma;
}
async findAll(filters) {
const products = await this.prisma.product.findMany({
where: {
...(filters.catalogId ? { catalogId: filters.catalogId } : {}),
...(filters.companyId ? { companyId: filters.companyId } : {}),
...(filters.color
? { color: { contains: filters.color, mode: 'insensitive' } }
: {}),
...(filters.activeOnly ? { isActive: true } : {}),
},
orderBy: [{ name: 'asc' }, { color: 'asc' }],
include: {
company: { select: { name: true } },
catalog: { select: { code: true, name: true } },
},
});
return products.map((p) => this.map(p));
}
async findOne(id) {
const product = await this.prisma.product.findUnique({
where: { id },
include: {
company: { select: { name: true } },
catalog: { select: { code: true, name: true } },
},
});
if (!product)
throw new common_1.NotFoundException('محصول یافت نشد');
return this.map(product);
}
async create(dto) {
const catalog = await this.prisma.catalog.findUnique({
where: { id: dto.catalogId },
});
if (!catalog)
throw new common_1.NotFoundException('کاتالوگ یافت نشد');
if (catalog.companyId !== dto.companyId) {
throw new common_1.ConflictException('کاتالوگ متعلق به این شرکت نیست');
}
const code = (dto.code || dto.productCode || '').trim();
if (!code)
throw new common_1.ConflictException('کد محصول الزامی است');
try {
const product = await this.prisma.product.create({
data: {
companyId: dto.companyId,
catalogId: dto.catalogId,
name: dto.name.trim(),
code,
color: dto.color.trim(),
description: dto.description?.trim() || null,
minMeterage: dto.minMeterage ?? 30,
orderMultiplier: dto.orderMultiplier ?? dto.orderStep ?? 10,
basePrice: this.pickNumber(dto.basePrice, dto.price),
stock: this.pickNumber(dto.stock, dto.internalStock),
isActive: dto.isActive ?? true,
},
include: {
company: { select: { name: true } },
catalog: { select: { code: true, name: true } },
},
});
return this.map(product);
}
catch (e) {
if (e instanceof client_1.Prisma.PrismaClientKnownRequestError && e.code === 'P2002') {
throw new common_1.ConflictException('کد محصول در این شرکت تکراری است');
}
throw e;
}
}
async update(id, dto) {
await this.ensure(id);
const code = dto.code !== undefined
? dto.code.trim()
: dto.productCode !== undefined
? dto.productCode.trim()
: undefined;
try {
const product = await this.prisma.product.update({
where: { id },
data: {
catalogId: dto.catalogId,
name: dto.name?.trim(),
code,
color: dto.color?.trim(),
description: dto.description === undefined
? undefined
: dto.description?.trim() || null,
minMeterage: dto.minMeterage,
orderMultiplier: dto.orderMultiplier !== undefined
? dto.orderMultiplier
: dto.orderStep,
basePrice: dto.basePrice !== undefined
? dto.basePrice
: dto.price !== undefined
? dto.price
: undefined,
stock: dto.stock !== undefined
? dto.stock
: dto.internalStock !== undefined
? dto.internalStock
: undefined,
isActive: dto.isActive,
},
include: {
company: { select: { name: true } },
catalog: { select: { code: true, name: true } },
},
});
return this.map(product);
}
catch (e) {
if (e instanceof client_1.Prisma.PrismaClientKnownRequestError && e.code === 'P2002') {
throw new common_1.ConflictException('کد محصول در این شرکت تکراری است');
}
throw e;
}
}
async setActive(id, isActive) {
await this.ensure(id);
const product = await this.prisma.product.update({
where: { id },
data: { isActive },
include: {
company: { select: { name: true } },
catalog: { select: { code: true, name: true } },
},
});
return this.map(product);
}
pickNumber(primary, alias) {
if (primary !== undefined)
return primary;
if (alias !== undefined)
return alias;
return null;
}
async ensure(id) {
const product = await this.prisma.product.findUnique({ where: { id } });
if (!product)
throw new common_1.NotFoundException('محصول یافت نشد');
return product;
}
map(product) {
return {
id: product.id,
companyId: product.companyId,
companyName: product.company.name,
catalogId: product.catalogId,
catalogCode: product.catalog.code,
catalogName: product.catalog.name,
name: product.name,
code: product.code,
productCode: product.code,
color: product.color,
description: product.description ?? undefined,
minMeterage: product.minMeterage,
orderMultiplier: product.orderMultiplier,
orderStep: product.orderMultiplier,
basePrice: product.basePrice,
price: product.basePrice,
stock: product.stock,
internalStock: product.stock ?? 0,
isActive: product.isActive,
createdAt: product.createdAt.toISOString(),
updatedAt: product.updatedAt.toISOString(),
};
}
};
exports.ProductsService = ProductsService;
exports.ProductsService = ProductsService = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
], ProductsService);
//# sourceMappingURL=products.service.js.map
File diff suppressed because one or more lines are too long