@things-factory/integration-sellercraft 4.2.5 → 4.2.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.
Files changed (22) hide show
  1. package/dist-server/constants/order-status-mapping.js +11 -1
  2. package/dist-server/constants/order-status-mapping.js.map +1 -1
  3. package/dist-server/constants/platform.js +2 -1
  4. package/dist-server/constants/platform.js.map +1 -1
  5. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js +1 -1
  6. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js.map +1 -1
  7. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js +5 -4
  8. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js.map +1 -1
  9. package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js +8 -4
  10. package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js.map +1 -1
  11. package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js +253 -243
  12. package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js.map +1 -1
  13. package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js +30 -16
  14. package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js.map +1 -1
  15. package/package.json +3 -3
  16. package/server/constants/order-status-mapping.ts +11 -1
  17. package/server/constants/platform.ts +2 -1
  18. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.ts +1 -1
  19. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts +13 -11
  20. package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts +8 -4
  21. package/server/service/marketplace-channel/marketplace-channel-order-mutation.ts +303 -282
  22. package/server/service/marketplace-channel/marketplace-channel-product-mutation.ts +30 -28
@@ -15,12 +15,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.MarketplaceChannelProductMutation = void 0;
16
16
  const type_graphql_1 = require("type-graphql");
17
17
  const typeorm_1 = require("typeorm");
18
- const marketplace_channel_1 = require("./marketplace-channel");
19
18
  const env_1 = require("@things-factory/env");
20
19
  const integration_marketplace_1 = require("@things-factory/integration-marketplace");
21
20
  const sellercraft_channel_integration_api_1 = require("../../controllers/sellercraft-channel-integration-api");
21
+ const marketplace_channel_1 = require("./marketplace-channel");
22
22
  let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation {
23
23
  async syncAllMarketplaceChannelProducts(context) {
24
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
24
25
  const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
25
26
  const { tokenCraftApiKey: apiKey, getShopsTokenCraftUrl } = sellercraftChannelIntegrationConfig;
26
27
  const channels = await (0, typeorm_1.getRepository)(marketplace_channel_1.MarketplaceChannel).find();
@@ -40,11 +41,12 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
40
41
  var shops = shopsResponse.shops;
41
42
  for (var j = 0; j < shops.length; j++) {
42
43
  var store = {
43
- accessKey: shops[j].credential.consumer_key,
44
- accessSecret: shops[j].credential.consumer_secret,
45
- storeURL: shops[j].credential.store_url,
44
+ accessKey: ((_b = (_a = shops[j]) === null || _a === void 0 ? void 0 : _a.credential) === null || _b === void 0 ? void 0 : _b.consumer_key) || '',
45
+ accessSecret: ((_d = (_c = shops[j]) === null || _c === void 0 ? void 0 : _c.credential) === null || _d === void 0 ? void 0 : _d.consumer_secret) || '',
46
+ storeURL: ((_f = (_e = shops[j]) === null || _e === void 0 ? void 0 : _e.credential) === null || _f === void 0 ? void 0 : _f.store_url) || '',
46
47
  platform: channels[i].name,
47
- accessToken: shops[j].credential.access_token // Magento+
48
+ accessToken: (_h = (_g = shops[j]) === null || _g === void 0 ? void 0 : _g.credential) === null || _h === void 0 ? void 0 : _h.access_token,
49
+ channelShopId: (_j = shops[j]) === null || _j === void 0 ? void 0 : _j.channel_shop_id
48
50
  };
49
51
  let countryCode = shops[j].country_code;
50
52
  let channelCode = shops[j].org_prefix;
@@ -68,7 +70,9 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
68
70
  let totalPagesCategory = 1;
69
71
  let limitCategory = 100;
70
72
  for (let page = 0; page < totalPagesCategory; page++) {
71
- const { results, total } = await integration_marketplace_1.StoreAPI.getStoreProductCategories(store, { pagination: { page, limitCategory } });
73
+ const { results, total } = await integration_marketplace_1.StoreAPI.getStoreProductCategories(store, {
74
+ pagination: { page, limitCategory }
75
+ });
72
76
  totalPagesCategory = Math.ceil(total / limitCategory);
73
77
  categoryResult.push(...results);
74
78
  }
@@ -76,7 +80,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
76
80
  var _a;
77
81
  let { categoryId, itemId: productId, name, brand, isVerified, images, attributes, variations } = item;
78
82
  variations = variations.map(variation => {
79
- let { variationSku, variationId, name, isEnabled: isEnabled, isEnabled: isSellable, attributes, stockLocked, qty: stockReported, costPrice: fullPrice, sellPrice: priceDiscounted, length, width, height, weight } = variation;
83
+ let { variationSku, variationId, name, isEnabled: isEnabled, isSellable: isSellable, attributes, stockLocked, qty: stockReported, costPrice: fullPrice, sellPrice: priceDiscounted, length, width, height, weight } = variation;
80
84
  return {
81
85
  variationSku,
82
86
  variationId,
@@ -140,16 +144,26 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
140
144
  childrenCategories: []
141
145
  };
142
146
  });
143
- mappedCategories = mappedCategories.map(category => {
144
- if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
145
- category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId);
147
+ try {
148
+ mappedCategories = mappedCategories.map(category => {
149
+ if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
150
+ category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId);
151
+ }
152
+ return category;
153
+ });
154
+ await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
155
+ categories: mappedCategories
156
+ });
157
+ }
158
+ catch (e) { }
159
+ try {
160
+ for (let k = 0, l = mappedProducts.length; k < l; k++) {
161
+ await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, {
162
+ products: [mappedProducts[k]]
163
+ });
146
164
  }
