"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.RecipesController = void 0; const common_1 = require("@nestjs/common"); const class_validator_1 = require("class-validator"); const recipes_service_1 = require("./recipes.service"); const create_recipe_dto_1 = require("./dto/create-recipe.dto"); const create_ingredient_dto_1 = require("./dto/create-ingredient.dto"); const parse_markdown_dto_1 = require("./dto/parse-markdown.dto"); const current_user_decorator_1 = require("../auth/decorators/current-user.decorator"); const share_recipe_dto_1 = require("./dto/share-recipe.dto"); const set_recipe_visibility_dto_1 = require("./dto/set-recipe-visibility.dto"); const recipe_analysis_service_1 = require("./recipe-analysis.service"); class UpdateImageDto { } __decorate([ (0, class_validator_1.IsString)(), __metadata("design:type", String) ], UpdateImageDto.prototype, "sourceUrl", void 0); let RecipesController = class RecipesController { constructor(recipesService, recipeAnalysisService) { this.recipesService = recipesService; this.recipeAnalysisService = recipeAnalysisService; } parseMarkdown(dto) { return this.recipesService.parseMarkdown(dto); } getAiSuggestions(user) { return this.recipesService.suggestRecipesFromInventory(user.userId); } findAll(user) { return this.recipesService.findAll(user.userId); } getInventoryPreview(id, user) { return this.recipesService.getInventoryPreview(id, user.userId); } getRecipeAnalysis(id, user) { return this.recipeAnalysisService.analyzeRecipeIngredients(id, user.userId); } rematchRecipeIngredients(id, user) { return this.recipeAnalysisService.rematchRecipeIngredients(id, user.userId); } findOne(id, user) { return this.recipesService.findOne(id, user.userId); } async create(createRecipeDto, user) { return this.recipesService.create(createRecipeDto, user.userId); } async update(id, createRecipeDto, user) { return this.recipesService.update(id, createRecipeDto, user.userId); } async remove(id, user) { return this.recipesService.remove(id, user.userId); } async updateImage(id, dto, user) { return this.recipesService.updateImage(id, dto.sourceUrl, user.userId); } async addIngredient(id, ingredient, user) { return this.recipesService.addIngredient(id, ingredient, user.userId); } async setVisibility(id, dto, user) { return this.recipesService.setVisibility(id, user.userId, dto.isPublic); } async shareRecipe(id, dto, user) { return this.recipesService.shareWithUser(id, user.userId, dto.username.trim()); } async unshareRecipe(id, username, user) { return this.recipesService.unshareWithUser(id, user.userId, username.trim()); } }; exports.RecipesController = RecipesController; __decorate([ (0, common_1.Post)('parse-markdown'), __param(0, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [parse_markdown_dto_1.ParseMarkdownDto]), __metadata("design:returntype", void 0) ], RecipesController.prototype, "parseMarkdown", null); __decorate([ (0, common_1.Get)('ai-suggestions'), __param(0, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], RecipesController.prototype, "getAiSuggestions", null); __decorate([ (0, common_1.Get)(), __param(0, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], RecipesController.prototype, "findAll", null); __decorate([ (0, common_1.Get)(':id/inventory-preview'), __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)), __param(1, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, Object]), __metadata("design:returntype", void 0) ], RecipesController.prototype, "getInventoryPreview", null); __decorate([ (0, common_1.Get)(':id/analysis'), __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)), __param(1, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, Object]), __metadata("design:returntype", void 0) ], RecipesController.prototype, "getRecipeAnalysis", null); __decorate([ (0, common_1.Post)(':id/rematch'), __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)), __param(1, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, Object]), __metadata("design:returntype", void 0) ], RecipesController.prototype, "rematchRecipeIngredients", null); __decorate([ (0, common_1.Get)(':id'), __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)), __param(1, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, Object]), __metadata("design:returntype", void 0) ], RecipesController.prototype, "findOne", null); __decorate([ (0, common_1.Post)(), __param(0, (0, common_1.Body)()), __param(1, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [create_recipe_dto_1.CreateRecipeDto, Object]), __metadata("design:returntype", Promise) ], RecipesController.prototype, "create", null); __decorate([ (0, common_1.Patch)(':id'), __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)), __param(1, (0, common_1.Body)()), __param(2, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, create_recipe_dto_1.CreateRecipeDto, Object]), __metadata("design:returntype", Promise) ], RecipesController.prototype, "update", null); __decorate([ (0, common_1.Delete)(':id'), (0, common_1.HttpCode)(204), __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)), __param(1, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, Object]), __metadata("design:returntype", Promise) ], RecipesController.prototype, "remove", null); __decorate([ (0, common_1.Post)(':id/image'), __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)), __param(1, (0, common_1.Body)()), __param(2, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, UpdateImageDto, Object]), __metadata("design:returntype", Promise) ], RecipesController.prototype, "updateImage", null); __decorate([ (0, common_1.Post)(':id/ingredients'), __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)), __param(1, (0, common_1.Body)()), __param(2, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, create_ingredient_dto_1.CreateIngredientDto, Object]), __metadata("design:returntype", Promise) ], RecipesController.prototype, "addIngredient", null); __decorate([ (0, common_1.Patch)(':id/visibility'), __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)), __param(1, (0, common_1.Body)()), __param(2, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, set_recipe_visibility_dto_1.SetRecipeVisibilityDto, Object]), __metadata("design:returntype", Promise) ], RecipesController.prototype, "setVisibility", null); __decorate([ (0, common_1.Post)(':id/share'), __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)), __param(1, (0, common_1.Body)()), __param(2, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, share_recipe_dto_1.ShareRecipeDto, Object]), __metadata("design:returntype", Promise) ], RecipesController.prototype, "shareRecipe", null); __decorate([ (0, common_1.Delete)(':id/share/:username'), __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)), __param(1, (0, common_1.Param)('username')), __param(2, (0, current_user_decorator_1.CurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, String, Object]), __metadata("design:returntype", Promise) ], RecipesController.prototype, "unshareRecipe", null); exports.RecipesController = RecipesController = __decorate([ (0, common_1.Controller)('recipes'), __metadata("design:paramtypes", [recipes_service_1.RecipesService, recipe_analysis_service_1.RecipeAnalysisService]) ], RecipesController); //# sourceMappingURL=recipes.controller.js.map