diff --git a/src/products/product-ai.service.ts b/src/products/product-ai.service.ts index 02af906..18de73b 100644 --- a/src/products/product-ai.service.ts +++ b/src/products/product-ai.service.ts @@ -5,7 +5,6 @@ import { import { ConfigService } from '@nestjs/config'; import { ContentStatus, TechnicalFieldType } from '@prisma/client'; import { AuthUser } from '../auth/auth.types'; -import { CategoryTechnicalFormService } from '../categories/category-technical-form.service'; import { PrismaService } from '../prisma/prisma.service'; import { CreateProductByAiDto, @@ -37,7 +36,6 @@ type AiProductDraft = { summary: string; descriptionHtml: string; tags: string[]; - technicalValues: Record; }; @Injectable() @@ -47,7 +45,6 @@ export class ProductAiService { private readonly prisma: PrismaService, private readonly products: ProductsService, private readonly technicalInfo: ProductTechnicalInfoService, - private readonly technicalFormService: CategoryTechnicalFormService, ) {} async createFromAi( @@ -70,16 +67,10 @@ export class ProductAiService { throw new BadRequestException('Product category not found'); } - const form = await this.technicalFormService.getFormForCategory( - businessId, - categoryId, - ); - const draft = await this.generateDraft({ categoryName: category.name, productName: dto.name.trim(), language: dto.language, - fields: form?.fields ?? [], }); const created = await this.products.create( @@ -96,26 +87,8 @@ export class ProductAiService { actor, ); - if (form && Object.keys(draft.technicalValues).length > 0) { - const values = Object.entries(draft.technicalValues) - .filter(([, value]) => { - if (Array.isArray(value)) return value.length > 0; - return value !== ''; - }) - .map(([fieldKey, value]) => ({ fieldKey, value })); - - if (values.length > 0) { - await this.technicalInfo.replaceForProduct( - businessIdRaw, - created.product.id, - { values }, - actor, - ); - } - } - return { - message: 'Product created with AI. Add images and variations next.', + message: 'Product created with AI. Add images, variations, and technical info next.', product: created.product, }; } @@ -445,23 +418,11 @@ Rules: categoryName: string; productName: string; language: ProductAiLanguage; - fields: TechnicalFormField[]; }): Promise { const provider = resolveAiProvider(this.config); const referencePages = await loadReferencePagesFromText(input.productName); const usableReferences = referencePages.filter((page) => page.text); - const technicalSchema = input.fields.map((field) => ({ - key: field.key, - label: field.label, - type: field.type, - required: field.isRequired, - options: - field.type === 'select' || field.type === 'multi_select' - ? field.options.map((option) => option.value) - : undefined, - })); - const inputLanguage = input.language === ProductAiLanguage.fa ? 'Persian (Farsi)' : 'English'; @@ -472,24 +433,18 @@ Return ONLY valid JSON with this shape: "nameFa": "Persian product name", "summary": "short listing summary", "descriptionHtml": "HTML description using

and