147
- return category;
148
- });
149
- await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
150
- categories: mappedCategories
151
- });
152
- await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, { products: mappedProducts });
165
+ }
166
+ catch (e) { }
153
167
  }
154
168
  return true;
155
169
  }
@@ -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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AAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAA;aAC5G;YAED,OAAO,IAAI,CAAA;SACZ;IACH,CAAC;CACF,CAAA;AAjLC;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IACY,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;0FAgL7C;AAlLU,iCAAiC;IAD7C,IAAA,uBAAQ,GAAE;GACE,iCAAiC,CAmL7C;AAnLY,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,6CAA4C;AAC5C,qFAAkE;AAElE,+GAAwG;AACxG,+DAA0D;AAG1D,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,CA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wBAC/E,UAAU,EAAE,gBAAgB;qBAC7B,CAAC,CAAA;iBACH;gBAAC,OAAO,CAAC,EAAE,GAAE;gBAEd,IAAI;oBACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;wBACrD,MAAM,sEAAgC,CAAC,oBAAoB,CAAC,gBAAgB,EAAE;4BAC5E,QAAQ,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;yBAC9B,CAAC,CAAA;qBACH;iBACF;gBAAC,OAAO,CAAC,EAAE,GAAE;aACf;YAED,OAAO,IAAI,CAAA;SACZ;IACH,CAAC;CACF,CAAA;AAnLC;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IACY,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;0FAkL7C;AApLU,iCAAiC;IAD7C,IAAA,uBAAQ,GAAE;GACE,iCAAiC,CAqL7C;AArLY,8EAAiC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-sellercraft",
3
- "version": "4.2.5",
3
+ "version": "4.2.7",
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.2.5",
34
+ "@things-factory/integration-marketplace": "^4.2.7",
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": "e1447c2e0c5c1ad9375e84291f688b7ecdbeee40"
54
+ "gitHead": "7a65abffbd9d05961b83bb31153b1c021ab607eb"
55
55
  }
