@things-factory/integration-sellercraft 4.1.35 → 4.2.1

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 (21) hide show
  1. package/dist-server/constants/order-status-mapping.js +1 -1
  2. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js +17 -21
  3. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js.map +1 -1
  4. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js +2 -2
  5. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js.map +1 -1
  6. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js +12 -18
  7. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js.map +1 -1
  8. package/dist-server/routers/sellercraft-router.js +6 -6
  9. package/dist-server/routers/sellercraft-router.js.map +1 -1
  10. package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js +182 -20
  11. package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js.map +1 -1
  12. package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js +36 -16
  13. package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js.map +1 -1
  14. package/package.json +15 -15
  15. package/server/constants/order-status-mapping.ts +1 -1
  16. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.ts +18 -22
  17. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.ts +3 -3
  18. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts +18 -18
  19. package/server/routers/sellercraft-router.ts +10 -22
  20. package/server/service/marketplace-channel/marketplace-channel-order-mutation.ts +187 -32
  21. package/server/service/marketplace-channel/marketplace-channel-product-mutation.ts +50 -46
@@ -43,16 +43,26 @@ 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;
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
  var sellercraftStore = Object.assign(Object.assign({}, store), { platform: 'sellercraftChannelIntegration' });
53
- const productResult = await integration_marketplace_1.StoreAPI.getStoreProducts(store, {});
54
+ const productResult = [];
55
+ let totalPages = 1;
56
+ var limit = 50;
57
+ for (let page = 0; page < totalPages; page++) {
58
+ const { results, total } = await integration_marketplace_1.StoreAPI.getStoreProducts(store, {
59
+ pagination: { page, limit }
60
+ });
61
+ totalPages = Math.ceil(total / limit);
62
+ productResult.push(...results);
63
+ }
54
64
  const categoryResult = await integration_marketplace_1.StoreAPI.getStoreProductCategories(store, {});
55
- let mappedProducts = productResult.results.map((item) => {
65
+ let mappedProducts = productResult.map(item => {
56
66
  let { categoryId, itemId: productId, name, brand, isVerified, images, attributes, variations } = item;
57
67
  variations = variations.map(variation => {
58
68
  let { variationSku, variationId, name, isEnabled: isEnabled, isEnabled: isSellable, attributes, stockLocked, qty: stockReported, costPrice: fullPrice, sellPrice: priceDiscounted, length, width, height, weight } = variation;
@@ -67,22 +77,26 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
67
77
  stockReported,
68
78
  fullPrice,
69
79
  priceDiscounted,
70
- inventoryProducts: [{
80
+ inventoryProducts: [
81
+ {
71
82
  qty: stockReported,
72
83
  name: `${name} - ${variationSku}`,
73
84
  sku: variationSku,
74
- productVersions: [{
85
+ productVersions: [
86
+ {
75
87
  label: 'Default',
76
88
  packageLengthMM: length,
77
89
  packageWidthMM: width,
78
90
  packageHeightMM: height,
79
91
  packageWeightGram: weight,
80
92
  qty: 1
81
- }]
82
- }]
93
+ }
94
+ ]
95
+ }
96
+ ]
83
97
  };
84
98
  });
85
- images = images.map(image => {
99
+ images = images === null || images === void 0 ? void 0 : images.map(image => {
86
100
  return {
87
101
  url: image
88
102
  };
@@ -102,7 +116,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
102
116
  variations
103
117
  };
104
118
  });
105
- let mappedCategories = categoryResult.results.map((category) => {
119
+ let mappedCategories = categoryResult.results.map(category => {
106
120
  let { id: categoryId, name: categoryName, parent, isActive } = category;
107
121
  return {
108
122
  categoryId,
@@ -111,14 +125,20 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
111
125
  isLeaf: parent == 0 ? false : true,
112
126
  isActive: isActive || true,
113
127
  channelCode,
114
- countryCode
128
+ countryCode,
129
+ childrenCategories: []
115
130
  };
116
131
  });
117
- mappedCategories.map((category) => {
118
- category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId);
132
+ mappedCategories = mappedCategories.map(category => {
133
+ if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
134
+ category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId);
135
+ }
136
+ return category;
137
+ });
138
+ await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
139
+ categories: mappedCategories
119
140
  });
120
- const ingestCategory = await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, { categories: mappedCategories });
121
- const ingestProduct = await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, { products: mappedProducts });
141
+ await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, { products: mappedProducts });
122
142
  }
