Refactor code structure for improved readability and maintainability
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
+471
@@ -0,0 +1,471 @@
|
||||
import { CreateProductDto } from './dto/create-product.dto';
|
||||
import { UpdateProductDto } from './dto/update-product.dto';
|
||||
import { ProductsService } from './products.service';
|
||||
import { MergeProductsDto } from './dto/merge-products.dto';
|
||||
import { UpdateCanonicalNameDto } from './dto/update-canonical-name.dto';
|
||||
import { SetTagsDto } from './dto/set-tags.dto';
|
||||
import { UpsertNutritionDto } from './dto/upsert-nutrition.dto';
|
||||
import { BulkUpdateProductsDto } from './dto/bulk-update-products.dto';
|
||||
import { AiCategorizeBulkDto } from './dto/ai-categorize-bulk.dto';
|
||||
import { SetProductStatusDto } from './dto/set-product-status.dto';
|
||||
import { AiService } from '../ai/ai.service';
|
||||
import { CategoriesService } from '../categories/categories.service';
|
||||
export declare class ProductsController {
|
||||
private readonly productsService;
|
||||
private readonly aiService;
|
||||
private readonly categoriesService;
|
||||
constructor(productsService: ProductsService, aiService: AiService, categoriesService: CategoriesService);
|
||||
findAll(tag?: string): Promise<({
|
||||
nutrition: {
|
||||
calories: number | null;
|
||||
protein: number | null;
|
||||
fat: number | null;
|
||||
carbohydrates: number | null;
|
||||
salt: number | null;
|
||||
sugar: number | null;
|
||||
fiber: number | null;
|
||||
id: number;
|
||||
productId: number;
|
||||
} | null;
|
||||
tags: ({
|
||||
tag: {
|
||||
name: string;
|
||||
id: number;
|
||||
};
|
||||
} & {
|
||||
productId: number;
|
||||
tagId: number;
|
||||
})[];
|
||||
categoryRef: ({
|
||||
parent: ({
|
||||
parent: {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
} | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
})[]>;
|
||||
findAllTags(): Promise<{
|
||||
name: string;
|
||||
id: number;
|
||||
}[]>;
|
||||
findDuplicates(): Promise<{
|
||||
normalizedName: string;
|
||||
count: number;
|
||||
products: {
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}[];
|
||||
}[]>;
|
||||
previewMerge(sourceProductId: number, targetProductId: number): Promise<{
|
||||
source: {
|
||||
inventoryCount: number;
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
};
|
||||
target: {
|
||||
inventoryCount: number;
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
};
|
||||
outcome: {
|
||||
inventoryItemsToMove: number;
|
||||
sourceWillBeSoftDeleted: boolean;
|
||||
targetWillRemainActive: boolean;
|
||||
};
|
||||
}>;
|
||||
backfillCanonical(): Promise<{
|
||||
message: string;
|
||||
updatedCount: number;
|
||||
products: {
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}[];
|
||||
}>;
|
||||
findPending(): Promise<({
|
||||
owner: {
|
||||
id: number;
|
||||
username: string;
|
||||
};
|
||||
categoryRef: ({
|
||||
parent: {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
} | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
})[]>;
|
||||
aiCategorizeBulk(body: AiCategorizeBulkDto): Promise<{
|
||||
productId: number;
|
||||
productName: string;
|
||||
suggestion: object;
|
||||
}[]>;
|
||||
findDeleted(): Promise<{
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}[]>;
|
||||
findMine(req: {
|
||||
user: {
|
||||
id: number;
|
||||
};
|
||||
}): Promise<{
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
}[]>;
|
||||
findOne(id: number): Promise<{
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}>;
|
||||
createPrivate(body: CreateProductDto, req: {
|
||||
user: {
|
||||
id: number;
|
||||
};
|
||||
}): Promise<{
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}>;
|
||||
suggestCategory(id: number): Promise<import("../ai/ai.service").CategorySuggestion>;
|
||||
create(body: CreateProductDto, req: {
|
||||
user: {
|
||||
id: number;
|
||||
};
|
||||
}): Promise<{
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}>;
|
||||
createPending(body: CreateProductDto, req: {
|
||||
user: {
|
||||
id: number;
|
||||
};
|
||||
}): Promise<{
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}>;
|
||||
merge(body: MergeProductsDto): Promise<{
|
||||
message: string;
|
||||
sourceProductId: number;
|
||||
targetProductId: number;
|
||||
movedInventoryCount: number;
|
||||
softDeletedSource: {
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
};
|
||||
}>;
|
||||
updateCanonicalName(id: number, body: UpdateCanonicalNameDto): Promise<{
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}>;
|
||||
setTags(id: number, body: SetTagsDto): Promise<({
|
||||
nutrition: {
|
||||
calories: number | null;
|
||||
protein: number | null;
|
||||
fat: number | null;
|
||||
carbohydrates: number | null;
|
||||
salt: number | null;
|
||||
sugar: number | null;
|
||||
fiber: number | null;
|
||||
id: number;
|
||||
productId: number;
|
||||
} | null;
|
||||
tags: ({
|
||||
tag: {
|
||||
name: string;
|
||||
id: number;
|
||||
};
|
||||
} & {
|
||||
productId: number;
|
||||
tagId: number;
|
||||
})[];
|
||||
} & {
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}) | null>;
|
||||
upsertNutrition(id: number, body: UpsertNutritionDto): Promise<{
|
||||
calories: number | null;
|
||||
protein: number | null;
|
||||
fat: number | null;
|
||||
carbohydrates: number | null;
|
||||
salt: number | null;
|
||||
sugar: number | null;
|
||||
fiber: number | null;
|
||||
id: number;
|
||||
productId: number;
|
||||
}>;
|
||||
update(id: number, body: UpdateProductDto): Promise<{
|
||||
nutrition: {
|
||||
calories: number | null;
|
||||
protein: number | null;
|
||||
fat: number | null;
|
||||
carbohydrates: number | null;
|
||||
salt: number | null;
|
||||
sugar: number | null;
|
||||
fiber: number | null;
|
||||
id: number;
|
||||
productId: number;
|
||||
} | null;
|
||||
tags: ({
|
||||
tag: {
|
||||
name: string;
|
||||
id: number;
|
||||
};
|
||||
} & {
|
||||
productId: number;
|
||||
tagId: number;
|
||||
})[];
|
||||
} & {
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}>;
|
||||
permanentDelete(id: number): Promise<{
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}>;
|
||||
remove(id: number): Promise<{
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}>;
|
||||
setStatus(id: number, body: SetProductStatusDto): import(".prisma/client").Prisma.Prisma__ProductClient<{
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}, never, import("@prisma/client/runtime/library").DefaultArgs, import(".prisma/client").Prisma.PrismaClientOptions>;
|
||||
restore(id: number): Promise<{
|
||||
category: string | null;
|
||||
status: string;
|
||||
name: string;
|
||||
categoryId: number | null;
|
||||
canonicalName: string | null;
|
||||
id: number;
|
||||
normalizedName: string;
|
||||
isActive: boolean;
|
||||
deletedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
ownerId: number;
|
||||
isPrivate: boolean;
|
||||
}>;
|
||||
resetAll(): Promise<{
|
||||
ok: boolean;
|
||||
}>;
|
||||
bulkUpdate(body: BulkUpdateProductsDto): Promise<{
|
||||
updated: number;
|
||||
}>;
|
||||
}
|
||||
Reference in New Issue
Block a user