@things-factory/integration-sellercraft 4.1.40 → 4.2.0

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.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ORDER_STATUS = void 0;
4
4
  exports.ORDER_STATUS = {
5
- pending: 'PENDING_PAYMENT',
5
+ pending: 'PAYMENT_PENDING',
6
6
  processing: 'CONFIRMED',
7
7
  completed: 'DELIVERED',
8
8
  cancelled: 'CANCELLED'
@@ -8,27 +8,7 @@ function ingestChannelCategories() {
8
8
  path: '/channel/ingest/category',
9
9
  denormalize(req) {
10
10
  const { categories } = req;
11
- let newCategories = categories.map(category => {
12
- return {
13
- native_category_id: category.categoryId.toString(),
14
- channel_code: category.channelCode,
15
- channel_country: category.countryCode,
16
- category_name: category.categoryName,
17
- is_leaf: category.isLeaf,
18
- is_active: category.isActive,
19
- children_categories: category.childrenCategories.map(childrenCategory => {
20
- return {
21
- native_category_id: category.categoryId.toString(),
22
- channel_code: category.channelCode,
23
- channel_country: category.countryCode,
24
- category_name: childrenCategory.categoryName,
25
- is_leaf: childrenCategory.isLeaf,
26
- is_active: childrenCategory.isActive,
27
- children_categories: []
28
- };
29
- })
30
- };
31
- });
11
+ let newCategories = mapCategories(categories);
32
12
  return {
33
13
  payload: [...newCategories]
34
14
  };
@@ -39,4 +19,20 @@ function ingestChannelCategories() {
39
19
  };
40
20
  }
41
21
  exports.ingestChannelCategories = ingestChannelCategories;
22
+ function mapCategories(categories) {
23
+ if (!categories)
24
+ return null;
25
+ categories = categories.map(category => {
26
+ return {
27
+ native_category_id: category.categoryId.toString(),
28
+ channel_code: category.channelCode,
29
+ channel_country: category.countryCode,
30
+ category_name: category.categoryName,
31
+ is_leaf: category.isLeaf,
32
+ is_active: category.isActive,
33
+ children_categories: mapCategories(category.childrenCategories)
34
+ };
35
+ });
36
+ return categories;
37
+ }
42
38
  //# sourceMappingURL=ingest-channel-categories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ingest-channel-categories.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.ts"],"names":[],"mappings":";AAAA,+FAA+F;;;AAE/F,SAAgB,uBAAuB;IACrC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,0BAA0B;QAChC,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;YAE1B,IAAI,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;gBAC5C,OAAO;oBACL,kBAAkB,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE;oBAClD,YAAY,EAAE,QAAQ,CAAC,WAAW;oBAClC,eAAe,EAAE,QAAQ,CAAC,WAAW;oBACrC,aAAa,EAAE,QAAQ,CAAC,YAAY;oBACpC,OAAO,EAAE,QAAQ,CAAC,MAAM;oBACxB,SAAS,EAAE,QAAQ,CAAC,QAAQ;oBAC5B,mBAAmB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE;wBACtE,OAAO;4BACL,kBAAkB,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE;4BAClD,YAAY,EAAE,QAAQ,CAAC,WAAW;4BAClC,eAAe,EAAE,QAAQ,CAAC,WAAW;4BACrC,aAAa,EAAE,gBAAgB,CAAC,YAAY;4BAC5C,OAAO,EAAE,gBAAgB,CAAC,MAAM;4BAChC,SAAS,EAAE,gBAAgB,CAAC,QAAQ;4BACpC,mBAAmB,EAAE,EAAE;yBACxB,CAAA;oBACH,CAAC,CAAC;iBACH,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,OAAO;gBACL,OAAO,EAAE,CAAC,GAAG,aAAa,CAAC;aAC5B,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AArCD,0DAqCC"}
1
+ {"version":3,"file":"ingest-channel-categories.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.ts"],"names":[],"mappings":";AAAA,+FAA+F;;;AAE/F,SAAgB,uBAAuB;IACrC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,0BAA0B;QAChC,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;YAE1B,IAAI,aAAa,GAAG,aAAa,CAAC,UAAU,CAAC,CAAA;YAE7C,OAAO;gBACL,OAAO,EAAE,CAAC,GAAG,aAAa,CAAC;aAC5B,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAjBD,0DAiBC;AAED,SAAS,aAAa,CAAC,UAAU;IAC/B,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAA;IAC5B,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;QACrC,OAAO;YACL,kBAAkB,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE;YAClD,YAAY,EAAE,QAAQ,CAAC,WAAW;YAClC,eAAe,EAAE,QAAQ,CAAC,WAAW;YACrC,aAAa,EAAE,QAAQ,CAAC,YAAY;YACpC,OAAO,EAAE,QAAQ,CAAC,MAAM;YACxB,SAAS,EAAE,QAAQ,CAAC,QAAQ;YAC5B,mBAAmB,EAAE,aAAa,CAAC,QAAQ,CAAC,kBAAkB,CAAC;SAChE,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,UAAU,CAAA;AACnB,CAAC"}
@@ -14,9 +14,12 @@ function ingestChannelProduct() {
14
14
  seller_sku: variant.variationSku,
15
15
  native_variant_id: variant.variationId.toString(),
16
16
  label: variant.name,
17
- is_enabled: variant.isEnabled,
18
- is_sellable: variant.isSellable,
17
+ is_enabled: variant.isEnabled || true,
18
+ is_sellable: variant.isSellable || true,
19
19
  is_deleted: false,
20
+ variant_attributes: (variant === null || variant === void 0 ? void 0 : variant.attributes.map(attribute => {
21
+ return Object.assign(Object.assign({}, attribute), { native_attribute_id: attribute.native_attribute_id.toString() });
22
+ })) || [],
20
23
  stock_locked: (variant === null || variant === void 0 ? void 0 : variant.stockLocked) ? variant.stockLocked : 0,
21
24
  native_stock_reported: (variant === null || variant === void 0 ? void 0 : variant.stockReported) ? variant.stockReported : 0,
22
25
  price_full: variant.fullPrice || 0,
@@ -24,7 +27,7 @@ function ingestChannelProduct() {
24
27
  inventory_products: (variant === null || variant === void 0 ? void 0 : variant.inventoryProducts)
25
28
  ? variant.inventoryProducts.map(inventoryProduct => {
26
29
  return {
27
- quantity: inventoryProduct.qty || 0,
30
+ quantity: inventoryProduct.qty || 1,
28
31
  name: inventoryProduct.name,
29
32
  inventory_sku: inventoryProduct.sku,
30
33
  product_versions: (inventoryProduct === null || inventoryProduct === void 0 ? void 0 : inventoryProduct.productVersions)
@@ -56,13 +59,16 @@ function ingestChannelProduct() {
56
59
  native_product_id: product.productId.toString(),
57
60
  label: product.name,
58
61
  brand: product.brand || '',
59
- is_verified: product.isVerified,
62
+ is_verified: product.isVerified || true,
60
63
  flexible_attributes: product.channelCode == 'WCM' ? true : false,
61
- images: product.images.map(image => {
64
+ images: product === null || product === void 0 ? void 0 : product.images.map(image => {
62
65
  return {
63
66
  file_url: image.url
64
67
  };
65
68
  }),
69
+ product_attributes: product === null || product === void 0 ? void 0 : product.attributes.map(attribute => {
70
+ return Object.assign(Object.assign({}, attribute), { native_attribute_id: attribute.native_attribute_id.toString() });
71
+ }),
66
72
  variants: productVariations
67
73
  };
68
74
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ingest-channel-product.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts"],"names":[],"mappings":";AAAA,+FAA+F;;;AAE/F,SAAgB,oBAAoB;IAClC,OA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AC/C,KAAK,EAAE,OAAO,CAAC,IAAI;oBACnB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;oBAC1B,WAAW,EAAE,OAAO,CAAC,UAAU;oBAC/B,mBAAmB,EAAE,OAAO,CAAC,WAAW,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;oBAChE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;wBACjC,OAAO;4BACL,QAAQ,EAAE,KAAK,CAAC,GAAG;yBACpB,CAAA;oBACH,CAAC,CAAC;oBACF,QAAQ,EAAE,iBAAiB;iBAC5B,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,OAAO;gBACL,OAAO,EAAE,CAAC,GAAG,WAAW,CAAC;aAC1B,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AA3ED,oDA2EC"}
1
+ {"version":3,"file":"ingest-channel-product.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts"],"names":[],"mappings":";AAAA,+FAA+F;;;AAE/F,SAAgB,oBAAoB;IAClC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;YAExB,IAAI,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;gBACvC,IAAI,iBAAiB,GAAU,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;oBAC9D,OAAO;wBACL,UAAU,EAAE,OAAO,CAAC,YAAY;wBAChC,iBAAiB,EAAE,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE;wBACjD,KAAK,EAAE,OAAO,CAAC,IAAI;wBACnB,UAAU,EAAE,OAAO,CAAC,SAAS,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AC,CAAC,CAAC,KAAK;oBAChE,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;wBAClC,OAAO;4BACL,QAAQ,EAAE,KAAK,CAAC,GAAG;yBACpB,CAAA;oBACH,CAAC,CAAC;oBACF,kBAAkB,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;wBACtD,uCACK,SAAS,KACZ,mBAAmB,EAAE,SAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAC9D;oBACH,CAAC,CAAC;oBACF,QAAQ,EAAE,iBAAiB;iBAC5B,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,OAAO;gBACL,OAAO,EAAE,CAAC,GAAG,WAAW,CAAC;aAC1B,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAvFD,oDAuFC"}
@@ -43,12 +43,13 @@ let MarketplaceChannelOrderMutation = class MarketplaceChannelOrderMutation {
43
43
  accessKey: shops[j].credential.consumer_key,
44
44
  accessSecret: shops[j].credential.consumer_secret,
45
45
  storeURL: shops[j].credential.store_url,
46
- platform: channels[i].name
46
+ platform: channels[i].name,
47
+ accessToken: shops[j].credential.access_token // Magento+
47
48
  };
48
49
  // let countryCode = shops[j].country_code
49
50
  // let channelCode = shops[j].org_prefix
50
- let organisationId = shops[j].credential.account_id;
51
- let channelShopId = shops[j].credential.channel_shop_id;
51
+ let organisationId = shops[j].account_id;
52
+ let channelShopId = shops[j].channel_shop_id;
52
53
  const orderReq = {
53
54
  fromDate: fromDate,
54
55
  toDate: toDate
@@ -57,10 +58,10 @@ let MarketplaceChannelOrderMutation = class MarketplaceChannelOrderMutation {
57
58
  var sellercraftStore = Object.assign(Object.assign({}, store), { platform: 'sellercraftChannelIntegration' });
58
59
  let mappedOrderResult = orderResult.results.map(order => {
59
60
  let { firstName: custFirstName, lastName: custLastName, orderCreatedAt: createdAt, orderUpdatedAt: updatedAt, orderNo: id, status } = order;
60
- let { first_name: billFirstName, last_name: billLastName, address_1: billAddress1, address_2: billAddress2, address_3: billAddress3, address_4: billAddress4, address_5: billAddress5, city: billCity, postcode: billPostalCode, country: billCountry, phone: billPhone1, phone_2: billPhone2 } = order.billing;
61
+ let { first_name: billFirstName, last_name: billLastName, address_1: billAddress1, address_2: billAddress2, address_3: billAddress3, address_4: billAddress4, address_5: billAddress5, city: billCity, postcode: billPostalCode, country: billCountry, phone: billPhone1, phone_2: billPhone2 } = order === null || order === void 0 ? void 0 : order.billing;
61
62
  let { first_name: shipFirstName, last_name: shipLastName, address_1: shipAddress1, address_2: shipAddress2, address_3: shipAddress3, address_4: shipAddress4, address_5: shipAddress5, city: shipCity, postcode: shipPostalCode, country: shipCountry, phone: shipPhone1, phone_2: shipPhone2 } = order.shipping;
62
63
  let orderItems = order.orderItems.map(item => {
63
- let { name: id, variationId: variationId, slaExpiresAt, total, totalTax, subtotal, subtotalTax } = item;
64
+ let { name: id, variationId: variationId, slaExpiresAt, total, totalTax, subtotal, subtotalTax, qty } = item;
64
65
  return {
65
66
  id,
66
67
  variationId,
@@ -79,9 +80,16 @@ let MarketplaceChannelOrderMutation = class MarketplaceChannelOrderMutation {
79
80
  nettAmount: subtotalTax
80
81
  }
81
82
  ],
82
- slaExpiresAt
83
+ slaExpiresAt,
84
+ qty
83
85
  };
84
86
  });
87
+ let mappedOrderItems = [];
88
+ orderItems.map(oi => {
89
+ for (let i = 0; i < oi.qty; i++) {
90
+ mappedOrderItems.push(Object.assign(Object.assign({}, oi), { id: `${oi.id}-${i + 1}` }));
91
+ }
92
+ });
85
93
  return {
86
94
  custFirstName,
87
95
  custLastName,
@@ -90,19 +98,19 @@ let MarketplaceChannelOrderMutation = class MarketplaceChannelOrderMutation {
90
98
  id,
91
99
  billFirstName,
92
100
  billLastName,
93
- billAddress1,
94
- billAddress2,
95
- billAddress3,
96
- billAddress4,
97
- billAddress5,
98
- billCity,
99
- billPostalCode,
100
- billCountry,
101
- billPhone1,
102
- billPhone2,
101
+ billAddress1: billAddress1.toString() || shipAddress1.toString(),
102
+ billAddress2: billAddress2 || shipAddress2,
103
+ billAddress3: billAddress3 || shipAddress3,
104
+ billAddress4: billAddress4 || shipAddress4,
105
+ billAddress5: billAddress5 || shipAddress5,
106
+ billCity: billCity || shipCity,
107
+ billPostalCode: billPostalCode || shipPostalCode,
108
+ billCountry: billCountry || shipCountry,
109
+ billPhone1: billPhone1 || shipPhone1,
110
+ billPhone2: billPhone2 || shipPhone2,
103
111
  shipFirstName,
104
112
  shipLastName,
105
- shipAddress1,
113
+ shipAddress1: shipAddress1.toString(),
106
114
  shipAddress2,
107
115
  shipAddress3,
108
116
  shipAddress4,
@@ -112,7 +120,7 @@ let MarketplaceChannelOrderMutation = class MarketplaceChannelOrderMutation {
112
120
  shipCountry,
113
121
  shipPhone1,
114
122
  shipPhone2,
115
- orderItems,
123
+ mappedOrderItems,
116
124
  channelShopId,
117
125
  organisationId,
118
126
  status
@@ -1 +1 @@
1
- {"version":3,"file":"marketplace-channel-order-mutation.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel-order-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAA2D;AAC3D,qCAAuC;AAEvC,+DAA0D;AAE1D,6CAA4C;AAC5C,qFAAkE;AAClE,+GAAwG;AAGxG,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IAE1C,KAAK,CAAC,+BAA+B,CAClB,QAAgB,EAClB,MAAc,EACtB,OAAY;QAEnB,MAAM,mCAAmC,GAAG,YAAM,CAAC,GAAG,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAA;QACjG,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,qBAAqB,EAAE,GAAG,mCAAmC,CAAA;QAE/F,MAAM,QAAQ,GAAyB,MAAM,IAAA,uBAAa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ACZ;IACH,CAAC;CACF,CAAA;AA7JC;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IAE1B,WAAA,IAAA,kBAAG,EAAC,UAAU,CAAC,CAAA;IACf,WAAA,IAAA,kBAAG,EAAC,QAAQ,CAAC,CAAA;IACb,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;sFAyJP;AA9JU,+BAA+B;IAD3C,IAAA,uBAAQ,GAAE;GACE,+BAA+B,CA+J3C;AA/JY,0EAA+B"}
1
+ {"version":3,"file":"marketplace-channel-order-mutation.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel-order-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAA2D;AAC3D,qCAAuC;AAEvC,+DAA0D;AAE1D,6CAA4C;AAC5C,qFAAkE;AAClE,+GAAwG;AAGxG,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IAE1C,KAAK,CAAC,+BAA+B,CAClB,QAAgB,EAClB,MAAc,EACtB,OAAY;QAEnB,MAAM,mCAAmC,GAAG,YAAM,CAAC,GAAG,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAA;QACjG,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,qBAAqB,EAAE,GAAG,mCAAmC,CAAA;QAE/F,MAAM,QAAQ,GAAyB,MAAM,IAAA,uBAAa,EAAC,wCAAkB,CAAC,CAAC,IAAI,EAAE,CAAA;QAErF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxC,IAAI,gBAAgB,GAAG,qBAAqB,GAAG,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;YACrF,MAAM,eAAe,GAAQ,MAAM,KAAK,CAAC,gBAAgB,EAAE;gBACzD,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,W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,EAAE;wBACrC,YAAY;wBACZ,YAAY;wBACZ,YAAY;wBACZ,YAAY;wBACZ,QAAQ;wBACR,cAAc;wBACd,WAAW;wBACX,UAAU;wBACV,UAAU;wBACV,gBAAgB;wBAChB,aAAa;wBACb,cAAc;wBACd,MAAM;qBACP,CAAA;gBACH,CAAC,CAAC,CAAA;gBAEF,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;oBAChC,MAAM,sEAAgC,CAAC,kBAAkB,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAA;iBAC3G;aACF;YAED,OAAO,IAAI,CAAA;SACZ;IACH,CAAC;CACF,CAAA;AAzKC;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IAE1B,WAAA,IAAA,kBAAG,EAAC,UAAU,CAAC,CAAA;IACf,WAAA,IAAA,kBAAG,EAAC,QAAQ,CAAC,CAAA;IACb,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;sFAqKP;AA1KU,+BAA+B;IAD3C,IAAA,uBAAQ,GAAE;GACE,+BAA+B,CA2K3C;AA3KY,0EAA+B"}
@@ -43,7 +43,8 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
43
43
  accessKey: shops[j].credential.consumer_key,
44
44
  accessSecret: shops[j].credential.consumer_secret,
45
45
  storeURL: shops[j].credential.store_url,
46
- platform: channels[i].name
46
+ platform: channels[i].name,
47
+ accessToken: shops[j].credential.access_token // Magento+
47
48
  };
48
49
  let countryCode = shops[j].country_code;
49
50
  let channelCode = shops[j].org_prefix;
@@ -86,7 +87,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
86
87
  ]
87
88
  };
88
89
  });
89
- images = images.map(image => {
90
+ images = images === null || images === void 0 ? void 0 : images.map(image => {
90
91
  return {
91
92
  url: image
92
93
  };
@@ -115,11 +116,15 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
115
116
  isLeaf: parent == 0 ? false : true,
116
117
  isActive: isActive || true,
117
118
  channelCode,
118
- countryCode
119
+ countryCode,
120
+ childrenCategories: []
119
121
  };
120
122
  });
121
- mappedCategories.map(category => {
122
- category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId);
123
+ mappedCategories = mappedCategories.map(category => {
124
+ if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
125
+ category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId);
126
+ }
127
+ return category;
123
128
  });
124
129
  await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
125
130
  categories: mappedCategories
@@ -1 +1 @@
1
- {"version":3,"file":"marketplace-channel-product-mutation.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel-product-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsD;AACtD,qCAAuC;AAEvC,+DAA0D;AAE1D,6CAA4C;AAC5C,qFAAkE;AAClE,+GAAwG;AAGxG,IAAa,iCAAiC,GAA9C,MAAa,iCAAiC;IAE5C,KAAK,CAAC,iCAAiC,CAAQ,OAAY;QACzD,MAAM,mCAAmC,GAAG,YAAM,CAAC,GAAG,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAA;QACjG,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,qBAAqB,EAAE,GAAG,mCAAmC,CAAA;QAE/F,MAAM,QAAQ,GAAyB,MAAM,IAAA,uBAAa,EAAC,wCAAkB,CAAC,CAAC,IAAI,EAAE,CAAA;QAErF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxC,IAAI,gBAAgB,GAAG,qBAAqB,GAAG,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;YACrF,MAAM,eAAe,GAAQ,MAAM,KAAK,CAAC,gBAAgB,EAAE;gBACzD,MAA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AAO,CAAC;IACY,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;0FA8I7C;AAhJU,iCAAiC;IAD7C,IAAA,uBAAQ,GAAE;GACE,iCAAiC,CAiJ7C;AAjJY,8EAAiC"}
1
+ {"version":3,"file":"marketplace-channel-product-mutation.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel-product-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsD;AACtD,qCAAuC;AAEvC,+DAA0D;AAE1D,6CAA4C;AAC5C,qFAAkE;AAClE,+GAAwG;AAGxG,IAAa,iCAAiC,GAA9C,MAAa,iCAAiC;IAE5C,KAAK,CAAC,iCAAiC,CAAQ,OAAY;QACzD,MAAM,mCAAmC,GAAG,YAAM,CAAC,GAAG,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAA;QACjG,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,qBAAqB,EAAE,GAAG,mCAAmC,CAAA;QAE/F,MAAM,QAAQ,GAAyB,MAAM,IAAA,uBAAa,EAAC,wCAAkB,CAAC,CAAC,IAAI,EAAE,CAAA;QAErF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxC,IAAI,gBAAgB,GAAG,qBAAqB,GAAG,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;YACrF,MAAM,eAAe,GAAQ,MAAM,KAAK,CAAC,gBAAgB,EAAE;gBACzD,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,WAAW,EAAE,MAAM;iBACpB;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE;gBACvB,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;aACjC;YACD,IAAI,aAAa,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,CAAA;YAChD,IAAI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IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IACY,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;0FAmJ7C;AArJU,iCAAiC;IAD7C,IAAA,uBAAQ,GAAE;GACE,iCAAiC,CAsJ7C;AAtJY,8EAAiC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-sellercraft",
3
- "version": "4.1.40",
3
+ "version": "4.2.0",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -31,7 +31,7 @@
31
31
  "@things-factory/context-ui": "^4.1.40",
32
32
  "@things-factory/grist-ui": "^4.1.40",
33
33
  "@things-factory/i18n-base": "^4.1.40",
34
- "@things-factory/integration-marketplace": "^4.1.40",
34
+ "@things-factory/integration-marketplace": "^4.2.0",
35
35
  "@things-factory/integration-ui": "^4.1.40",
36
36
  "@things-factory/more-ui": "^4.1.40",
37
37
  "@things-factory/resource-ui": "^4.1.40",
@@ -51,5 +51,5 @@
51
51
  "nock": "^13.0.2",
52
52
  "should": "^13.2.3"
53
53
  },
54
- "gitHead": "060b5c664e80a6fcba09598f2c7ceffe067e02bf"
54
+ "gitHead": "ea20ff47ca0caa48313ae9d7c527e866f7eb1571"
55
55
  }
@@ -1,5 +1,5 @@
1
1
  export const ORDER_STATUS = {
2
- pending: 'PENDING_PAYMENT',
2
+ pending: 'PAYMENT_PENDING',
3
3
  processing: 'CONFIRMED',
4
4
  completed: 'DELIVERED',
5
5
  cancelled: 'CANCELLED'
@@ -7,27 +7,7 @@ export function ingestChannelCategories() {
7
7
  denormalize(req) {
8
8
  const { categories } = req
9
9
 
10
- let newCategories = categories.map(category => {
11
- return {
12
- native_category_id: category.categoryId.toString(),
13
- channel_code: category.channelCode,
14
- channel_country: category.countryCode,
15
- category_name: category.categoryName,
16
- is_leaf: category.isLeaf,
17
- is_active: category.isActive,
18
- children_categories: category.childrenCategories.map(childrenCategory => {
19
- return {
20
- native_category_id: category.categoryId.toString(),
21
- channel_code: category.channelCode,
22
- channel_country: category.countryCode,
23
- category_name: childrenCategory.categoryName,
24
- is_leaf: childrenCategory.isLeaf,
25
- is_active: childrenCategory.isActive,
26
- children_categories: []
27
- }
28
- })
29
- }
30
- })
10
+ let newCategories = mapCategories(categories)
31
11
 
32
12
  return {
33
13
  payload: [...newCategories]
@@ -38,3 +18,19 @@ export function ingestChannelCategories() {
38
18
  }
39
19
  }
40
20
  }
21
+
22
+ function mapCategories(categories) {
23
+ if (!categories) return null
24
+ categories = categories.map(category => {
25
+ return {
26
+ native_category_id: category.categoryId.toString(),
27
+ channel_code: category.channelCode,
28
+ channel_country: category.countryCode,
29
+ category_name: category.categoryName,
30
+ is_leaf: category.isLeaf,
31
+ is_active: category.isActive,
32
+ children_categories: mapCategories(category.childrenCategories)
33
+ }
34
+ })
35
+ return categories
36
+ }
@@ -13,9 +13,15 @@ export function ingestChannelProduct() {
13
13
  seller_sku: variant.variationSku,
14
14
  native_variant_id: variant.variationId.toString(),
15
15
  label: variant.name,
16
- is_enabled: variant.isEnabled,
17
- is_sellable: variant.isSellable,
16
+ is_enabled: variant.isEnabled || true,
17
+ is_sellable: variant.isSellable || true,
18
18
  is_deleted: false, // default
19
+ variant_attributes: variant?.attributes.map(attribute => {
20
+ return {
21
+ ...attribute,
22
+ native_attribute_id: attribute.native_attribute_id.toString()
23
+ }
24
+ }) || [],
19
25
  stock_locked: variant?.stockLocked ? variant.stockLocked : 0,
20
26
  native_stock_reported: variant?.stockReported ? variant.stockReported : 0,
21
27
  price_full: variant.fullPrice || 0,
@@ -23,7 +29,7 @@ export function ingestChannelProduct() {
23
29
  inventory_products: variant?.inventoryProducts
24
30
  ? variant.inventoryProducts.map(inventoryProduct => {
25
31
  return {
26
- quantity: inventoryProduct.qty || 0,
32
+ quantity: inventoryProduct.qty || 1,
27
33
  name: inventoryProduct.name,
28
34
  inventory_sku: inventoryProduct.sku,
29
35
  product_versions: inventoryProduct?.productVersions
@@ -56,13 +62,19 @@ export function ingestChannelProduct() {
56
62
  native_product_id: product.productId.toString(),
57
63
  label: product.name,
58
64
  brand: product.brand || '',
59
- is_verified: product.isVerified,
65
+ is_verified: product.isVerified || true,
60
66
  flexible_attributes: product.channelCode == 'WCM' ? true : false, // add channels that do not support category_attributes ingestion
61
- images: product.images.map(image => {
67
+ images: product?.images.map(image => {
62
68
  return {
63
69
  file_url: image.url
64
70
  }
65
71
  }),
72
+ product_attributes: product?.attributes.map(attribute => {
73
+ return {
74
+ ...attribute,
75
+ native_attribute_id: attribute.native_attribute_id.toString()
76
+ }
77
+ }),
66
78
  variants: productVariations
67
79
  }
68
80
  })
@@ -41,13 +41,14 @@ export class MarketplaceChannelOrderMutation {
41
41
  accessKey: shops[j].credential.consumer_key,
42
42
  accessSecret: shops[j].credential.consumer_secret,
43
43
  storeURL: shops[j].credential.store_url,
44
- platform: channels[i].name
44
+ platform: channels[i].name,
45
+ accessToken: shops[j].credential.access_token // Magento+
45
46
  }
46
47
 
47
48
  // let countryCode = shops[j].country_code
48
49
  // let channelCode = shops[j].org_prefix
49
- let organisationId = shops[j].credential.account_id
50
- let channelShopId = shops[j].credential.channel_shop_id
50
+ let organisationId = shops[j].account_id
51
+ let channelShopId = shops[j].channel_shop_id
51
52
 
52
53
  const orderReq = {
53
54
  fromDate: fromDate,
@@ -80,7 +81,7 @@ export class MarketplaceChannelOrderMutation {
80
81
  country: billCountry,
81
82
  phone: billPhone1,
82
83
  phone_2: billPhone2
83
- } = order.billing
84
+ } = order?.billing
84
85
 
85
86
  let {
86
87
  first_name: shipFirstName,
@@ -98,7 +99,7 @@ export class MarketplaceChannelOrderMutation {
98
99
  } = order.shipping
99
100
 
100
101
  let orderItems = order.orderItems.map(item => {
101
- let { name: id, variationId: variationId, slaExpiresAt, total, totalTax, subtotal, subtotalTax } = item
102
+ let { name: id, variationId: variationId, slaExpiresAt, total, totalTax, subtotal, subtotalTax, qty } = item
102
103
 
103
104
  return {
104
105
  id,
@@ -118,10 +119,21 @@ export class MarketplaceChannelOrderMutation {
118
119
  nettAmount: subtotalTax
119
120
  }
120
121
  ],
121
- slaExpiresAt
122
+ slaExpiresAt,
123
+ qty
122
124
  }
123
125
  })
124
126
 
127
+ let mappedOrderItems = []
128
+ orderItems.map(oi => {
129
+ for (let i = 0; i < oi.qty; i++) {
130
+ mappedOrderItems.push({
131
+ ...oi,
132
+ id: `${oi.id}-${i+1}`
133
+ })
134
+ }
135
+ })
136
+
125
137
  return {
126
138
  custFirstName,
127
139
  custLastName,
@@ -130,19 +142,19 @@ export class MarketplaceChannelOrderMutation {
130
142
  id,
131
143
  billFirstName,
132
144
  billLastName,
133
- billAddress1,
134
- billAddress2,
135
- billAddress3,
136
- billAddress4,
137
- billAddress5,
138
- billCity,
139
- billPostalCode,
140
- billCountry,
141
- billPhone1,
142
- billPhone2,
145
+ billAddress1: billAddress1.toString() || shipAddress1.toString(),
146
+ billAddress2: billAddress2 || shipAddress2,
147
+ billAddress3: billAddress3 || shipAddress3,
148
+ billAddress4: billAddress4 || shipAddress4,
149
+ billAddress5: billAddress5 || shipAddress5,
150
+ billCity: billCity || shipCity,
151
+ billPostalCode: billPostalCode || shipPostalCode,
152
+ billCountry: billCountry || shipCountry,
153
+ billPhone1: billPhone1 || shipPhone1,
154
+ billPhone2: billPhone2 || shipPhone2,
143
155
  shipFirstName,
144
156
  shipLastName,
145
- shipAddress1,
157
+ shipAddress1: shipAddress1.toString(),
146
158
  shipAddress2,
147
159
  shipAddress3,
148
160
  shipAddress4,
@@ -152,7 +164,7 @@ export class MarketplaceChannelOrderMutation {
152
164
  shipCountry,
153
165
  shipPhone1,
154
166
  shipPhone2,
155
- orderItems,
167
+ mappedOrderItems,
156
168
  channelShopId,
157
169
  organisationId,
158
170
  status
@@ -37,7 +37,8 @@ export class MarketplaceChannelProductMutation {
37
37
  accessKey: shops[j].credential.consumer_key,
38
38
  accessSecret: shops[j].credential.consumer_secret,
39
39
  storeURL: shops[j].credential.store_url,
40
- platform: channels[i].name
40
+ platform: channels[i].name,
41
+ accessToken: shops[j].credential.access_token // Magento+
41
42
  }
42
43
 
43
44
  let countryCode = shops[j].country_code
@@ -103,7 +104,7 @@ export class MarketplaceChannelProductMutation {
103
104
  }
104
105
  })
105
106
 
106
- images = images.map(image => {
107
+ images = images?.map(image => {
107
108
  return {
108
109
  url: image
109
110
  }
@@ -135,12 +136,16 @@ export class MarketplaceChannelProductMutation {
135
136
  isLeaf: parent == 0 ? false : true,
136
137
  isActive: isActive || true,
137
138
  channelCode,
138
- countryCode
139
+ countryCode,
140
+ childrenCategories: []
139
141
  }
140
142
  })
141
143
 
142
- mappedCategories.map(category => {
143
- category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId)
144
+ mappedCategories = mappedCategories.map(category => {
145
+ if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
146
+ category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId)
147
+ }
148
+ return category
144
149
  })
145
150
 
146
151
  await SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {