@things-factory/integration-sellercraft 4.2.2 → 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.
- package/dist-server/constants/order-status-mapping.js +13 -3
- package/dist-server/constants/order-status-mapping.js.map +1 -1
- package/dist-server/constants/platform.js +2 -1
- package/dist-server/constants/platform.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js +25 -8
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js +8 -4
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js.map +1 -1
- package/dist-server/routers/sellercraft-router.js +2 -1
- package/dist-server/routers/sellercraft-router.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js +253 -231
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js +48 -23
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js.map +1 -1
- package/package.json +3 -3
- package/server/constants/order-status-mapping.ts +13 -3
- package/server/constants/platform.ts +2 -1
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.ts +1 -1
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts +34 -15
- package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts +8 -4
- package/server/routers/sellercraft-router.ts +2 -1
- package/server/service/marketplace-channel/marketplace-channel-order-mutation.ts +305 -270
- package/server/service/marketplace-channel/marketplace-channel-product-mutation.ts +47 -26
@@ -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
|
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;
|
@@ -53,19 +55,32 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
53
55
|
var sellercraftStore = Object.assign(Object.assign({}, store), { platform: 'sellercraftChannelIntegration' });
|
54
56
|
const productResult = [];
|
55
57
|
let totalPages = 1;
|
56
|
-
|
58
|
+
let limit = 50;
|
59
|
+
let parentLinks = [];
|
57
60
|
for (let page = 0; page < totalPages; page++) {
|
58
|
-
const { results, total } = await integration_marketplace_1.StoreAPI.getStoreProducts(store, {
|
61
|
+
const { results, total, parentLinkList } = await integration_marketplace_1.StoreAPI.getStoreProducts(store, {
|
59
62
|
pagination: { page, limit }
|
60
63
|
});
|
61
64
|
totalPages = Math.ceil(total / limit);
|
62
65
|
productResult.push(...results);
|
66
|
+
if (store.platform == 'magento')
|
67
|
+
parentLinks.push(...parentLinkList);
|
68
|
+
}
|
69
|
+
const categoryResult = [];
|
70
|
+
let totalPagesCategory = 1;
|
71
|
+
let limitCategory = 100;
|
72
|
+
for (let page = 0; page < totalPagesCategory; page++) {
|
73
|
+
const { results, total } = await integration_marketplace_1.StoreAPI.getStoreProductCategories(store, {
|
74
|
+
pagination: { page, limitCategory }
|
75
|
+
});
|
76
|
+
totalPagesCategory = Math.ceil(total / limitCategory);
|
77
|
+
categoryResult.push(...results);
|
63
78
|
}
|
64
|
-
const categoryResult = await integration_marketplace_1.StoreAPI.getStoreProductCategories(store, {});
|
65
79
|
let mappedProducts = productResult.map(item => {
|
66
|
-
|
80
|
+
var _a;
|
81
|
+
let { categoryId, itemId: productId, name, brand, isVerified, images, attributes, variations } = item;
|
67
82
|
variations = variations.map(variation => {
|
68
|
-
let { variationSku, variationId, name, isEnabled: isEnabled,
|
83
|
+
let { variationSku, variationId, name, isEnabled: isEnabled, isSellable: isSellable, attributes, stockLocked, qty: stockReported, costPrice: fullPrice, sellPrice: priceDiscounted, length, width, height, weight } = variation;
|
69
84
|
return {
|
70
85
|
variationSku,
|
71
86
|
variationId,
|
@@ -79,7 +94,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
79
94
|
priceDiscounted,
|
80
95
|
inventoryProducts: [
|
81
96
|
{
|
82
|
-
qty:
|
97
|
+
qty: 1,
|
83
98
|
name: `${name} - ${variationSku}`,
|
84
99
|
sku: variationSku,
|
85
100
|
productVersions: [
|
@@ -89,7 +104,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
89
104
|
packageWidthMM: width,
|
90
105
|
packageHeightMM: height,
|
91
106
|
packageWeightGram: weight,
|
92
|
-
qty:
|
107
|
+
qty: stockReported
|
93
108
|
}
|
94
109
|
]
|
95
110
|
}
|
@@ -107,7 +122,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
107
122
|
channelCode: channels[i].channelCode,
|
108
123
|
channelCountry: shops[j].country_code,
|
109
124
|
categoryId,
|
110
|
-
productId:
|
125
|
+
productId: ((_a = parentLinks.find(e => e.children.includes(productId))) === null || _a === void 0 ? void 0 : _a.id) || productId,
|
111
126
|
name,
|
112
127
|
brand,
|
113
128
|
isVerified,
|
@@ -116,7 +131,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
116
131
|
variations
|
117
132
|
};
|
118
133
|
});
|
119
|
-
let mappedCategories = categoryResult.
|
134
|
+
let mappedCategories = categoryResult.map(category => {
|
120
135
|
let { id: categoryId, name: categoryName, parent, isActive } = category;
|
121
136
|
return {
|
122
137
|
categoryId,
|
@@ -129,16 +144,26 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
129
144
|
childrenCategories: []
|
130
145
|
};
|
131
146
|
});
|
132
|
-
|
133
|
-
|
134
|
-
|
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
|
+
});
|
135
164
|
}
|
136
|
-
|
137
|
-
}
|
138
|
-
await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
|
139
|
-
categories: mappedCategories
|
140
|
-
});
|
141
|
-
await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, { products: mappedProducts });
|
165
|
+
}
|
166
|
+
catch (e) { }
|
142
167
|
}
|
143
168
|
return true;
|
144
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
|
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,CAA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,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.
|
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.
|
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": "
|
54
|
+
"gitHead": "7a65abffbd9d05961b83bb31153b1c021ab607eb"
|
55
55
|
}
|
@@ -1,10 +1,20 @@
|
|
1
1
|
export const ORDER_STATUS = {
|
2
|
-
pending: '
|
3
|
-
processing: '
|
2
|
+
pending: 'CONFIRMED',
|
3
|
+
processing: 'CONFIRMED',
|
4
4
|
completed: 'DELIVERED',
|
5
5
|
cancelled: 'CANCELLED',
|
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
|
}
|
@@ -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:
|
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,
|
@@ -31,7 +31,7 @@ export function ingestChannelProduct() {
|
|
31
31
|
inventory_products: variant?.inventoryProducts
|
32
32
|
? variant.inventoryProducts.map(inventoryProduct => {
|
33
33
|
return {
|
34
|
-
quantity: inventoryProduct.qty ||
|
34
|
+
quantity: inventoryProduct.qty || 0,
|
35
35
|
name: inventoryProduct.name,
|
36
36
|
inventory_sku: inventoryProduct.sku,
|
37
37
|
product_versions: inventoryProduct?.productVersions
|
@@ -45,7 +45,7 @@ export function ingestChannelProduct() {
|
|
45
45
|
package_weight_gram: productVersion?.packageWeightGram
|
46
46
|
? productVersion.packageWeightGram
|
47
47
|
: 0,
|
48
|
-
stock_available: productVersion.qty
|
48
|
+
stock_available: productVersion.qty
|
49
49
|
}
|
50
50
|
})
|
51
51
|
: []
|
@@ -65,22 +65,41 @@ export function ingestChannelProduct() {
|
|
65
65
|
label: product.name,
|
66
66
|
brand: product.brand || '',
|
67
67
|
is_verified: product.isVerified || true,
|
68
|
-
flexible_attributes: product.channelCode == 'WCM' ? true : false, // add channels that do not support category_attributes ingestion
|
69
|
-
images:
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
68
|
+
flexible_attributes: product.channelCode == 'WCM' || product.channelCode == 'MGT' ? true : false, // add channels that do not support category_attributes ingestion
|
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
|
+
}) || [],
|
82
|
+
variants: productVariations,
|
83
|
+
has_all_variants: product.channelCode == 'MGT' ? false : true
|
81
84
|
}
|
82
85
|
})
|
83
86
|
|
87
|
+
if (products[0].channelCode == 'MGT') {
|
88
|
+
let newList = []
|
89
|
+
for (let np of newProducts) {
|
90
|
+
if (np.native_product_id == np.variants[0].native_variant_id) {
|
91
|
+
let vars = newProducts
|
92
|
+
.filter(e => e.native_product_id == np.native_product_id)
|
93
|
+
.map(e => {
|
94
|
+
return e.variants[0]
|
95
|
+
})
|
96
|
+
np.variants = vars
|
97
|
+
newList.push(np)
|
98
|
+
}
|
99
|
+
}
|
100
|
+
newProducts = newList
|
101
|
+
}
|
102
|
+
|
84
103
|
return {
|
85
104
|
payload: [...newProducts]
|
86
105
|
}
|
package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts
CHANGED
@@ -44,9 +44,11 @@ export class SellercraftChannelIntegration {
|
|
44
44
|
})
|
45
45
|
|
46
46
|
if (response.ok) {
|
47
|
-
|
47
|
+
const result = await response.json()
|
48
|
+
return result
|
48
49
|
} else {
|
49
|
-
|
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
|
-
|
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
|
-
|
106
|
+
const result = await response.json()
|
107
|
+
throw new Error(`(${response.status}) ${result.message}`)
|
104
108
|
}
|
105
109
|
}
|
106
110
|
}
|
@@ -163,7 +163,8 @@ sellercraftRouter.post('/sellercraft/store/update-order-status', async (context,
|
|
163
163
|
orderId: requestBody.native_order_id,
|
164
164
|
status: requestBody.order_status,
|
165
165
|
carrier: requestBody?.shipper_last_mile,
|
166
|
-
trackingNo: requestBody?.tracking_number
|
166
|
+
trackingNo: requestBody?.tracking_number,
|
167
|
+
orderItems: requestBody?.order_item_ids
|
167
168
|
}
|
168
169
|
|
169
170
|
result = await StoreAPI.updateOrderStatus(mappedStore, reqBody)
|