rerobe-js-orm 4.6.3 → 4.6.5

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.
@@ -4,44 +4,45 @@ const ProductFactory_1 = require("./ProductFactory");
4
4
  const Product_1 = require("../../models/Product");
5
5
  class ProductFromFormState extends ProductFactory_1.default {
6
6
  createProduct(props) {
7
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32;
7
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37;
8
8
  const productAttributes = {
9
9
  availableForSale: props.fields.availableForSale.selectedValue,
10
10
  description: props.fields.description.inputValue,
11
11
  handle: props.fields.handle.inputValue || '',
12
12
  shopifyId: ((_a = props.props) === null || _a === void 0 ? void 0 : _a.shopifyId) || '',
13
+ traderaId: ((_b = props.props) === null || _b === void 0 ? void 0 : _b.traderaId) || '',
13
14
  title: props.fields.title.inputValue,
14
- coverPhotoUrl: ((_b = props.props) === null || _b === void 0 ? void 0 : _b.coverPhotoUrl) || '',
15
- imageUrls: ((_c = props.props) === null || _c === void 0 ? void 0 : _c.imageUrls) || [],
16
- imageUrlsForAI: ((_d = props.props) === null || _d === void 0 ? void 0 : _d.imageUrlsForAI) || [],
15
+ coverPhotoUrl: ((_c = props.props) === null || _c === void 0 ? void 0 : _c.coverPhotoUrl) || '',
16
+ imageUrls: ((_d = props.props) === null || _d === void 0 ? void 0 : _d.imageUrls) || [],
17
+ imageUrlsForAI: ((_e = props.props) === null || _e === void 0 ? void 0 : _e.imageUrlsForAI) || [],
17
18
  price: props.fields.price.inputValue,
18
19
  isTaxable: props.fields.isTaxable.selectedValue,
19
20
  productClass: props.fields.productClass.selectedValue,
20
- createdAt: ((_e = props.props) === null || _e === void 0 ? void 0 : _e.createdAt) || new Date().toUTCString(), // ToDo look into different timestamp
21
- updatedAt: ((_f = props.props) === null || _f === void 0 ? void 0 : _f.updatedAt) || new Date().toUTCString(), // ToDo look into different timestamp
22
- publishedAt: ((_g = props.props) === null || _g === void 0 ? void 0 : _g.publishedAt) || new Date().toUTCString(),
23
- vendorId: props.fields.vendorId.selectedValue || ((_h = props.props) === null || _h === void 0 ? void 0 : _h.vendorId) || '',
21
+ createdAt: ((_f = props.props) === null || _f === void 0 ? void 0 : _f.createdAt) || new Date().toUTCString(), // ToDo look into different timestamp
22
+ updatedAt: ((_g = props.props) === null || _g === void 0 ? void 0 : _g.updatedAt) || new Date().toUTCString(), // ToDo look into different timestamp
23
+ publishedAt: ((_h = props.props) === null || _h === void 0 ? void 0 : _h.publishedAt) || new Date().toUTCString(),
24
+ vendorId: props.fields.vendorId.selectedValue || ((_j = props.props) === null || _j === void 0 ? void 0 : _j.vendorId) || '',
24
25
  vendorName: props.fields.vendorName.selectedValue || '',
25
26
  weight: props.fields.weight.inputValue,
26
27
  weightRange: props.fields.weightRange.selectedValue || '',
27
28
  weightUnit: props.fields.weightUnit.selectedValue || '',
28
- variantId: ((_j = props.props) === null || _j === void 0 ? void 0 : _j.variantId) || '',
29
- reservedBy: ((_k = props.props) === null || _k === void 0 ? void 0 : _k.reservedBy) || [],
29
+ variantId: ((_k = props.props) === null || _k === void 0 ? void 0 : _k.variantId) || '',
30
+ reservedBy: ((_l = props.props) === null || _l === void 0 ? void 0 : _l.reservedBy) || [],
30
31
  options: props.fields.options.selectedValue,
31
- variantInventory: ((_l = props.fields.variantInventory) === null || _l === void 0 ? void 0 : _l.selectedValues) || [],
32
+ variantInventory: ((_m = props.fields.variantInventory) === null || _m === void 0 ? void 0 : _m.selectedValues) || [],
32
33
  costPerItem: props.fields.costPerItem.inputValue,
33
34
  compareAtPrice: props.fields.compareAtPrice.inputValue,
34
35
  quantity: props.fields.quantity.inputValue,
35
- merchants: ((_m = props.props) === null || _m === void 0 ? void 0 : _m.merchants) || [],
36
- merchantId: ((_o = props.props) === null || _o === void 0 ? void 0 : _o.merchantId) || '',
36
+ merchants: ((_o = props.props) === null || _o === void 0 ? void 0 : _o.merchants) || [],
37
+ merchantId: ((_p = props.props) === null || _p === void 0 ? void 0 : _p.merchantId) || '',
37
38
  editorAuthorizations: props.fields.editorAuthorizations.selectedValue,
38
39
  rfidTag: props.fields.rfidTag.inputValue || '',
39
40
  sku: props.fields.sku.inputValue || '',
40
- metaDataDescription: ((_p = props.fields.metaDataDescription) === null || _p === void 0 ? void 0 : _p.inputValue) || '',
41
- metaDataTitle: ((_q = props.fields.metaDataTitle) === null || _q === void 0 ? void 0 : _q.inputValue) || '',
41
+ metaDataDescription: ((_q = props.fields.metaDataDescription) === null || _q === void 0 ? void 0 : _q.inputValue) || '',
42
+ metaDataTitle: ((_r = props.fields.metaDataTitle) === null || _r === void 0 ? void 0 : _r.inputValue) || '',
42
43
  };
43
44
  const productFilterAttributes = {
44
- documentId: (_r = props.props) === null || _r === void 0 ? void 0 : _r.documentId,
45
+ documentId: (_s = props.props) === null || _s === void 0 ? void 0 : _s.documentId,
45
46
  brand: props.fields.brand.selectedValue,
46
47
  measurementCategory: props.fields.measurementCategory.selectedValue,
47
48
  size: props.fields.size.selectedValue,
@@ -62,10 +63,11 @@ class ProductFromFormState extends ProductFactory_1.default {
62
63
  featuredCollections: props.fields.featuredCollections.selectedValues || [],
63
64
  primaryAgeCategory: props.fields.primaryAgeCategory.selectedValue || '',
64
65
  tags: props.fields.tags.selectedValues || [],
65
- systemTags: ((_s = props.props) === null || _s === void 0 ? void 0 : _s.systemTags) || [],
66
+ systemTags: ((_t = props.props) === null || _t === void 0 ? void 0 : _t.systemTags) || [],
67
+ stockStatus: ((_u = props.props) === null || _u === void 0 ? void 0 : _u.stockStatus) || '',
66
68
  };
67
69
  const consignmentAttributes = {
68
- sellRequestId: ((_t = props.props) === null || _t === void 0 ? void 0 : _t.sellRequestId) || '',
70
+ sellRequestId: ((_v = props.props) === null || _v === void 0 ? void 0 : _v.sellRequestId) || '',
69
71
  publishType: props.fields.publishType.selectedValue,
70
72
  conditionRemarks: props.fields.conditionRemarks.inputValue,
71
73
  productRemarks: props.fields.productRemarks.inputValue,
@@ -78,14 +80,14 @@ class ProductFromFormState extends ProductFactory_1.default {
78
80
  nextAvailableSeason: props.fields.nextAvailableSeason.selectedValue,
79
81
  notesForProductionTeam: props.fields.notesForProductionTeam.inputValue,
80
82
  reviewedBy: props.fields.reviewedBy.selectedValue,
81
- sellRequestImageUrls: ((_u = props.props) === null || _u === void 0 ? void 0 : _u.sellRequestImageUrls) || [],
83
+ sellRequestImageUrls: ((_w = props.props) === null || _w === void 0 ? void 0 : _w.sellRequestImageUrls) || [],
82
84
  salesChannel: props.fields.salesChannel.selectedValues || [],
83
85
  sizeComment: props.fields.sizeComment.selectedValue,
84
- salePrice: ((_v = props.props) === null || _v === void 0 ? void 0 : _v.salePrice) || '',
86
+ salePrice: ((_x = props.props) === null || _x === void 0 ? void 0 : _x.salePrice) || '',
85
87
  isOnSale: props.fields.isOnSale.selectedValue || '',
86
88
  discountType: props.fields.discountType.selectedValue || '',
87
89
  discountValue: props.fields.discountValue.inputValue || '',
88
- selectedForClearance: ((_w = props.props) === null || _w === void 0 ? void 0 : _w.selectedForClearance) || '',
90
+ selectedForClearance: ((_y = props.props) === null || _y === void 0 ? void 0 : _y.selectedForClearance) || '',
89
91
  locationIds: props.fields.locationIds.selectedValues || [],
90
92
  inventoryLocations: props.fields.inventoryLocations.selectedValues || [],
91
93
  majorDefects: props.fields.majorDefects.selectedValues || [], // ToDo: Deprecate
@@ -93,44 +95,47 @@ class ProductFromFormState extends ProductFactory_1.default {
93
95
  careInstructions: props.fields.careInstructions.inputValue || '',
94
96
  };
95
97
  const timestampAttributes = {
96
- createdAtTimestamp: (_x = props.props) === null || _x === void 0 ? void 0 : _x.createdAtTimestamp,
97
- updatedAtTimestamp: (_y = props.props) === null || _y === void 0 ? void 0 : _y.updatedAtTimestamp,
98
- sellRequestReviewTimestamp: (_z = props.props) === null || _z === void 0 ? void 0 : _z.sellRequestReviewTimestamp,
99
- sellRequestReviewDraftTimestamp: (_0 = props.props) === null || _0 === void 0 ? void 0 : _0.sellRequestReviewDraftTimestamp,
100
- rejectedTimestamp: (_1 = props.props) === null || _1 === void 0 ? void 0 : _1.rejectedTimestamp,
101
- holdTimestamp: (_2 = props.props) === null || _2 === void 0 ? void 0 : _2.holdTimestamp,
102
- acceptedTimestamp: (_3 = props.props) === null || _3 === void 0 ? void 0 : _3.acceptedTimestamp,
103
- sellerToDropOffTimestamp: (_4 = props.props) === null || _4 === void 0 ? void 0 : _4.sellerToDropOffTimestamp,
104
- sellerToShipTimestamp: (_5 = props.props) === null || _5 === void 0 ? void 0 : _5.sellerToShipTimestamp,
105
- sellerToGetPickUpTimestamp: (_6 = props.props) === null || _6 === void 0 ? void 0 : _6.sellerToGetPickUpTimestamp,
106
- qualityControlTimestamp: (_7 = props.props) === null || _7 === void 0 ? void 0 : _7.qualityControlTimestamp,
107
- pendingPublicationTimestamp: (_8 = props.props) === null || _8 === void 0 ? void 0 : _8.pendingPublicationTimestamp,
108
- listedTimestamp: (_9 = props.props) === null || _9 === void 0 ? void 0 : _9.listedTimestamp,
109
- clearanceTimestamp: (_10 = props.props) === null || _10 === void 0 ? void 0 : _10.clearanceTimestamp,
110
- reservedTimestamp: (_11 = props.props) === null || _11 === void 0 ? void 0 : _11.reservedTimestamp,
111
- soldTimestamp: (_12 = props.props) === null || _12 === void 0 ? void 0 : _12.soldTimestamp,
112
- returnedTimestamp: (_13 = props.props) === null || _13 === void 0 ? void 0 : _13.returnedTimestamp,
113
- soldSellerSelfPayTimestamp: (_14 = props.props) === null || _14 === void 0 ? void 0 : _14.soldSellerSelfPayTimestamp,
114
- soldSellerPayoutProcessingTimestamp: (_15 = props.props) === null || _15 === void 0 ? void 0 : _15.soldSellerPayoutProcessingTimestamp,
115
- soldSellerPayoutFailedTimestamp: (_16 = props.props) === null || _16 === void 0 ? void 0 : _16.soldSellerPayoutFailedTimestamp,
116
- soldSellerToBePaidTimestamp: (_17 = props.props) === null || _17 === void 0 ? void 0 : _17.soldSellerToBePaidTimestamp,
117
- soldSellerPaidTimestamp: (_18 = props.props) === null || _18 === void 0 ? void 0 : _18.soldSellerPaidTimestamp,
118
- sellerSelfRejectTimestamp: (_19 = props.props) === null || _19 === void 0 ? void 0 : _19.sellerSelfRejectTimestamp,
119
- liquidationRequestedTimestamp: (_20 = props.props) === null || _20 === void 0 ? void 0 : _20.liquidationRequestedTimestamp,
120
- sellerLiquidatedTimestamp: (_21 = props.props) === null || _21 === void 0 ? void 0 : _21.sellerLiquidatedTimestamp,
121
- archivedTimestamp: (_22 = props.props) === null || _22 === void 0 ? void 0 : _22.archivedTimestamp,
122
- liquidationReadyTimestamp: (_23 = props.props) === null || _23 === void 0 ? void 0 : _23.liquidationReadyTimestamp,
123
- sellerDonatedTimestamp: (_24 = props.props) === null || _24 === void 0 ? void 0 : _24.sellerDonatedTimestamp,
124
- merchantDonatedTimestamp: (_25 = props.props) === null || _25 === void 0 ? void 0 : _25.merchantDonatedTimestamp,
125
- draftTimestamp: (_26 = props.props) === null || _26 === void 0 ? void 0 : _26.draftTimestamp,
126
- hiddenTimestamp: (_27 = props.props) === null || _27 === void 0 ? void 0 : _27.hiddenTimestamp,
127
- bookedTimestamp: (_28 = props.props) === null || _28 === void 0 ? void 0 : _28.bookedTimestamp,
128
- openTimestamp: (_29 = props.props) === null || _29 === void 0 ? void 0 : _29.openTimestamp,
98
+ createdAtTimestamp: (_z = props.props) === null || _z === void 0 ? void 0 : _z.createdAtTimestamp,
99
+ updatedAtTimestamp: (_0 = props.props) === null || _0 === void 0 ? void 0 : _0.updatedAtTimestamp,
100
+ sellRequestReviewTimestamp: (_1 = props.props) === null || _1 === void 0 ? void 0 : _1.sellRequestReviewTimestamp,
101
+ sellRequestReviewDraftTimestamp: (_2 = props.props) === null || _2 === void 0 ? void 0 : _2.sellRequestReviewDraftTimestamp,
102
+ rejectedTimestamp: (_3 = props.props) === null || _3 === void 0 ? void 0 : _3.rejectedTimestamp,
103
+ holdTimestamp: (_4 = props.props) === null || _4 === void 0 ? void 0 : _4.holdTimestamp,
104
+ acceptedTimestamp: (_5 = props.props) === null || _5 === void 0 ? void 0 : _5.acceptedTimestamp,
105
+ sellerToDropOffTimestamp: (_6 = props.props) === null || _6 === void 0 ? void 0 : _6.sellerToDropOffTimestamp,
106
+ sellerToShipTimestamp: (_7 = props.props) === null || _7 === void 0 ? void 0 : _7.sellerToShipTimestamp,
107
+ sellerToGetPickUpTimestamp: (_8 = props.props) === null || _8 === void 0 ? void 0 : _8.sellerToGetPickUpTimestamp,
108
+ qualityControlTimestamp: (_9 = props.props) === null || _9 === void 0 ? void 0 : _9.qualityControlTimestamp,
109
+ pendingPublicationTimestamp: (_10 = props.props) === null || _10 === void 0 ? void 0 : _10.pendingPublicationTimestamp,
110
+ listedTimestamp: (_11 = props.props) === null || _11 === void 0 ? void 0 : _11.listedTimestamp,
111
+ clearanceTimestamp: (_12 = props.props) === null || _12 === void 0 ? void 0 : _12.clearanceTimestamp,
112
+ reservedTimestamp: (_13 = props.props) === null || _13 === void 0 ? void 0 : _13.reservedTimestamp,
113
+ soldTimestamp: (_14 = props.props) === null || _14 === void 0 ? void 0 : _14.soldTimestamp,
114
+ returnedTimestamp: (_15 = props.props) === null || _15 === void 0 ? void 0 : _15.returnedTimestamp,
115
+ soldSellerSelfPayTimestamp: (_16 = props.props) === null || _16 === void 0 ? void 0 : _16.soldSellerSelfPayTimestamp,
116
+ soldSellerPayoutProcessingTimestamp: (_17 = props.props) === null || _17 === void 0 ? void 0 : _17.soldSellerPayoutProcessingTimestamp,
117
+ soldSellerPayoutFailedTimestamp: (_18 = props.props) === null || _18 === void 0 ? void 0 : _18.soldSellerPayoutFailedTimestamp,
118
+ soldSellerToBePaidTimestamp: (_19 = props.props) === null || _19 === void 0 ? void 0 : _19.soldSellerToBePaidTimestamp,
119
+ soldSellerPaidTimestamp: (_20 = props.props) === null || _20 === void 0 ? void 0 : _20.soldSellerPaidTimestamp,
120
+ sellerSelfRejectTimestamp: (_21 = props.props) === null || _21 === void 0 ? void 0 : _21.sellerSelfRejectTimestamp,
121
+ liquidationRequestedTimestamp: (_22 = props.props) === null || _22 === void 0 ? void 0 : _22.liquidationRequestedTimestamp,
122
+ sellerLiquidatedTimestamp: (_23 = props.props) === null || _23 === void 0 ? void 0 : _23.sellerLiquidatedTimestamp,
123
+ archivedTimestamp: (_24 = props.props) === null || _24 === void 0 ? void 0 : _24.archivedTimestamp,
124
+ liquidationReadyTimestamp: (_25 = props.props) === null || _25 === void 0 ? void 0 : _25.liquidationReadyTimestamp,
125
+ sellerDonatedTimestamp: (_26 = props.props) === null || _26 === void 0 ? void 0 : _26.sellerDonatedTimestamp,
126
+ merchantDonatedTimestamp: (_27 = props.props) === null || _27 === void 0 ? void 0 : _27.merchantDonatedTimestamp,
127
+ draftTimestamp: (_28 = props.props) === null || _28 === void 0 ? void 0 : _28.draftTimestamp,
128
+ hiddenTimestamp: (_29 = props.props) === null || _29 === void 0 ? void 0 : _29.hiddenTimestamp,
129
+ bookedTimestamp: (_30 = props.props) === null || _30 === void 0 ? void 0 : _30.bookedTimestamp,
130
+ openTimestamp: (_31 = props.props) === null || _31 === void 0 ? void 0 : _31.openTimestamp,
131
+ stockTakeFirstTimestamp: (_32 = props.props) === null || _32 === void 0 ? void 0 : _32.stockTakeFirstTimestamp,
132
+ stockTakeLatestTimestamp: (_33 = props.props) === null || _33 === void 0 ? void 0 : _33.stockTakeLatestTimestamp,
133
+ stockStatusTimestamp: (_34 = props.props) === null || _34 === void 0 ? void 0 : _34.stockStatusTimestamp,
129
134
  };
130
135
  const payoutAttributes = {
131
- payoutMethod: (_30 = props.props) === null || _30 === void 0 ? void 0 : _30.payoutMethod,
132
- payoutSystem: (_31 = props.props) === null || _31 === void 0 ? void 0 : _31.payoutSystem,
133
- payoutReference: (_32 = props.props) === null || _32 === void 0 ? void 0 : _32.payoutReference,
136
+ payoutMethod: (_35 = props.props) === null || _35 === void 0 ? void 0 : _35.payoutMethod,
137
+ payoutSystem: (_36 = props.props) === null || _36 === void 0 ? void 0 : _36.payoutSystem,
138
+ payoutReference: (_37 = props.props) === null || _37 === void 0 ? void 0 : _37.payoutReference,
134
139
  };
135
140
  return new Product_1.default(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, productAttributes), productFilterAttributes), consignmentAttributes), timestampAttributes), payoutAttributes));
