@factorypure/client-helpers 1.1.5 → 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
  };
@@ -196,6 +198,7 @@ const HIDE_ALWAYS_MAP = {
196
198
  [HIDE_REASONS.CALCULATED_SKU_MISMATCH]: false,
197
199
  [HIDE_REASONS.CRITICAL_SPEC_MISMATCH]: false,
198
200
  [HIDE_REASONS.MANUALLY_IGNORED]: true,
201
+ [HIDE_REASONS.MANUALLY_EXCLUDED]: true,
199
202
  [HIDE_REASONS.OUT_OF_STOCK_ONLINE]: true,
200
203
  [HIDE_REASONS.REFURBISHED_USED]: false,
201
204
  [HIDE_REASONS.SKIP_SKU]: false,
@@ -540,20 +543,24 @@ export const calculateHideReasons = (result, variant, variantScrapeOptions, vend
540
543
  }
541
544
  return hide_reasons;
542
545
  };
543
- export const calculateHideOverrideReasons = (result, variant) => {
546
+ export const calculateHideOverrideReasons = (result, variant, sku_alternates) => {
544
547
  const hide_override_reasons = [];
545
548
  // Match SKU as a whole word or inside parentheses/brackets
546
549
  const escapedSku = variant.sku.replace(/\+/g, '\\+');
547
550
  const skuRegex = new RegExp(`(?:\\b|[\\(\\[\\{])${escapedSku}(?:\\b|[\\)\\]\\}])`, 'gi');
548
551
  if (skuRegex.test(result.title)) {
549
- hide_override_reasons.push('SKU Match');
552
+ hide_override_reasons.push(HIDE_OVERRIDE_REASONS.SKU_MATCH);
550
553
  }
551
554
  if (variant.sku.toLowerCase() === result.calculated_sku?.toLowerCase()) {
552
- hide_override_reasons.push('Calculated SKU Match');
555
+ hide_override_reasons.push(HIDE_OVERRIDE_REASONS.CALCULATED_SKU_MATCH);
553
556
  }
554
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?
555
559
  hide_override_reasons.push('Product Id Linked');
556
560
  }
561
+ if (sku_alternates.some((alt) => result.title.includes(alt))) {
562
+ hide_override_reasons.push(HIDE_OVERRIDE_REASONS.ALT_SKU_MATCH);
563
+ }
557
564
  return hide_override_reasons;
558
565
  };
559
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.5",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",