@factorypure/client-helpers 1.1.15 → 1.1.16
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 +1 -0
- package/dist/index.js +46 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -411,6 +411,7 @@ export const HIDE_REASONS = {
|
|
|
411
411
|
DUPLICATE: 'Duplicate',
|
|
412
412
|
SEARCH_EXCLUSION: 'Search Exclusion',
|
|
413
413
|
CALCULATED_SKU_MISMATCH: 'Calculated SKU Mismatch',
|
|
414
|
+
AI_SKU_MISMATCH: 'AI SKU Mismatch',
|
|
414
415
|
CRITICAL_SPEC_MISMATCH: 'Critical Spec Mismatch',
|
|
415
416
|
MANUALLY_IGNORED: 'Manually ignored',
|
|
416
417
|
MANUALLY_EXCLUDED: 'Manually excluded',
|
|
@@ -437,6 +438,7 @@ const HIDE_ALWAYS_MAP = {
|
|
|
437
438
|
[HIDE_REASONS.DUPLICATE]: true,
|
|
438
439
|
[HIDE_REASONS.SEARCH_EXCLUSION]: false,
|
|
439
440
|
[HIDE_REASONS.CALCULATED_SKU_MISMATCH]: false,
|
|
441
|
+
[HIDE_REASONS.AI_SKU_MISMATCH]: false,
|
|
440
442
|
[HIDE_REASONS.CRITICAL_SPEC_MISMATCH]: false,
|
|
441
443
|
[HIDE_REASONS.MANUALLY_IGNORED]: true,
|
|
442
444
|
[HIDE_REASONS.MANUALLY_EXCLUDED]: true,
|
|
@@ -1092,6 +1094,49 @@ class CalculatedSkuMismatchRule {
|
|
|
1092
1094
|
};
|
|
1093
1095
|
}
|
|
1094
1096
|
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Rule for AI SKU mismatches
|
|
1099
|
+
*/
|
|
1100
|
+
class AISkuMismatchRule {
|
|
1101
|
+
id = 'ai_sku_mismatch';
|
|
1102
|
+
name = 'AI SKU Mismatch';
|
|
1103
|
+
description = 'Filters results with mismatched AI extracted SKUs';
|
|
1104
|
+
severity = FilterSeverity.WARNING;
|
|
1105
|
+
priority = 30;
|
|
1106
|
+
enabled = true;
|
|
1107
|
+
canBeOverridden = true;
|
|
1108
|
+
overridableBy = ['sku_match', 'calculated_sku_match', 'alt_sku_match'];
|
|
1109
|
+
evaluate(context) {
|
|
1110
|
+
const result = context.result;
|
|
1111
|
+
if (!result.ai_extracted_sku) {
|
|
1112
|
+
return null;
|
|
1113
|
+
}
|
|
1114
|
+
const aiSkuLower = result.ai_extracted_sku.toLowerCase();
|
|
1115
|
+
const variantSkuLower = context.variant.sku.toLowerCase();
|
|
1116
|
+
// Check if AI extracted SKU matches variant SKU
|
|
1117
|
+
if (aiSkuLower === variantSkuLower) {
|
|
1118
|
+
return null;
|
|
1119
|
+
}
|
|
1120
|
+
// Check if AI extracted SKU matches any SKU alternates
|
|
1121
|
+
const skuAlternates = context.variantScrapeOptions.sku_alternates || [];
|
|
1122
|
+
const matchesAlternate = skuAlternates.some((alt) => alt.toLowerCase() === aiSkuLower);
|
|
1123
|
+
if (matchesAlternate) {
|
|
1124
|
+
return null;
|
|
1125
|
+
}
|
|
1126
|
+
// If no match found, trigger the rule
|
|
1127
|
+
return {
|
|
1128
|
+
ruleId: this.id,
|
|
1129
|
+
severity: this.severity,
|
|
1130
|
+
message: HIDE_REASONS.AI_SKU_MISMATCH,
|
|
1131
|
+
metadata: {
|
|
1132
|
+
aiSku: result.ai_extracted_sku,
|
|
1133
|
+
variantSku: context.variant.sku,
|
|
1134
|
+
skuAlternates: skuAlternates,
|
|
1135
|
+
},
|
|
1136
|
+
timestamp: new Date().toISOString(),
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1095
1140
|
/**
|
|
1096
1141
|
* Rule for critical spec mismatches
|
|
1097
1142
|
*/
|
|
@@ -1311,6 +1356,7 @@ export function createDefaultFilterRegistry() {
|
|
|
1311
1356
|
registry.registerRule(new BrandMismatchRule());
|
|
1312
1357
|
registry.registerRule(new OutOfStockRule());
|
|
1313
1358
|
registry.registerRule(new CalculatedSkuMismatchRule());
|
|
1359
|
+
registry.registerRule(new AISkuMismatchRule());
|
|
1314
1360
|
registry.registerRule(new CriticalSpecMismatchRule());
|
|
1315
1361
|
registry.registerRule(new RefurbishedUsedRule());
|
|
1316
1362
|
// Register override rules
|