@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
@@ -1,11 +1,11 @@
1
1
  import { Ctx, Mutation, Resolver } from 'type-graphql'
2
2
  import { getRepository } from 'typeorm'
3
3
 
4
- import { MarketplaceChannel } from './marketplace-channel'
5
-
6
4
  import { config } from '@things-factory/env'
7
5
  import { StoreAPI } from '@things-factory/integration-marketplace'
6
+
8
7
  import { SellercraftChannelIntegrationAPI } from '../../controllers/sellercraft-channel-integration-api'
8
+ import { MarketplaceChannel } from './marketplace-channel'
9
9
 
10
10
  @Resolver()
11
11
  export class MarketplaceChannelProductMutation {
@@ -34,11 +34,12 @@ export class MarketplaceChannelProductMutation {
34
34
 
35
35
  for (var j = 0; j < shops.length; j++) {
36
36
  var store = {
37
- accessKey: shops[j].credential.consumer_key,
38
- accessSecret: shops[j].credential.consumer_secret,
39
- storeURL: shops[j].credential.store_url,
37
+ accessKey: shops[j]?.credential?.consumer_key || '',
38
+ accessSecret: shops[j]?.credential?.consumer_secret || '',
39
+ storeURL: shops[j]?.credential?.store_url || '',
40
40
  platform: channels[i].name,
41
- accessToken: shops[j].credential.access_token // Magento+
41
+ accessToken: shops[j]?.credential?.access_token, // Magento+, Tiktok
42
+ channelShopId: shops[j]?.channel_shop_id
42
43
  }
43
44
 
44
45
  let countryCode = shops[j].country_code
@@ -67,22 +68,15 @@ export class MarketplaceChannelProductMutation {
67
68
  let limitCategory: number = 100
68
69
 
69
70
  for (let page = 0; page < totalPagesCategory; page++) {
70
- const { results, total } = await StoreAPI.getStoreProductCategories(store, { pagination: { page, limitCategory } })
71
+ const { results, total } = await StoreAPI.getStoreProductCategories(store, {
72
+ pagination: { page, limitCategory }
73
+ })
71
74
  totalPagesCategory = Math.ceil(total / limitCategory)
72
75
  categoryResult.push(...results)
73
76
  }
74
77
 
75
78
  let mappedProducts = productResult.map(item => {
76
- let {
77
- categoryId,
78
- itemId: productId,
79
- name,
80
- brand,
81
- isVerified,
82
- images,
83
- attributes,
84
- variations
85
- } = item
79
+ let { categoryId, itemId: productId, name, brand, isVerified, images, attributes, variations } = item
86
80
 
87
81
  variations = variations.map(variation => {
88
82
  let {
@@ -90,7 +84,7 @@ export class MarketplaceChannelProductMutation {
90
84
  variationId,
91
85
  name,
92
86
  isEnabled: isEnabled,
93
- isEnabled: isSellable,
87
+ isSellable: isSellable,
94
88
  attributes,
95
89
  stockLocked,
96
90
  qty: stockReported,
@@ -170,18 +164,26 @@ export class MarketplaceChannelProductMutation {
170
164
  }
171
165
  })
172
166
 
173
- mappedCategories = mappedCategories.map(category => {
174
- if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
175
- category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId)
176
- }
177
- return category
178
- })
167
+ try {
168
+ mappedCategories = mappedCategories.map(category => {
169
+ if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
170
+ category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId)
171
+ }
172
+ return category
173
+ })
179
174
 
180
- await SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
181
- categories: mappedCategories
182
- })
175
+ await SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
176
+ categories: mappedCategories
177
+ })
178
+ } catch (e) {}
183
179
 
184
- await SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, { products: mappedProducts })
180
+ try {
181
+ for (let k = 0, l = mappedProducts.length; k < l; k++) {
182
+ await SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, {
183
+ products: [mappedProducts[k]]
184
+ })
185
+ }
186
+ } catch (e) {}
185
187
  }
186
188
 
187
189
  return true