@factorypure/client-helpers 1.1.6 → 1.1.8
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 -1
- package/dist/index.js +13 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -313,6 +313,7 @@ export type ResultIgnoreType = z.infer<typeof ResultIgnoreSchema>;
|
|
|
313
313
|
export type ScrapeFiltersType = {
|
|
314
314
|
found_id_exclusions: string[] | null;
|
|
315
315
|
competitor_exclusions: string[];
|
|
316
|
+
sku_alternates: string[];
|
|
316
317
|
match_values: string[];
|
|
317
318
|
default_skip_skus: string[];
|
|
318
319
|
skip_vendors: string[];
|
|
@@ -329,6 +330,7 @@ export declare const variantScrapeOptionsSchema: z.ZodObject<{
|
|
|
329
330
|
custom_search_value: z.ZodString;
|
|
330
331
|
match_values: z.ZodArray<z.ZodString>;
|
|
331
332
|
competitor_exclusions: z.ZodArray<z.ZodString>;
|
|
333
|
+
sku_alternates: z.ZodArray<z.ZodString>;
|
|
332
334
|
found_product_ids: z.ZodArray<z.ZodString>;
|
|
333
335
|
result_ignore_keys: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
334
336
|
id: z.ZodNumber;
|
|
@@ -382,8 +384,10 @@ export declare const HIDE_REASONS: {
|
|
|
382
384
|
};
|
|
383
385
|
export declare const HIDE_OVERRIDE_REASONS: {
|
|
384
386
|
SKU_MATCH: string;
|
|
387
|
+
ALT_SKU_MATCH: string;
|
|
385
388
|
CALCULATED_SKU_MATCH: string;
|
|
386
389
|
CALCULATED_SKU_PARTIAL_MATCH: string;
|
|
390
|
+
CALCULATED_ALT_SKU_MATCH: string;
|
|
387
391
|
};
|
|
388
392
|
export declare const TOO_CHEAP_MULTIPLIER = 0.75;
|
|
389
393
|
export declare const TOO_EXPENSIVE_MULTIPLIER = 1.15;
|
|
@@ -419,5 +423,5 @@ export declare const calculateHideOverrideReasons: (result: ScrapeResultsType |
|
|
|
419
423
|
price: number;
|
|
420
424
|
vendor: string;
|
|
421
425
|
found_product_ids?: string[];
|
|
422
|
-
}) => string[];
|
|
426
|
+
}, sku_alternates: string[]) => string[];
|
|
423
427
|
export declare function findUnitVariations(data: any): any;
|
package/dist/index.js
CHANGED
|
@@ -143,6 +143,7 @@ export const variantScrapeOptionsSchema = z.object({
|
|
|
143
143
|
custom_search_value: z.string(),
|
|
144
144
|
match_values: z.array(z.string()),
|
|
145
145
|
competitor_exclusions: z.array(z.string()),
|
|
146
|
+
sku_alternates: z.array(z.string()),
|
|
146
147
|
found_product_ids: z.array(z.string()),
|
|
147
148
|
result_ignore_keys: z.array(ResultIgnoreSchema).nullable(),
|
|
148
149
|
day_window: z.string().nullable(),
|
|
@@ -183,8 +184,10 @@ export const HIDE_REASONS = {
|
|
|
183
184
|
};
|
|
184
185
|
export const HIDE_OVERRIDE_REASONS = {
|
|
185
186
|
SKU_MATCH: 'SKU Match',
|
|
187
|
+
ALT_SKU_MATCH: 'Alt SKU Match',
|
|
186
188
|
CALCULATED_SKU_MATCH: 'Calculated SKU Match',
|
|
187
189
|
CALCULATED_SKU_PARTIAL_MATCH: 'Calculated SKU Partial Match',
|
|
190
|
+
CALCULATED_ALT_SKU_MATCH: 'Calc. Alt SKU Match',
|
|
188
191
|
};
|
|
189
192
|
const HIDE_ALWAYS_MAP = {
|
|
190
193
|
[HIDE_REASONS.HIGH_PRICE_OUTLIER]: true,
|
|
@@ -541,20 +544,27 @@ export const calculateHideReasons = (result, variant, variantScrapeOptions, vend
|
|
|
541
544
|
}
|
|
542
545
|
return hide_reasons;
|
|
543
546
|
};
|
|
544
|
-
export const calculateHideOverrideReasons = (result, variant) => {
|
|
547
|
+
export const calculateHideOverrideReasons = (result, variant, sku_alternates) => {
|
|
545
548
|
const hide_override_reasons = [];
|
|
546
549
|
// Match SKU as a whole word or inside parentheses/brackets
|
|
547
550
|
const escapedSku = variant.sku.replace(/\+/g, '\\+');
|
|
548
551
|
const skuRegex = new RegExp(`(?:\\b|[\\(\\[\\{])${escapedSku}(?:\\b|[\\)\\]\\}])`, 'gi');
|
|
549
552
|
if (skuRegex.test(result.title)) {
|
|
550
|
-
hide_override_reasons.push(
|
|
553
|
+
hide_override_reasons.push(HIDE_OVERRIDE_REASONS.SKU_MATCH);
|
|
551
554
|
}
|
|
552
555
|
if (variant.sku.toLowerCase() === result.calculated_sku?.toLowerCase()) {
|
|
553
|
-
hide_override_reasons.push(
|
|
556
|
+
hide_override_reasons.push(HIDE_OVERRIDE_REASONS.CALCULATED_SKU_MATCH);
|
|
554
557
|
}
|
|
555
558
|
if (variant.found_product_ids && variant.found_product_ids.includes(result.found_product_id)) {
|
|
559
|
+
// TODO ALEX - Does this work? Is it doing anything?
|
|
556
560
|
hide_override_reasons.push('Product Id Linked');
|
|
557
561
|
}
|
|
562
|
+
if (sku_alternates.some((alt) => result?.title?.toLowerCase().includes(alt.toLowerCase()))) {
|
|
563
|
+
hide_override_reasons.push(HIDE_OVERRIDE_REASONS.ALT_SKU_MATCH);
|
|
564
|
+
}
|
|
565
|
+
if (sku_alternates.some((alt) => result?.calculated_sku?.toLowerCase() === alt.toLowerCase())) {
|
|
566
|
+
hide_override_reasons.push(HIDE_OVERRIDE_REASONS.CALCULATED_ALT_SKU_MATCH);
|
|
567
|
+
}
|
|
558
568
|
return hide_override_reasons;
|
|
559
569
|
};
|
|
560
570
|
function getRegexUnitResultsIgnore(resultRegexResults, variantRegexResults, criticalUnits = ['ton', 'cc', 'hp']) {
|