@factorypure/client-helpers 1.1.15 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -20
- package/dist/index.js +50 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -508,28 +508,12 @@ export declare const immersiveScrapeResultsSchema: z.ZodObject<{
|
|
|
508
508
|
}, z.core.$strip>>;
|
|
509
509
|
ai_extracted_sku: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
510
510
|
ai_extracted_brand: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
ai_extraction_quality: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
516
|
-
high: "high";
|
|
517
|
-
medium: "medium";
|
|
518
|
-
low: "low";
|
|
519
|
-
}>>>;
|
|
520
|
-
ai_extraction_method: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
521
|
-
openai: "openai";
|
|
522
|
-
regex_fallback: "regex_fallback";
|
|
523
|
-
cached: "cached";
|
|
524
|
-
none: "none";
|
|
525
|
-
}>>>;
|
|
511
|
+
ai_extracted_description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
512
|
+
ai_extracted_features: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
513
|
+
ai_extracted_specifications: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
514
|
+
ai_extracted_shipping: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
526
515
|
ai_processed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
527
516
|
listing_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
528
|
-
ai_unique_skus_found: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>>;
|
|
529
|
-
ai_most_common_sku: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
530
|
-
ai_sku_confidence_avg: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
531
|
-
ai_high_quality_listing_count: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
532
|
-
ai_total_listing_count: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
533
517
|
inline_link: z.ZodOptional<z.ZodNull>;
|
|
534
518
|
delivery: z.ZodOptional<z.ZodNull>;
|
|
535
519
|
}, z.core.$strip>;
|
|
@@ -679,6 +663,7 @@ export declare const HIDE_REASONS: {
|
|
|
679
663
|
DUPLICATE: string;
|
|
680
664
|
SEARCH_EXCLUSION: string;
|
|
681
665
|
CALCULATED_SKU_MISMATCH: string;
|
|
666
|
+
AI_SKU_MISMATCH: string;
|
|
682
667
|
CRITICAL_SPEC_MISMATCH: string;
|
|
683
668
|
MANUALLY_IGNORED: string;
|
|
684
669
|
MANUALLY_EXCLUDED: string;
|
package/dist/index.js
CHANGED
|
@@ -334,20 +334,12 @@ export const immersiveScrapeResultsSchema = z.object({
|
|
|
334
334
|
// AI extraction fields (per store listing)
|
|
335
335
|
ai_extracted_sku: z.string().nullable().optional(),
|
|
336
336
|
ai_extracted_brand: z.string().nullable().optional(),
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
ai_extraction_quality: z.enum(['high', 'medium', 'low']).nullable().optional(),
|
|
342
|
-
ai_extraction_method: z.enum(['openai', 'regex_fallback', 'cached', 'none']).nullable().optional(),
|
|
337
|
+
ai_extracted_description: z.string().nullable().optional(),
|
|
338
|
+
ai_extracted_features: z.string().nullable().optional(),
|
|
339
|
+
ai_extracted_specifications: z.string().nullable().optional(),
|
|
340
|
+
ai_extracted_shipping: z.string().nullable().optional(),
|
|
343
341
|
ai_processed_at: z.string().nullable().optional(),
|
|
344
342
|
listing_hash: z.string().nullable().optional(),
|
|
345
|
-
// AI aggregate fields (from variant_scrape_found_product_ids)
|
|
346
|
-
ai_unique_skus_found: z.record(z.string(), z.number()).nullable().optional(),
|
|
347
|
-
ai_most_common_sku: z.string().nullable().optional(),
|
|
348
|
-
ai_sku_confidence_avg: z.number().nullable().optional(),
|
|
349
|
-
ai_high_quality_listing_count: z.number().nullable().optional(),
|
|
350
|
-
ai_total_listing_count: z.number().nullable().optional(),
|
|
351
343
|
inline_link: z.null().optional(),
|
|
352
344
|
delivery: z.null().optional(),
|
|
353
345
|
});
|
|
@@ -411,6 +403,7 @@ export const HIDE_REASONS = {
|
|
|
411
403
|
DUPLICATE: 'Duplicate',
|
|
412
404
|
SEARCH_EXCLUSION: 'Search Exclusion',
|
|
413
405
|
CALCULATED_SKU_MISMATCH: 'Calculated SKU Mismatch',
|
|
406
|
+
AI_SKU_MISMATCH: 'AI SKU Mismatch',
|
|
414
407
|
CRITICAL_SPEC_MISMATCH: 'Critical Spec Mismatch',
|
|
415
408
|
MANUALLY_IGNORED: 'Manually ignored',
|
|
416
409
|
MANUALLY_EXCLUDED: 'Manually excluded',
|
|
@@ -437,6 +430,7 @@ const HIDE_ALWAYS_MAP = {
|
|
|
437
430
|
[HIDE_REASONS.DUPLICATE]: true,
|
|
438
431
|
[HIDE_REASONS.SEARCH_EXCLUSION]: false,
|
|
439
432
|
[HIDE_REASONS.CALCULATED_SKU_MISMATCH]: false,
|
|
433
|
+
[HIDE_REASONS.AI_SKU_MISMATCH]: false,
|
|
440
434
|
[HIDE_REASONS.CRITICAL_SPEC_MISMATCH]: false,
|
|
441
435
|
[HIDE_REASONS.MANUALLY_IGNORED]: true,
|
|
442
436
|
[HIDE_REASONS.MANUALLY_EXCLUDED]: true,
|
|
@@ -1092,6 +1086,49 @@ class CalculatedSkuMismatchRule {
|
|
|
1092
1086
|
};
|
|
1093
1087
|
}
|
|
1094
1088
|
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Rule for AI SKU mismatches
|
|
1091
|
+
*/
|
|
1092
|
+
class AISkuMismatchRule {
|
|
1093
|
+
id = 'ai_sku_mismatch';
|
|
1094
|
+
name = 'AI SKU Mismatch';
|
|
1095
|
+
description = 'Filters results with mismatched AI extracted SKUs';
|
|
1096
|
+
severity = FilterSeverity.WARNING;
|
|
1097
|
+
priority = 30;
|
|
1098
|
+
enabled = true;
|
|
1099
|
+
canBeOverridden = true;
|
|
1100
|
+
overridableBy = ['sku_match', 'calculated_sku_match', 'alt_sku_match'];
|
|
1101
|
+
evaluate(context) {
|
|
1102
|
+
const result = context.result;
|
|
1103
|
+
if (!result.ai_extracted_sku) {
|
|
1104
|
+
return null;
|
|
1105
|
+
}
|
|
1106
|
+
const aiSkuLower = result.ai_extracted_sku.toLowerCase();
|
|
1107
|
+
const variantSkuLower = context.variant.sku.toLowerCase();
|
|
1108
|
+
// Check if AI extracted SKU matches variant SKU
|
|
1109
|
+
if (aiSkuLower === variantSkuLower) {
|
|
1110
|
+
return null;
|
|
1111
|
+
}
|
|
1112
|
+
// Check if AI extracted SKU matches any SKU alternates
|
|
1113
|
+
const skuAlternates = context.variantScrapeOptions.sku_alternates || [];
|
|
1114
|
+
const matchesAlternate = skuAlternates.some((alt) => alt.toLowerCase() === aiSkuLower);
|
|
1115
|
+
if (matchesAlternate) {
|
|
1116
|
+
return null;
|
|
1117
|
+
}
|
|
1118
|
+
// If no match found, trigger the rule
|
|
1119
|
+
return {
|
|
1120
|
+
ruleId: this.id,
|
|
1121
|
+
severity: this.severity,
|
|
1122
|
+
message: HIDE_REASONS.AI_SKU_MISMATCH,
|
|
1123
|
+
metadata: {
|
|
1124
|
+
aiSku: result.ai_extracted_sku,
|
|
1125
|
+
variantSku: context.variant.sku,
|
|
1126
|
+
skuAlternates: skuAlternates,
|
|
1127
|
+
},
|
|
1128
|
+
timestamp: new Date().toISOString(),
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1095
1132
|
/**
|
|
1096
1133
|
* Rule for critical spec mismatches
|
|
1097
1134
|
*/
|
|
@@ -1311,6 +1348,7 @@ export function createDefaultFilterRegistry() {
|
|
|
1311
1348
|
registry.registerRule(new BrandMismatchRule());
|
|
1312
1349
|
registry.registerRule(new OutOfStockRule());
|
|
1313
1350
|
registry.registerRule(new CalculatedSkuMismatchRule());
|
|
1351
|
+
registry.registerRule(new AISkuMismatchRule());
|
|
1314
1352
|
registry.registerRule(new CriticalSpecMismatchRule());
|
|
1315
1353
|
registry.registerRule(new RefurbishedUsedRule());
|
|
1316
1354
|
// Register override rules
|