88import { prisma } from '@/lib/prisma' ;
99
1010import { fetchProductPage } from './fetch' ;
11- import { extractMetadata } from './metadata ' ;
11+ import { runExtractionPipeline } from './engine ' ;
1212import { extractDomain , getRetailerName , normalizeUrl } from './normalize' ;
1313
14- export type { ExtractedMetadata } from './metadata ' ;
14+ export type { PipelineResult } from './engine ' ;
1515export type { PriceCandidate , PriceResult } from './price' ;
1616
1717// ─────────────────────────────────────────────────────────────────────────────
@@ -143,11 +143,11 @@ export async function importProductFromUrl(rawUrl: string): Promise<ImportOutcom
143143 return { success : false , error : `Could not fetch page: ${ message } ` } ;
144144 }
145145
146- // 4. Extract metadata (pass domain for retailer-specific price parsing )
147- const metadata = extractMetadata ( html , domain ) ;
146+ // 4. Extract metadata via pipeline (parallel extractors + consensus )
147+ const pipelineResult = await runExtractionPipeline ( { html, url : normalizedUrl , domain } ) ;
148148
149149 // Must have at least a title
150- if ( ! metadata . title ) {
150+ if ( ! pipelineResult . title ) {
151151 return {
152152 success : false ,
153153 error :
@@ -163,19 +163,19 @@ export async function importProductFromUrl(rawUrl: string): Promise<ImportOutcom
163163 canonicalUrl,
164164 normalizedUrl : canonicalUrl . toLowerCase ( ) ,
165165 domain,
166- retailer : metadata . retailer ?? retailerFromDomain ?? domain ,
167- title : metadata . title ,
168- description : metadata . description ,
169- brand : metadata . brand ,
170- sku : metadata . sku ,
171- mpn : metadata . mpn ,
172- gtin : metadata . gtin ,
173- image : metadata . image ,
174- gallery : metadata . gallery ,
175- currentPrice : metadata . price ,
176- currency : metadata . currency ?? 'USD' ,
177- inStock : metadata . inStock ,
178- availability : metadata . availability ,
166+ retailer : pipelineResult . retailer ?? retailerFromDomain ?? domain ,
167+ title : pipelineResult . title ,
168+ description : pipelineResult . description ,
169+ brand : pipelineResult . brand ,
170+ sku : pipelineResult . sku ,
171+ mpn : pipelineResult . mpn ,
172+ gtin : pipelineResult . gtin ,
173+ image : pipelineResult . image ,
174+ gallery : pipelineResult . gallery ,
175+ currentPrice : pipelineResult . price ,
176+ currency : pipelineResult . currency ?? 'USD' ,
177+ inStock : pipelineResult . inStock ,
178+ availability : pipelineResult . availability ,
179179 } ;
180180
181181 return { success : true , data } ;
0 commit comments