123
143
  return true;
124
144
  }
@@ -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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AM,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;wBAClC,QAAQ,EAAE,QAAQ,IAAI,IAAI;wBAC1B,WAAW;wBACX,WAAW;qBACZ,CAAA;gBACH,CAAC,CAAC,CAAA;gBAEF,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;oBAChC,QAAQ,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,CAAE,CAAA;gBAC9F,CAAC,CAAC,CAAA;gBAEF,MAAM,cAAc,GAAG,MAAM,sEAAgC,CAAC,uBAAuB,CAAC,gBAAgB,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAC,CAAC,CAAA;gBAExI,MAAM,aAAa,GAAG,MAAM,sEAAgC,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAA;aAElI;YAED,OAAO,IAAI,CAAA;SACZ;IACH,CAAC;CACF,CAAA;AA1JC;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IAE1B,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;0FAwJP;AA3JU,iCAAiC;IAD7C,IAAA,uBAAQ,GAAE;GACE,iCAAiC,CA4J7C;AA5JY,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,CA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CAAA;;;;0FA6J7C;AA/JU,iCAAiC;IAD7C,IAAA,uBAAQ,GAAE;GACE,iCAAiC,CAgK7C;AAhKY,8EAAiC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-sellercraft",
3
- "version": "4.1.35",
3
+ "version": "4.2.1",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,19 +24,19 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
25
25
  },
26
26
  "dependencies": {
27
- "@things-factory/apptool-ui": "^4.1.28",
28
- "@things-factory/auth-ui": "^4.1.28",
29
- "@things-factory/biz-base": "^4.1.28",
30
- "@things-factory/code-ui": "^4.1.28",
31
- "@things-factory/context-ui": "^4.1.28",
32
- "@things-factory/grist-ui": "^4.1.28",
33
- "@things-factory/i18n-base": "^4.1.28",
34
- "@things-factory/integration-marketplace": "^4.1.35",
35
- "@things-factory/integration-ui": "^4.1.28",
36
- "@things-factory/more-ui": "^4.1.28",
37
- "@things-factory/resource-ui": "^4.1.28",
38
- "@things-factory/setting-ui": "^4.1.28",
39
- "@things-factory/system-ui": "^4.1.28",
27
+ "@things-factory/apptool-ui": "^4.1.40",
28
+ "@things-factory/auth-ui": "^4.1.40",
29
+ "@things-factory/biz-base": "^4.1.40",
30
+ "@things-factory/code-ui": "^4.1.40",
31
+ "@things-factory/context-ui": "^4.1.40",
32
+ "@things-factory/grist-ui": "^4.1.40",
33
+ "@things-factory/i18n-base": "^4.1.40",
34
+ "@things-factory/integration-marketplace": "^4.2.1",
35
+ "@things-factory/integration-ui": "^4.1.40",
36
+ "@things-factory/more-ui": "^4.1.40",
37
+ "@things-factory/resource-ui": "^4.1.40",
38
+ "@things-factory/setting-ui": "^4.1.40",
39
+ "@things-factory/system-ui": "^4.1.40",
40
40
  "debug": "^4.1.1",
41
41
  "node-fetch": "^2.6.0",
42
42
  "querystring": "^0.2.1"
@@ -51,5 +51,5 @@
51
51
  "nock": "^13.0.2",
52
52
  "should": "^13.2.3"
53
53
  },
