first
This commit is contained in:
commit
0fa3c7ac48
140 files changed
+24289
No files matched your search
@@ -0,0 +1,68 @@
|
||||
import { SourceService } from './source.service';
|
||||
export declare class SourceController {
|
||||
private readonly sourceService;
|
||||
constructor(sourceService: SourceService);
|
||||
getSources(): Promise<{
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
logo: string | null;
|
||||
lastScraped: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}[]>;
|
||||
getSource(id: string): Promise<{
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
logo: string | null;
|
||||
lastScraped: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
} | null>;
|
||||
getProductsFromSource(id: string, skip?: string, take?: string): Promise<{
|
||||
products: ({
|
||||
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;
|
||||
})[];
|
||||
pagination: {
|
||||
total: number;
|
||||
skip: number;
|
||||
take: number;
|
||||
hasMore: boolean;
|
||||
};
|
||||
}>;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
"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.SourceController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const source_service_1 = require("./source.service");
|
||||
let SourceController = class SourceController {
|
||||
sourceService;
|
||||
constructor(sourceService) {
|
||||
this.sourceService = sourceService;
|
||||
}
|
||||
async getSources() {
|
||||
return this.sourceService.getSources();
|
||||
}
|
||||
async getSource(id) {
|
||||
return this.sourceService.getSource(Number(id));
|
||||
}
|
||||
async getProductsFromSource(id, skip, take) {
|
||||
return this.sourceService.getProductsFromSource(Number(id), skip ? Number(skip) : undefined, take ? Number(take) : undefined);
|
||||
}
|
||||
};
|
||||
exports.SourceController = SourceController;
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], SourceController.prototype, "getSources", null);
|
||||
__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)
|
||||
], SourceController.prototype, "getSource", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(':id/products'),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__param(1, (0, common_1.Query)('skip')),
|
||||
__param(2, (0, common_1.Query)('take')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, String, String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], SourceController.prototype, "getProductsFromSource", null);
|
||||
exports.SourceController = SourceController = __decorate([
|
||||
(0, common_1.Controller)('sources'),
|
||||
__metadata("design:paramtypes", [source_service_1.SourceService])
|
||||
], SourceController);
|
||||
//# sourceMappingURL=source.controller.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"source.controller.js","sourceRoot":"","sources":["../../src/source/source.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+D;AAC/D,qDAAiD;AAG1C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACE;IAA7B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAGvD,AAAN,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;IACzC,CAAC;IAGK,AAAN,KAAK,CAAC,SAAS,CAAc,EAAU;QACrC,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IAGK,AAAN,KAAK,CAAC,qBAAqB,CACZ,EAAU,EACR,IAAa,EACb,IAAa;QAE5B,OAAO,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAC7C,MAAM,CAAC,EAAE,CAAC,EACV,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EAC/B,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAChC,CAAC;IACJ,CAAC;CACF,CAAA;AAzBY,4CAAgB;AAIrB;IADL,IAAA,YAAG,GAAE;;;;kDAGL;AAGK;IADL,IAAA,YAAG,EAAC,KAAK,CAAC;IACM,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;iDAE3B;AAGK;IADL,IAAA,YAAG,EAAC,cAAc,CAAC;IAEjB,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,WAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;IACb,WAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;;;;6DAOf;2BAxBU,gBAAgB;IAD5B,IAAA,mBAAU,EAAC,SAAS,CAAC;qCAEwB,8BAAa;GAD9C,gBAAgB,CAyB5B"}
|
||||
@@ -0,0 +1,2 @@
|
||||
export declare class SourceModule {
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"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.SourceModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const source_controller_1 = require("./source.controller");
|
||||
const source_service_1 = require("./source.service");
|
||||
const prisma_module_1 = require("../prisma/prisma.module");
|
||||
let SourceModule = class SourceModule {
|
||||
};
|
||||
exports.SourceModule = SourceModule;
|
||||
exports.SourceModule = SourceModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [prisma_module_1.PrismaModule],
|
||||
controllers: [source_controller_1.SourceController],
|
||||
providers: [source_service_1.SourceService],
|
||||
exports: [source_service_1.SourceService],
|
||||
})
|
||||
], SourceModule);
|
||||
//# sourceMappingURL=source.module.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"source.module.js","sourceRoot":"","sources":["../../src/source/source.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2DAAuD;AACvD,qDAAiD;AACjD,2DAAuD;AAQhD,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IANxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,4BAAY,CAAC;QACvB,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,YAAY,CAAG"}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
export declare class SourceService {
|
||||
private prisma;
|
||||
constructor(prisma: PrismaService);
|
||||
getSources(): Promise<{
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
logo: string | null;
|
||||
lastScraped: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}[]>;
|
||||
getSource(id: number): Promise<{
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
logo: string | null;
|
||||
lastScraped: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
} | null>;
|
||||
getProductsFromSource(sourceId: number, skip?: number, take?: number): Promise<{
|
||||
products: ({
|
||||
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;
|
||||
})[];
|
||||
pagination: {
|
||||
total: number;
|
||||
skip: number;
|
||||
take: number;
|
||||
hasMore: boolean;
|
||||
};
|
||||
}>;
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
"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.SourceService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const prisma_service_1 = require("../prisma/prisma.service");
|
||||
let SourceService = class SourceService {
|
||||
prisma;
|
||||
constructor(prisma) {
|
||||
this.prisma = prisma;
|
||||
}
|
||||
async getSources() {
|
||||
return this.prisma.source.findMany({
|
||||
orderBy: { name: 'asc' },
|
||||
});
|
||||
}
|
||||
async getSource(id) {
|
||||
return this.prisma.source.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
}
|
||||
async getProductsFromSource(sourceId, skip, take) {
|
||||
const products = await this.prisma.product.findMany({
|
||||
where: {
|
||||
prices: {
|
||||
some: {
|
||||
sourceId,
|
||||
},
|
||||
},
|
||||
},
|
||||
include: {
|
||||
prices: {
|
||||
where: { sourceId },
|
||||
orderBy: { lastUpdated: 'desc' },
|
||||
take: 1,
|
||||
include: { source: true },
|
||||
},
|
||||
},
|
||||
skip,
|
||||
take: take || 20,
|
||||
orderBy: { name: 'asc' },
|
||||
});
|
||||
const total = await this.prisma.product.count({
|
||||
where: {
|
||||
prices: {
|
||||
some: {
|
||||
sourceId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
return {
|
||||
products,
|
||||
pagination: {
|
||||
total,
|
||||
skip: skip || 0,
|
||||
take: take || 20,
|
||||
hasMore: (skip || 0) + (take || 20) < total,
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
exports.SourceService = SourceService;
|
||||
exports.SourceService = SourceService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||
], SourceService);
|
||||
//# sourceMappingURL=source.service.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"source.service.js","sourceRoot":"","sources":["../../src/source/source.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6DAAyD;AAGlD,IAAM,aAAa,GAAnB,MAAM,aAAa;IACJ;IAApB,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAE7C,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;YACjC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;SACzB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,EAAU;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;YACnC,KAAK,EAAE,EAAE,EAAE,EAAE;SACd,CAAC,CAAC;IACL,CAAC;IAED,KAAK,C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