04b1fc3024
Test Suite / test (24.15.0) (push) Has been cancelled
- Added a new API path for rematching recipe ingredients in `api_paths.dart`. - Implemented a manual product creation dialog in `inventory_screen.dart` to allow users to create new products directly. - Integrated the rematch functionality in `recipe_repository.dart` to handle rematching of recipe ingredients. - Updated the recipe detail screen to include a button for triggering the rematch process. - Introduced a new `RecipeMatchingService` in the backend to handle ingredient matching logic. - Added database migration to include `aiEngineEnabled` column in the User table. Co-authored-by: Copilot <copilot@github.com>
472 lines
13 KiB
TypeScript
472 lines
13 KiB
TypeScript
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: {
|
|
id: number;
|
|
productId: number;
|
|
calories: number | null;
|
|
protein: number | null;
|
|
fat: number | null;
|
|
carbohydrates: number | null;
|
|
salt: number | null;
|
|
sugar: number | null;
|
|
fiber: number | null;
|
|
} | 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;
|
|
} & {
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
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: {
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
}[];
|
|
}[]>;
|
|
previewMerge(sourceProductId: number, targetProductId: number): Promise<{
|
|
source: {
|
|
inventoryCount: number;
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
};
|
|
target: {
|
|
inventoryCount: number;
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
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: {
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
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;
|
|
} & {
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
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<{
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
}[]>;
|
|
findMine(req: {
|
|
user: {
|
|
id: number;
|
|
};
|
|
}): Promise<{
|
|
name: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
canonicalName: string | null;
|
|
}[]>;
|
|
findOne(id: number): Promise<{
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
}>;
|
|
createPrivate(body: CreateProductDto, req: {
|
|
user: {
|
|
id: number;
|
|
};
|
|
}): Promise<{
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
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<{
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
}>;
|
|
createPending(body: CreateProductDto, req: {
|
|
user: {
|
|
id: number;
|
|
};
|
|
}): Promise<{
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
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: {
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
};
|
|
}>;
|
|
updateCanonicalName(id: number, body: UpdateCanonicalNameDto): Promise<{
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
}>;
|
|
setTags(id: number, body: SetTagsDto): Promise<({
|
|
nutrition: {
|
|
id: number;
|
|
productId: number;
|
|
calories: number | null;
|
|
protein: number | null;
|
|
fat: number | null;
|
|
carbohydrates: number | null;
|
|
salt: number | null;
|
|
sugar: number | null;
|
|
fiber: number | null;
|
|
} | null;
|
|
tags: ({
|
|
tag: {
|
|
name: string;
|
|
id: number;
|
|
};
|
|
} & {
|
|
productId: number;
|
|
tagId: number;
|
|
})[];
|
|
} & {
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
}) | null>;
|
|
upsertNutrition(id: number, body: UpsertNutritionDto): Promise<{
|
|
id: number;
|
|
productId: number;
|
|
calories: number | null;
|
|
protein: number | null;
|
|
fat: number | null;
|
|
carbohydrates: number | null;
|
|
salt: number | null;
|
|
sugar: number | null;
|
|
fiber: number | null;
|
|
}>;
|
|
update(id: number, body: UpdateProductDto): Promise<{
|
|
nutrition: {
|
|
id: number;
|
|
productId: number;
|
|
calories: number | null;
|
|
protein: number | null;
|
|
fat: number | null;
|
|
carbohydrates: number | null;
|
|
salt: number | null;
|
|
sugar: number | null;
|
|
fiber: number | null;
|
|
} | null;
|
|
tags: ({
|
|
tag: {
|
|
name: string;
|
|
id: number;
|
|
};
|
|
} & {
|
|
productId: number;
|
|
tagId: number;
|
|
})[];
|
|
} & {
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
}>;
|
|
permanentDelete(id: number): Promise<{
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
}>;
|
|
remove(id: number): Promise<{
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
}>;
|
|
setStatus(id: number, body: SetProductStatusDto): import(".prisma/client").Prisma.Prisma__ProductClient<{
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
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<{
|
|
name: string;
|
|
category: string | null;
|
|
status: string;
|
|
id: number;
|
|
categoryId: number | null;
|
|
normalizedName: string;
|
|
canonicalName: string | null;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
}>;
|
|
resetAll(): Promise<{
|
|
ok: boolean;
|
|
}>;
|
|
bulkUpdate(body: BulkUpdateProductsDto): Promise<{
|
|
updated: number;
|
|
}>;
|
|
}
|