136
141
  }
@@ -31,6 +31,7 @@ export default class Product extends Base {
31
31
  };
32
32
  toObjForTextTranslation(): TranslatableAttributes;
33
33
  toObjForTypesense(isCanonicalMerchant?: boolean): TypesenseProductObj;
34
+ private deriveStockStatusFromSystemTags;
34
35
  buildUpdatedFieldsForSalesChannel(): {
35
36
  title: string;
36
37
  description: string;
@@ -16,6 +16,7 @@ class Product extends Base_1.default {
16
16
  imageUrlsForAI: this.utilities.sanitzeStringArr(props === null || props === void 0 ? void 0 : props.imageUrlsForAI),
17
17
  price: (props === null || props === void 0 ? void 0 : props.price) || '',
18
18
  shopifyId: (props === null || props === void 0 ? void 0 : props.shopifyId) || '',
19
+ traderaId: (props === null || props === void 0 ? void 0 : props.traderaId) || '',
19
20
  handle: (props === null || props === void 0 ? void 0 : props.handle) || '',
20
21
  availableForSale: !!(props === null || props === void 0 ? void 0 : props.availableForSale),
21
22
  createdAt: (props === null || props === void 0 ? void 0 : props.createdAt) || '',
@@ -66,6 +67,7 @@ class Product extends Base_1.default {
66
67
  primaryAgeCategory: (props === null || props === void 0 ? void 0 : props.primaryAgeCategory) || '',
67
68
  tags: this.utilities.sanitzeStringArr(props === null || props === void 0 ? void 0 : props.tags) || [],
68
69
  systemTags: this.utilities.sanitzeStringArr(props === null || props === void 0 ? void 0 : props.systemTags) || [],
70
+ stockStatus: (props === null || props === void 0 ? void 0 : props.stockStatus) || '',
69
71
  };
70
72
  this.consignmentAttributes = {
71
73
  sellRequestImageUrls: (props === null || props === void 0 ? void 0 : props.sellRequestImageUrls) || [],
@@ -141,6 +143,9 @@ class Product extends Base_1.default {
141
143
  soldSellerPayoutFailedTimestamp: (props === null || props === void 0 ? void 0 : props.soldSellerPayoutFailedTimestamp)
142
144
  ? Number(props === null || props === void 0 ? void 0 : props.soldSellerPayoutFailedTimestamp)
143
145
  : null,
146
+ stockTakeFirstTimestamp: (props === null || props === void 0 ? void 0 : props.stockTakeFirstTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.stockTakeFirstTimestamp) : null,
147
+ stockTakeLatestTimestamp: (props === null || props === void 0 ? void 0 : props.stockTakeLatestTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.stockTakeLatestTimestamp) : null,
148
+ stockStatusTimestamp: (props === null || props === void 0 ? void 0 : props.stockStatusTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.stockStatusTimestamp) : null,
144
149
  };
145
150
  this.payoutAttributes = {
146
151
  payoutMethod: (props === null || props === void 0 ? void 0 : props.payoutMethod) || null,
@@ -493,6 +498,14 @@ class Product extends Base_1.default {
493
498
  rfidTag: this.utilities.sanitizeString(this.attributes.rfidTag),
494
499
  sku: this.utilities.sanitizeString(this.attributes.sku),
495
500
  salesChannel: this.utilities.sanitzeStringArr(this.consignmentAttributes.salesChannel),
501
+ thirdPartySalesChannels: (() => {
502
+ const channels = [];
503
+ if (this.attributes.shopifyId)
504
+ channels.push('shopify');
505
+ if (this.attributes.traderaId)
506
+ channels.push('tradera');
507
+ return channels;
508
+ })(),
496
509
  status: this.utilities.sanitizeString(this.consignmentAttributes.status),
497
510
  tags: this.utilities.sanitzeStringArr(this.filterAttributes.tags),
498
511
  systemTags: this.utilities.sanitzeStringArr(this.filterAttributes.systemTags),
@@ -547,9 +560,12 @@ class Product extends Base_1.default {
547
560
  description: this.utilities.sanitizeString(this.attributes.description),
548
561
  discountType: this.utilities.sanitizeString(this.consignmentAttributes.discountType),
549
562
  discountValue: this.utilities.sanitizeNumber(this.consignmentAttributes.discountValue, 0),
563
+ stockStatus: 'Unknown',
564
+ stockStatusTimestamp: null,
550
565
  id: this.utilities.sanitizeString(this.filterAttributes.documentId),
551
566
  documentId: this.utilities.sanitizeString(this.filterAttributes.documentId),
552
567
  shopifyId: this.utilities.sanitizeString(this.attributes.shopifyId),
568
+ traderaId: this.utilities.sanitizeString(this.attributes.traderaId),
553
569
  gender: this.utilities.sanitizeString(this.filterAttributes.gender),
554
570
  handle: this.utilities.sanitizeString(this.attributes.handle),
555
571
  imageUrls: this.utilities.sanitzeStringArr(this.attributes.imageUrls),
@@ -560,7 +576,14 @@ class Product extends Base_1.default {
560
576
  ? this.consignmentAttributes.inventoryLocations.map((c) => String(c.id))
561
577
  : [],
562
578
  productClass: this.utilities.sanitizeString(this.attributes.productClass),
579
+ stockTakeLatestTimestamp: null,
580
+ stockTakeFirstTimestamp: null,
563
581
  };
582
+ const stockDerivations = this.deriveStockStatusFromSystemTags();
583
+ stagedObj.stockStatus = stockDerivations.stockStatus;
584
+ stagedObj.stockStatusTimestamp = this.utilities.sanitizeMillisTimeStamp(stockDerivations.stockStatusTimestamp);
585
+ stagedObj.stockTakeFirstTimestamp = this.utilities.sanitizeMillisTimeStamp(stockDerivations.stockTakeFirstTimestamp);
586
+ stagedObj.stockTakeLatestTimestamp = this.utilities.sanitizeMillisTimeStamp(stockDerivations.stockTakeLatestTimestamp);
564
587
  if (((_a = this.consignmentAttributes) === null || _a === void 0 ? void 0 : _a.inventoryLocations) &&
565
588
  Array.isArray((_b = this.consignmentAttributes) === null || _b === void 0 ? void 0 : _b.inventoryLocations)) {
566
589
  this.consignmentAttributes.inventoryLocations.forEach((l) => {
@@ -577,6 +600,64 @@ class Product extends Base_1.default {
577
600
  });
578
601
  return stagedObj;
579
602
  }
603
+ deriveStockStatusFromSystemTags() {
604
+ const systemTags = Array.isArray(this.filterAttributes.systemTags) ? this.filterAttributes.systemTags : [];
605
+ const stockTakeTags = systemTags.filter((t) => typeof t === 'string' && t.startsWith('stock-take|'));
606
+ const inTransitTags = systemTags.filter((t) => typeof t === 'string' && t.startsWith('in-transit|'));
607
+ const parseLatestAndFirstTs = (tags) => {
608
+ let latest = 0;
609
+ let first = 0;
610
+ tags.forEach((tag) => {
611
+ const parts = String(tag).split('|');
612
+ let timestampMs = null;
613
+ parts.forEach((p) => {
614
+ if (p.startsWith('ts=')) {
615
+ const parsed = Number(p.substring(3));
616
+ if (!isNaN(parsed)) {
617
+ timestampMs = parsed;
618
+ }
619
+ }
620
+ });
621
+ if (timestampMs != null) {
622
+ const ts = this.utilities.sanitizeMillisTimeStamp(timestampMs);
623
+ if (ts > latest)
624
+ latest = ts;
625
+ if (first === 0 || ts < first)
626
+ first = ts;
627
+ }
628
+ });
629
+ return { latest, first };
630
+ };
631
+ const stockTakeLatest = parseLatestAndFirstTs(stockTakeTags).latest;
632
+ const inTransitLatest = parseLatestAndFirstTs(inTransitTags).latest;
633
+ const stockTakeLatestSan = stockTakeLatest ? this.utilities.sanitizeMillisTimeStamp(stockTakeLatest) : null;
634
+ const stockTakeFirstRaw = stockTakeTags.length ? parseLatestAndFirstTs(stockTakeTags).first : 0;
635
+ const stockTakeFirstSan = stockTakeFirstRaw ? this.utilities.sanitizeMillisTimeStamp(stockTakeFirstRaw) : null;
636
+ let stockStatus = 'Unknown';
637
+ let stockStatusTimestamp = null;
638
+ if (stockTakeLatest === 0 && inTransitLatest === 0) {
639
+ stockStatus = 'Unknown';
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
+ this.timestampAttributes.stockTakeFirstTimestamp = stockTakeFirstSan;
653
+ this.timestampAttributes.stockTakeLatestTimestamp = stockTakeLatestSan;
654
+ return {
655
+ stockTakeFirstTimestamp: stockTakeFirstSan,
656
+ stockTakeLatestTimestamp: stockTakeLatestSan,
657
+ stockStatus,
658
+ stockStatusTimestamp,
659
+ };
660
+ }
580
661
  buildUpdatedFieldsForSalesChannel() {
581
662
  return {
582
663
  title: this.attributes.title,
@@ -971,6 +1052,12 @@ class Product extends Base_1.default {
971
1052
  name: 'salesChannel',
972
1053
  type: 'string[]',
973
1054
  },
1055
+ {
1056
+ facet: true,
1057
+ optional: true,
1058
+ name: 'thirdPartySalesChannels',
1059
+ type: 'string[]',
1060
+ },
974
1061
  {
975
1062
  facet: true,
976
1063
  name: 'status',
@@ -1066,6 +1153,12 @@ class Product extends Base_1.default {
1066
1153
  name: 'shopifyId',
1067
1154
  type: 'string',
1068
1155
  },
1156
+ {
1157
+ facet: false,
1158
+ optional: true,
1159
+ name: 'traderaId',
1160
+ type: 'string',
1161
+ },
1069
1162
  {
1070
1163
  facet: true,
1071
1164
  name: 'gender',
@@ -1123,6 +1216,12 @@ class Product extends Base_1.default {
1123
1216
  name: 'inventoryLocations..*.incomingAmount',
1124
1217
  type: 'int32',
1125
1218
  },
1219
+ {
1220
+ facet: true,
1221
+ optional: true,
1222
+ name: 'stockStatus',
1223
+ type: 'string',
1224
+ },
1126
1225
  {
1127
1226
  facet: true,
1128
1227
  optional: true,
@@ -3,6 +3,7 @@ type ProductAttributes = {
3
3
  description: string;
4
4
  handle: string;
5
5
  shopifyId: string;
6
+ traderaId?: string;
6
7
  title: string;
7
8
  coverPhotoUrl: string;
8
9
  imageUrls: string[];
@@ -56,6 +57,7 @@ type ProductFilterAttributes = {
56
57
  primaryAgeCategory: string;
57
58
  tags?: string[];
58
59
  systemTags?: string[];
60
+ stockStatus?: string;
59
61
  };
60
62
  type ProductConsignmentAttributes = {
61
63
  sellRequestImageUrls: string[];
@@ -119,6 +121,9 @@ type ProductTimestampAttributes = {
119
121
  hiddenTimestamp: number | null;
120
122
  bookedTimestamp: number | null;
121
123
  openTimestamp: number | null;
124
+ stockTakeFirstTimestamp: number | null;
125
+ stockTakeLatestTimestamp: number | null;
126
+ stockStatusTimestamp: number | null;
122
127
  };
123
128
  type TranslatableAttributes = {
124
129
  description: string;
@@ -321,6 +326,7 @@ type TypesenseProductObj = {
321
326
  rfidTag: string;
322
327
  sku: string;
323
328
  salesChannel: string[];
329
+ thirdPartySalesChannels: string[];
324
330
  status: string;
325
331
  tags: string[];
326
332
  systemTags: string[];
@@ -365,6 +371,8 @@ type TypesenseProductObj = {
365
371
  description: string;
366
372
  discountType: string;
367
373
  discountValue: number;
374
+ stockStatus: 'In stock' | 'In transit' | 'Unknown';
375
+ stockStatusTimestamp: number | null;
368
376
  id: string;
369
377
  documentId: string;
370
378
  gender: string;
@@ -372,6 +380,8 @@ type TypesenseProductObj = {
372
380
  imageUrls: string[];
373
381
  sellRequestImageUrls: string[];
374
382
  reservedBy: string[];
383
+ stockTakeLatestTimestamp: number | null;
384
+ stockTakeFirstTimestamp: number | null;
375
385
  'inventoryLocations.ids': string[];
376
386
  'materialComposition.names': string[];
377
387
  createdAtDay: string;
@@ -384,6 +394,8 @@ type TypesenseProductObj = {
384
394
  payoutSystem: 'STRIPE' | 'MANUAL_TRANSFER' | 'RIBBN_CREDITS' | null;
385
395
  payoutReference: string;
386
396
  productClass: string;
397
+ shopifyId: string;
398
+ traderaId: string;
387
399
  [key: string]: any;
388
400
  };
389
401
  type GoogleMerchantCenterProductObj = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "4.6.3",
3
+ "version": "4.6.5",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",