rerobe-js-orm 4.6.6 → 4.6.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.
@@ -31,7 +31,7 @@ export default class Product extends Base {
31
31
  };
32
32
  toObjForTextTranslation(): TranslatableAttributes;
33
33
  toObjForTypesense(isCanonicalMerchant?: boolean): TypesenseProductObj;
34
- private deriveStockStatusFromSystemTags;
34
+ private deriveStockTimestampsFromSystemTags;
35
35
  buildUpdatedFieldsForSalesChannel(): {
36
36
  title: string;
37
37
  description: string;
@@ -579,9 +579,9 @@ class Product extends Base_1.default {
579
579
  stockTakeLatestTimestamp: null,
580
580
  stockTakeFirstTimestamp: null,
581
581
  };
582
- const stockDerivations = this.deriveStockStatusFromSystemTags();
583
- stagedObj.stockStatus = stockDerivations.stockStatus;
584
- stagedObj.stockStatusTimestamp = this.utilities.sanitizeMillisTimeStamp(stockDerivations.stockStatusTimestamp);
582
+ const stockDerivations = this.deriveStockTimestampsFromSystemTags();
583
+ stagedObj.stockStatus = this.utilities.sanitizeString(this.filterAttributes.stockStatus);
584
+ stagedObj.stockStatusTimestamp = this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.stockStatusTimestamp);
585
585
  stagedObj.stockTakeFirstTimestamp = this.utilities.sanitizeMillisTimeStamp(stockDerivations.stockTakeFirstTimestamp);
586
586
  stagedObj.stockTakeLatestTimestamp = this.utilities.sanitizeMillisTimeStamp(stockDerivations.stockTakeLatestTimestamp);
587
587
  if (((_a = this.consignmentAttributes) === null || _a === void 0 ? void 0 : _a.inventoryLocations) &&
@@ -600,7 +600,7 @@ class Product extends Base_1.default {
600
600
  });
601
601
  return stagedObj;
602
602
  }
603
- deriveStockStatusFromSystemTags() {
603
+ deriveStockTimestampsFromSystemTags() {
604
604
  const systemTags = Array.isArray(this.filterAttributes.systemTags) ? this.filterAttributes.systemTags : [];
605
605
  const stockTakeTags = systemTags.filter((t) => typeof t === 'string' && t.startsWith('stock-take|'));
606
606
  const inTransitTags = systemTags.filter((t) => typeof t === 'string' && t.startsWith('in-transit|'));
@@ -631,31 +631,15 @@ class Product extends Base_1.default {
631
631
  const stockTakeLatest = parseLatestAndFirstTs(stockTakeTags).latest;
632
632
  const inTransitLatest = parseLatestAndFirstTs(inTransitTags).latest;
633
633
  const stockTakeLatestSan = stockTakeLatest ? this.utilities.sanitizeMillisTimeStamp(stockTakeLatest) : null;
634
+ const inTransitLatestSan = inTransitLatest ? this.utilities.sanitizeMillisTimeStamp(inTransitLatest) : null;
634
635
  const stockTakeFirstRaw = stockTakeTags.length ? parseLatestAndFirstTs(stockTakeTags).first : 0;
635
636
  const stockTakeFirstSan = stockTakeFirstRaw ? this.utilities.sanitizeMillisTimeStamp(stockTakeFirstRaw) : null;
636
- let stockStatus = '';
637
- let stockStatusTimestamp = null;
638
- if (stockTakeLatest === 0 && inTransitLatest === 0) {
639
- stockStatus = '';
640
- stockStatusTimestamp = null;
641
- }
642
- else if (stockTakeLatest >= inTransitLatest) {
643
- stockStatus = 'In stock';
644
- stockStatusTimestamp = stockTakeLatestSan;
645
- }
646
- else {
647
- stockStatus = 'In transit';
648
- stockStatusTimestamp = this.utilities.sanitizeMillisTimeStamp(inTransitLatest);
649
- }
650
- this.filterAttributes.stockStatus = stockStatus;
651
- this.timestampAttributes.stockStatusTimestamp = stockStatusTimestamp;
652
637
  this.timestampAttributes.stockTakeFirstTimestamp = stockTakeFirstSan;
653
638
  this.timestampAttributes.stockTakeLatestTimestamp = stockTakeLatestSan;
654
639
  return {
655
640
  stockTakeFirstTimestamp: stockTakeFirstSan,
656
641
  stockTakeLatestTimestamp: stockTakeLatestSan,
657
- stockStatus,
658
- stockStatusTimestamp,
642
+ inTransitLatestTimestamp: inTransitLatestSan,
659
643
  };
660
644
  }
661
645
  buildUpdatedFieldsForSalesChannel() {
@@ -371,7 +371,7 @@ type TypesenseProductObj = {
371
371
  description: string;
372
372
  discountType: string;
373
373
  discountValue: number;
374
- stockStatus: 'In stock' | 'In transit' | '';
374
+ stockStatus: string;
375
375
  stockStatusTimestamp: number | null;
376
376
  id: string;
377
377
  documentId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "4.6.6",
3
+ "version": "4.6.8",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",