This commit is contained in:
echo committed 2025-05-06 10:01:03 +02:00
commit 0fa3c7ac48
140 files changed
+24289

No files matched your search

+154
View File
@@ -0,0 +1,154 @@
import { ProductService } from './product.service';
import { Prisma } from '@prisma/client';
export declare class ProductController {
private readonly productService;
constructor(productService: ProductService);
getProduct(id: string): Promise<({
prices: ({
source: {
id: number;
name: string;
url: string;
logo: string | null;
lastScraped: Date | null;
createdAt: Date;
updatedAt: Date;
};
} & {
id: number;
createdAt: Date;
sourceId: number;
regularPrice: number;
discountedPrice: number | null;
discountPercentage: number | null;
unitPrice: string | null;
promotionType: string | null;
promotionStart: Date | null;
promotionEnd: Date | null;
vatIncluded: boolean;
lastUpdated: Date;
productId: number;
})[];
} & {
id: number;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
category: string;
availability: boolean;
sourceProductId: string | null;
sourceId: number;
}) | null>;
getProducts(skip?: string, take?: string, search?: string, maxPrice?: string): Promise<({
prices: ({
source: {
id: number;
name: string;
url: string;
logo: string | null;
lastScraped: Date | null;
createdAt: Date;
updatedAt: Date;
};
} & {
id: number;
createdAt: Date;
sourceId: number;
regularPrice: number;
discountedPrice: number | null;
discountPercentage: number | null;
unitPrice: string | null;
promotionType: string | null;
promotionStart: Date | null;
promotionEnd: Date | null;
vatIncluded: boolean;
lastUpdated: Date;
productId: number;
})[];
} & {
id: number;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
category: string;
availability: boolean;
sourceProductId: string | null;
sourceId: number;
})[]>;
createProduct(data: Prisma.ProductCreateInput): Promise<{
prices: ({
source: {
id: number;
name: string;
url: string;
logo: string | null;
lastScraped: Date | null;
createdAt: Date;
updatedAt: Date;
};
} & {
id: number;
createdAt: Date;
sourceId: number;
regularPrice: number;
discountedPrice: number | null;
discountPercentage: number | null;
unitPrice: string | null;
promotionType: string | null;
promotionStart: Date | null;
promotionEnd: Date | null;
vatIncluded: boolean;
lastUpdated: Date;
productId: number;
})[];
} & {
id: number;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
category: string;
availability: boolean;
sourceProductId: string | null;
sourceId: number;
}>;
updateProduct(id: string, data: Prisma.ProductUpdateInput): Promise<{
prices: ({
source: {
id: number;
name: string;
url: string;
logo: string | null;
lastScraped: Date | null;
createdAt: Date;
updatedAt: Date;
};
} & {
id: number;
createdAt: Date;
sourceId: number;
regularPrice: number;
discountedPrice: number | null;
discountPercentage: number | null;
unitPrice: string | null;
promotionType: string | null;
promotionStart: Date | null;
promotionEnd: Date | null;
vatIncluded: boolean;
lastUpdated: Date;
productId: number;
})[];
} & {
id: number;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
category: string;
availability: boolean;
sourceProductId: string | null;
sourceId: number;
}>;
}
+94
View File
@@ -0,0 +1,94 @@
"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.ProductController = void 0;
const common_1 = require("@nestjs/common");
const product_service_1 = require("./product.service");
const client_1 = require("@prisma/client");
let ProductController = class ProductController {
productService;
constructor(productService) {
this.productService = productService;
}
async getProduct(id) {
return this.productService.getProduct(Number(id));
}
async getProducts(skip, take, search, maxPrice) {
if (search) {
return this.productService.searchProducts(search);
}
return this.productService.getProducts({
skip: skip ? Number(skip) : undefined,
take: take ? Number(take) : undefined,
where: maxPrice
? {
prices: {
some: {
regularPrice: {
lte: Number(maxPrice),
},
},
},
}
: undefined,
});
}
async createProduct(data) {
return this.productService.createProduct(data);
}
async updateProduct(id, data) {
return this.productService.updateProduct({
where: { id: Number(id) },
data,
});
}
};
exports.ProductController = ProductController;
__decorate([
(0, common_1.Get)(':id'),
__param(0, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], ProductController.prototype, "getProduct", null);
__decorate([
(0, common_1.Get)(),
__param(0, (0, common_1.Query)('skip')),
__param(1, (0, common_1.Query)('take')),
__param(2, (0, common_1.Query)('search')),
__param(3, (0, common_1.Query)('maxPrice')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String, String, String]),
__metadata("design:returntype", Promise)
], ProductController.prototype, "getProducts", null);
__decorate([
(0, common_1.Post)(),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], ProductController.prototype, "createProduct", null);
__decorate([
(0, common_1.Put)(':id'),
__param(0, (0, common_1.Param)('id')),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, Object]),
__metadata("design:returntype", Promise)
], ProductController.prototype, "updateProduct", null);
exports.ProductController = ProductController = __decorate([
(0, common_1.Controller)('products'),
__metadata("design:paramtypes", [product_service_1.ProductService])
], ProductController);
//# sourceMappingURL=product.controller.js.map
@@ -0,0 +1 @@
{"version":3,"file":"product.controller.js","sourceRoot":"","sources":["../../src/product/product.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgF;AAChF,uDAAmD;AACnD,2CAAwC;AAGjC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IACC;IAA7B,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAGzD,AAAN,KAAK,CAAC,UAAU,CAAc,EAAU;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAA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cAAK,EAAC,MAAM,CAAC,CAAA;IACb,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IACf,WAAA,IAAA,cAAK,EAAC,UAAU,CAAC,CAAA;;;;oDAqBnB;AAGK;IADL,IAAA,aAAI,GAAE;IACc,WAAA,IAAA,aAAI,GAAE,CAAA;;;;sDAE1B;AAGK;IADL,IAAA,YAAG,EAAC,KAAK,CAAC;IAER,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,WAAA,IAAA,aAAI,GAAE,CAAA;;;;sDAMR;4BAlDU,iBAAiB;IAD7B,IAAA,mBAAU,EAAC,UAAU,CAAC;qCAEwB,gCAAc;GADhD,iBAAiB,CAmD7B"}
+2
View File
@@ -0,0 +1,2 @@
export declare class ProductModule {
}
+24
View File
@@ -0,0 +1,24 @@
"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.ProductModule = void 0;
const common_1 = require("@nestjs/common");
const prisma_module_1 = require("../prisma/prisma.module");
const product_controller_1 = require("./product.controller");
const product_service_1 = require("./product.service");
let ProductModule = class ProductModule {
};
exports.ProductModule = ProductModule;
exports.ProductModule = ProductModule = __decorate([
(0, common_1.Module)({
imports: [prisma_module_1.PrismaModule],
controllers: [product_controller_1.ProductController],
providers: [product_service_1.ProductService],
})
], ProductModule);
//# sourceMappingURL=product.module.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"product.module.js","sourceRoot":"","sources":["../../src/product/product.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2DAAuD;AACvD,6DAAyD;AACzD,uDAAmD;AAO5C,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IALzB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,4BAAY,CAAC;QACvB,WAAW,EAAE,CAAC,sCAAiB,CAAC;QAChC,SAAS,EAAE,CAAC,gCAAc,CAAC;KAC5B,CAAC;GACW,aAAa,CAAG"}
+200
View File
@@ -0,0 +1,200 @@
import { PrismaService } from '../prisma/prisma.service';
import { Prisma } from '@prisma/client';
export declare class ProductService {
private prisma;
constructor(prisma: PrismaService);
getProduct(id: number): Promise<({
prices: ({
source: {
id: number;
name: string;
url: string;
logo: string | null;
lastScraped: Date | null;
createdAt: Date;
updatedAt: Date;
};
} & {
id: number;
createdAt: Date;
sourceId: number;
regularPrice: number;
discountedPrice: number | null;
discountPercentage: number | null;
unitPrice: string | null;
promotionType: string | null;
promotionStart: Date | null;
promotionEnd: Date | null;
vatIncluded: boolean;
lastUpdated: Date;
productId: number;
})[];
} & {
id: number;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
category: string;
availability: boolean;
sourceProductId: string | null;
sourceId: number;
}) | null>;
getProducts(params: {
skip?: number;
take?: number;
cursor?: Prisma.ProductWhereUniqueInput;
where?: Prisma.ProductWhereInput;
orderBy?: Prisma.ProductOrderByWithRelationInput;
}): Promise<({
prices: ({
source: {
id: number;
name: string;
url: string;
logo: string | null;
lastScraped: Date | null;
createdAt: Date;
updatedAt: Date;
};
} & {
id: number;
createdAt: Date;
sourceId: number;
regularPrice: number;
discountedPrice: number | null;
discountPercentage: number | null;
unitPrice: string | null;
promotionType: string | null;
promotionStart: Date | null;
promotionEnd: Date | null;
vatIncluded: boolean;
lastUpdated: Date;
productId: number;
})[];
} & {
id: number;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
category: string;
availability: boolean;
sourceProductId: string | null;
sourceId: number;
})[]>;
searchProducts(query: string): Promise<({
prices: ({
source: {
id: number;
name: string;
url: string;
logo: string | null;
lastScraped: Date | null;
createdAt: Date;
updatedAt: Date;
};
} & {
id: number;
createdAt: Date;
sourceId: number;
regularPrice: number;
discountedPrice: number | null;
discountPercentage: number | null;
unitPrice: string | null;
promotionType: string | null;
promotionStart: Date | null;
promotionEnd: Date | null;
vatIncluded: boolean;
lastUpdated: Date;
productId: number;
})[];
} & {
id: number;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
category: string;
availability: boolean;
sourceProductId: string | null;
sourceId: number;
})[]>;
createProduct(data: Prisma.ProductCreateInput): Promise<{
prices: ({
source: {
id: number;
name: string;
url: string;
logo: string | null;
lastScraped: Date | null;
createdAt: Date;
updatedAt: Date;
};
} & {
id: number;
createdAt: Date;
sourceId: number;
regularPrice: number;
discountedPrice: number | null;
discountPercentage: number | null;
unitPrice: string | null;
promotionType: string | null;
promotionStart: Date | null;
promotionEnd: Date | null;
vatIncluded: boolean;
lastUpdated: Date;
productId: number;
})[];
} & {
id: number;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
category: string;
availability: boolean;
sourceProductId: string | null;
sourceId: number;
}>;
updateProduct(params: {
where: Prisma.ProductWhereUniqueInput;
data: Prisma.ProductUpdateInput;
}): Promise<{
prices: ({
source: {
id: number;
name: string;
url: string;
logo: string | null;
lastScraped: Date | null;
createdAt: Date;
updatedAt: Date;
};
} & {
id: number;
createdAt: Date;
sourceId: number;
regularPrice: number;
discountedPrice: number | null;
discountPercentage: number | null;
unitPrice: string | null;
promotionType: string | null;
promotionStart: Date | null;
promotionEnd: Date | null;
vatIncluded: boolean;
lastUpdated: Date;
productId: number;
})[];
} & {
id: number;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
category: string;
availability: boolean;
sourceProductId: string | null;
sourceId: number;
}>;
}
+94
View File
@@ -0,0 +1,94 @@
"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.ProductService = void 0;
const common_1 = require("@nestjs/common");
const prisma_service_1 = require("../prisma/prisma.service");
let ProductService = class ProductService {
prisma;
constructor(prisma) {
this.prisma = prisma;
}
async getProduct(id) {
return this.prisma.product.findUnique({
where: { id },
include: {
prices: {
include: { source: true },
orderBy: { lastUpdated: 'desc' }
}
}
});
}
async getProducts(params) {
const { skip, take, cursor, where, orderBy } = params;
return this.prisma.product.findMany({
skip,
take,
cursor,
where,
orderBy,
include: {
prices: {
include: { source: true },
orderBy: { lastUpdated: 'desc' },
take: 1
}
}
});
}
async searchProducts(query) {
return this.prisma.product.findMany({
where: {
OR: [
{ name: { contains: query, mode: 'insensitive' } },
{ description: { contains: query, mode: 'insensitive' } },
{ category: { contains: query, mode: 'insensitive' } }
]
},
include: {
prices: {
include: { source: true },
orderBy: { lastUpdated: 'desc' },
take: 1
}
}
});
}
async createProduct(data) {
return this.prisma.product.create({
data,
include: {
prices: {
include: { source: true }
}
}
});
}
async updateProduct(params) {
const { where, data } = params;
return this.prisma.product.update({
data,
where,
include: {
prices: {
include: { source: true }
}
}
});
}
};
exports.ProductService = ProductService;
exports.ProductService = ProductService = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
], ProductService);
//# sourceMappingURL=product.service.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"product.service.js","sourceRoot":"","sources":["../../src/product/product.service.ts"],"names":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