54
- "gitHead": "a7e4a62c6ab05d18879ab945ac0f10be440a5f34"
54
+ "gitHead": "1aeab216e97c010d738ed7e49302750f3534c462"
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,30 +7,10 @@ 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
- payload: [ ...newCategories ]
13
+ payload: [...newCategories]
34
14
  }
35
15
  },
36
16
  normalize(res) {
@@ -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
+ }
@@ -1,4 +1,4 @@
1
- /* https://docs.sellercraft.co/docs/api-integrations/b3A6MTY4NjQxODU-initiate-order-shipment */
1
+ /* https://docs.sellercraft.co/docs/api-integrations/b3A6MjQzODQ4OTg-ingest-channel-order */
2
2
 
3
3
  import { ORDER_STATUS } from '../../../constants'
4
4
 
@@ -49,7 +49,7 @@ export function ingestChannelOrder() {
49
49
  phone_1: order.billPhone1,
50
50
  phone_2: order.billPhone2
51
51
  },
52
- order_items: order.orderItems.map(orderItem => {
52
+ order_items: order.mappedOrderItems.map(orderItem => {
53
53
  return {
54
54
  native_item_id: orderItem.id.toString(),
55
55
  native_variant_id: orderItem.variationId.toString(),
@@ -73,7 +73,7 @@ export function ingestChannelOrder() {
73
73
  })
74
74
 
75
75
  return {
76
- payload: [ ...newOrders ]
76
+ payload: [...newOrders]
77
77
  }
78
78
  },
79
79
  normalize(res) {
@@ -13,15 +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
+ variant_attributes: variant?.attributes.map(attribute => {
20
+ return {
21
+ ...attribute,
22
+ native_attribute_id: attribute.native_attribute_id.toString()
23
+ }
24
+ }) || [],
25
25
  stock_locked: variant?.stockLocked ? variant.stockLocked : 0,
26
26
  native_stock_reported: variant?.stockReported ? variant.stockReported : 0,
27
27
  price_full: variant.fullPrice || 0,
@@ -29,7 +29,7 @@ export function ingestChannelProduct() {
29
29
  inventory_products: variant?.inventoryProducts
30
30
  ? variant.inventoryProducts.map(inventoryProduct => {
31
31
  return {
32
- quantity: inventoryProduct.qty,
32
+ quantity: inventoryProduct.qty || 1,
33
33
  name: inventoryProduct.name,
34
34
  inventory_sku: inventoryProduct.sku,
35
35
  product_versions: inventoryProduct?.productVersions
@@ -61,20 +61,20 @@ export function ingestChannelProduct() {
61
61
  native_category_id: product.categoryId.toString(),
62
62
  native_product_id: product.productId.toString(),
63
63
  label: product.name,
64
- brand: product.brand,
65
- is_verified: product.isVerified,
64
+ brand: product.brand || '',
65
+ is_verified: product.isVerified || true,
66
66
  flexible_attributes: product.channelCode == 'WCM' ? true : false, // add channels that do not support category_attributes ingestion
67
- images: product.images.map(image => {
67
+ images: product?.images.map(image => {
68
68
  return {
69
69
  file_url: image.url
70
70
  }
71
71
  }),
72
- // product_attributes: product.attributes.map(attribute => {
73
- // return {
74
- // ...attribute,
75
- // native_attribute_id: attribute.native_attribute_id.toString()
76
- // }
77
- // }),
72
+ product_attributes: product?.attributes.map(attribute => {
73
+ return {
74
+ ...attribute,
75
+ native_attribute_id: attribute.native_attribute_id.toString()
76
+ }
77
+ }),
78
78
  variants: productVariations
79
79
  }
80
80
  })
@@ -23,7 +23,7 @@ sellercraftRouter.post('/sellercraft/store/update-product-price', async (context
23
23
  var result
24
24
 
25
25
  // https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
26
- var fullPath = tokenCraftUrl + '?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=' + requestBody[i].shop_id
26
+ var fullPath = `${tokenCraftUrl}?channel_id=${requestBody[i].channel_id}&shop_id=${requestBody[i].shop_id}`
27
27
  const response: any = await fetch(fullPath, {
28
28
  method: 'get',
29
29
  headers: {
@@ -42,7 +42,7 @@ sellercraftRouter.post('/sellercraft/store/update-product-price', async (context
42
42
  platform: PLATFORM[`${store.shop.org_prefix}`]
43
43
  }
44
44
 
45
- if (requestBody[i].native_variant_id) {
45
+ if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
46
46
  const req = {
47
47
  costPrice: requestBody[i].full_price,
48
48
  sellPrice: requestBody[i].sale_price,
@@ -79,7 +79,7 @@ sellercraftRouter.post('/sellercraft/store/update-product-stock', async (context
79
79
  var result
80
80
 
81
81
  // https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
82
- var fullPath = tokenCraftUrl + '?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=' + requestBody[i].shop_id
82
+ var fullPath = `${tokenCraftUrl}?channel_id=${requestBody[i].channel_id}&shop_id=${requestBody[i].shop_id}`
83
83
  const response: any = await fetch(fullPath, {
84
84
  method: 'get',
85
85
  headers: {
@@ -98,7 +98,7 @@ sellercraftRouter.post('/sellercraft/store/update-product-stock', async (context
98
98
  platform: PLATFORM[`${store.shop.org_prefix}`]
99
99
  }
100
100
 
101
- if (requestBody[i].native_variant_id) {
101
+ if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
102
102
  const req = {
103
103
  qty: requestBody[i].stock,
104
104
  itemId: requestBody[i].native_product_id,
@@ -131,7 +131,7 @@ sellercraftRouter.post('/sellercraft/store/update-order-status', async (context,
131
131
  var store: any = {}
132
132
 
133
133
  // https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
134
- var fullPath = tokenCraftUrl + '?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=' + requestBody.shop_id
134
+ var fullPath = `${tokenCraftUrl}?channel_id=${requestBody.channel_id}&shop_id=${requestBody.shop_id}`
135
135
  const response: any = await fetch(fullPath, {
136
136
  method: 'get',
137
137
  headers: {
@@ -170,7 +170,7 @@ sellercraftRouter.post('/sellercraft/store/update-product-attribute', async (con
170
170
  var store: any = {}
171
171
 
172
172
  // https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
173
- var fullPath = tokenCraftUrl + '?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=' + requestBody.shop_id
173
+ var fullPath = `${tokenCraftUrl}?channel_id=${requestBody.channel_id}&shop_id=${requestBody.shop_id}`
174
174
  const response: any = await fetch(fullPath, {
175
175
  method: 'get',
176
176
  headers: {
@@ -188,26 +188,14 @@ sellercraftRouter.post('/sellercraft/store/update-product-attribute', async (con
188
188
  storeURL: store.shop.credential.store_url,
189
189
  platform: PLATFORM[`${store.shop.org_prefix}`]
190
190
  }
191
-
192
- let {
193
- product_sku: productSku,
194
- native_product_id: itemId,
195
- variants
196
- } = requestBody
191
+
192
+ let { product_sku: productSku, native_product_id: itemId, variants } = requestBody
197
193
 
198
194
  variants.map(variant => {
199
- let {
200
- variant_sku: variantSku,
201
- native_variant_id: variantId,
202
- attributes
203
- } = variant
195
+ let { variant_sku: variantSku, native_variant_id: variantId, attributes } = variant
204
196
 
205
197
  attributes.map(attribute => {
206
- let {
207
- native_attribute_id: id,
208
- attribute_key: name,
209
- attribute_value: value
210
- } = attribute
198
+ let { native_attribute_id: id, attribute_key: name, attribute_value: value } = attribute
211
199
 
212
200
  return {
213
201
  id,