@factorypure/client-helpers 1.1.6 → 1.1.7

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 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,6 +384,7 @@ 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;
387
390
  };
@@ -419,5 +422,5 @@ export declare const calculateHideOverrideReasons: (result: ScrapeResultsType |
419
422
  price: number;
420
423
  vendor: string;
421
424
  found_product_ids?: string[];
422
- }) => string[];
425
+ }, sku_alternates: string[]) => string[];
423
426
  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,6 +184,7 @@ 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',
188
190
  };
@@ -541,20 +543,24 @@ export const calculateHideReasons = (result, variant, variantScrapeOptions, vend
541
543
  }
542
544
  return hide_reasons;
543
545
  };
544
- export const calculateHideOverrideReasons = (result, variant) => {
546
+ export const calculateHideOverrideReasons = (result, variant, sku_alternates) => {
545
547
  const hide_override_reasons = [];
546
548
  // Match SKU as a whole word or inside parentheses/brackets
547
549
  const escapedSku = variant.sku.replace(/\+/g, '\\+');
548
550
  const skuRegex = new RegExp(`(?:\\b|[\\(\\[\\{])${escapedSku}(?:\\b|[\\)\\]\\}])`, 'gi');
549
551
  if (skuRegex.test(result.title)) {
550
- hide_override_reasons.push('SKU Match');
552
+ hide_override_reasons.push(HIDE_OVERRIDE_REASONS.SKU_MATCH);
551
553
  }
552
554
  if (variant.sku.toLowerCase() === result.calculated_sku?.toLowerCase()) {
553
- hide_override_reasons.push('Calculated SKU Match');
555
+ hide_override_reasons.push(HIDE_OVERRIDE_REASONS.CALCULATED_SKU_MATCH);
554
556
  }
555
557
  if (variant.found_product_ids && variant.found_product_ids.includes(result.found_product_id)) {
558
+ // TODO ALEX - Does this work? Is it doing anything?
556
559
  hide_override_reasons.push('Product Id Linked');
557
560
  }
561
+ if (sku_alternates.some((alt) => result.title.includes(alt))) {
562
+ hide_override_reasons.push(HIDE_OVERRIDE_REASONS.ALT_SKU_MATCH);
563
+ }
558
564
  return hide_override_reasons;
559
565
  };
560
566
  function getRegexUnitResultsIgnore(resultRegexResults, variantRegexResults, criticalUnits = ['ton', 'cc', 'hp']) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorypure/client-helpers",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",