@@ -6,5 +6,15 @@ export const ORDER_STATUS = {
6
6
  canceled: 'CANCELLED',
7
7
  refunded: 'REFUND_COMPLETE',
8
8
  failed: 'SHIPMENT_LOST_OR_DAMAGED',
9
- refund: 'REFUND_COMPLETE'
9
+ refund: 'REFUND_COMPLETE',
10
+ ttk_100: 'PAYMENT_PENDING', // UNPAID
11
+ ttk_111: 'CONFIRMED', // AWAITING_SHIPMENT
12
+ ttk_112: 'READY_TO_SHIP', // AWAITING_COLLECTION
13
+ ttk_121: 'SHIPPED', // IN_TRANSIT
14
+ ttk_122: 'DELIVERED', // DELIVERED
15
+ ttk_130: 'CLOSED', // COMPLETED
16
+ ttk_140: 'CANCELLED', // CANCELLED
17
+ ttk_201: 'INITIATED_CANCELLATION', // CANCEL_PENDING
18
+ ttk_202: '', // CANCEL_REJECT
19
+ ttk_203: 'CANCELLED' // CANCEL_COMPLETED
10
20
  }
@@ -1,4 +1,5 @@
1
1
  export const PLATFORM = {
2
2
  WCM: 'woocommerce',
3
- MGT: 'magento'
3
+ MGT: 'magento',
4
+ TTK: 'tiktok'
4
5
  }
@@ -58,7 +58,7 @@ export function ingestChannelOrder() {
58
58
  ordered_at_time: new Date(order.createdAt).toISOString(),
59
59
  updated_at_date: new Date(order.updatedAt).toISOString(),
60
60
  updated_at_time: new Date(order.updatedAt).toISOString(),
61
- sla_expires_at: order?.slaExpiresAt,
61
+ sla_expires_at: orderItem?.slaExpiresAt ? new Date(orderItem.slaExpiresAt).toISOString() : null,
62
62
  charges: orderItem.charges.map(charge => {
63
63
  return {
64
64
  charge_type_value: charge.name,
@@ -66,17 +66,19 @@ export function ingestChannelProduct() {
66
66
  brand: product.brand || '',
67
67
  is_verified: product.isVerified || true,
68
68
  flexible_attributes: product.channelCode == 'WCM' || product.channelCode == 'MGT' ? true : false, // add channels that do not support category_attributes ingestion
69
- images: product?.images.map(image => {
70
- return {
71
- file_url: image.url
72
- }
73
- }),
74
- product_attributes: product?.attributes.map(attribute => {
75
- return {
76
- ...attribute,
77
- native_attribute_id: attribute.native_attribute_id.toString()
78
- }
79
- }),
69
+ images:
70
+ product?.images?.map(image => {
71
+ return {
72
+ file_url: image.url
73
+ }
74
+ }) || [],
75
+ product_attributes:
76
+ product?.attributes?.map(attribute => {
77
+ return {
78
+ ...attribute,
79
+ native_attribute_id: attribute.native_attribute_id.toString()
80
+ }
81
+ }) || [],
80
82
  variants: productVariations,
81
83
  has_all_variants: product.channelCode == 'MGT' ? false : true
82
84
  }
@@ -44,9 +44,11 @@ export class SellercraftChannelIntegration {
44
44
  })
45
45
 
46
46
  if (response.ok) {
47
- return await response.json()
47
+ const result = await response.json()
48
+ return result
48
49
  } else {
49
- throw new Error(`response code - ${response.status}, ${response.statusText}`)
50
+ const result = await response.json()
51
+ throw new Error(`(${response.status}) ${result.message}`)
50
52
  }
51
53
  }
52
54
 
@@ -71,7 +73,8 @@ export class SellercraftChannelIntegration {
71
73
  if (response.ok) {
72
74
  return await response.json()
73
75
  } else {
74
- throw new Error(`response code - ${response.status}, ${response.statusText}`)
76
+ const result = await response.json()
77
+ throw new Error(`(${response.status}) ${result.message}`)
75
78
  }
76
79
  }
77
80
 
@@ -100,7 +103,8 @@ export class SellercraftChannelIntegration {
100
103
  if (response.ok) {
101
104
  return await response.json()
102
105
  } else {
103
- throw new Error(`response code - ${response.status}, ${response.statusText}`)
106
+ const result = await response.json()
107
+ throw new Error(`(${response.status}) ${result.message}`)
104
108
  }
105
109
  }
106
110
  }