@things-factory/integration-marketplace 5.0.11 → 5.0.14
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/controllers/shopee/apis2/create-shipping-document.js +28 -0
- package/dist-server/controllers/shopee/apis2/create-shipping-document.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/echo.js +19 -0
- package/dist-server/controllers/shopee/apis2/echo.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-logistics-param.js +51 -0
- package/dist-server/controllers/shopee/apis2/get-logistics-param.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-shipping-document-result.js +26 -0
- package/dist-server/controllers/shopee/apis2/get-shipping-document-result.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-logistics.js +25 -0
- package/dist-server/controllers/shopee/apis2/get-store-logistics.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-order-by-batch.js +80 -0
- package/dist-server/controllers/shopee/apis2/get-store-order-by-batch.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-order-document.js +41 -0
- package/dist-server/controllers/shopee/apis2/get-store-order-document.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-order-payout-dates.js +36 -0
- package/dist-server/controllers/shopee/apis2/get-store-order-payout-dates.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-order-transaction-details.js +31 -0
- package/dist-server/controllers/shopee/apis2/get-store-order-transaction-details.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-order.js +77 -0
- package/dist-server/controllers/shopee/apis2/get-store-order.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-orders.js +37 -0
- package/dist-server/controllers/shopee/apis2/get-store-orders.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-product-variations.js +21 -0
- package/dist-server/controllers/shopee/apis2/get-store-product-variations.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-product.js +101 -0
- package/dist-server/controllers/shopee/apis2/get-store-product.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-products.js +29 -0
- package/dist-server/controllers/shopee/apis2/get-store-products.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-refund-order-details.js +40 -0
- package/dist-server/controllers/shopee/apis2/get-store-refund-order-details.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-store-refund-orders.js +36 -0
- package/dist-server/controllers/shopee/apis2/get-store-refund-orders.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/get-tracking-number.js +21 -0
- package/dist-server/controllers/shopee/apis2/get-tracking-number.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/index.js +24 -0
- package/dist-server/controllers/shopee/apis2/index.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/init-logistics.js +39 -0
- package/dist-server/controllers/shopee/apis2/init-logistics.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/update-store-product-stock.js +30 -0
- package/dist-server/controllers/shopee/apis2/update-store-product-stock.js.map +1 -0
- package/dist-server/controllers/shopee/apis2/update-store-product-variation-stock.js +31 -0
- package/dist-server/controllers/shopee/apis2/update-store-product-variation-stock.js.map +1 -0
- package/dist-server/controllers/shopee/refresh-access-token.js +65 -0
- package/dist-server/controllers/shopee/refresh-access-token.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://open.shopee.com/documents/v2/v2.product.get_item_base_info?module=89&type=1 */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getStoreProduct = void 0;
|
|
5
|
+
const store_api_1 = require("../../store-api");
|
|
6
|
+
function getStoreProduct() {
|
|
7
|
+
return {
|
|
8
|
+
path: '/product/get_item_base_info',
|
|
9
|
+
method: 'getV2',
|
|
10
|
+
denormalize(req) {
|
|
11
|
+
return {
|
|
12
|
+
item_id_list: req.itemIds
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
async normalize(res, { store }) {
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
17
|
+
let items = res.item_list;
|
|
18
|
+
let results = [];
|
|
19
|
+
for (let i = 0; i < items.length; i++) {
|
|
20
|
+
const item = items[i];
|
|
21
|
+
let variations;
|
|
22
|
+
if (item.has_model) {
|
|
23
|
+
variations = await store_api_1.StoreAPI.getStoreProductVariations(store, { itemId: item.item_id });
|
|
24
|
+
}
|
|
25
|
+
const result = {
|
|
26
|
+
itemId: item.item_id,
|
|
27
|
+
isku: item === null || item === void 0 ? void 0 : item.item_sku,
|
|
28
|
+
weight: item.weight,
|
|
29
|
+
categoryId: item.category_id,
|
|
30
|
+
condition: item.condition,
|
|
31
|
+
marketplaceStatus: item.item_status,
|
|
32
|
+
name: item.item_name,
|
|
33
|
+
description: (_d = (_c = (_b = (_a = item.description_info) === null || _a === void 0 ? void 0 : _a.extended_description) === null || _b === void 0 ? void 0 : _b.field_list) === null || _c === void 0 ? void 0 : _c.find(f => f.field_type == 'text')) === null || _d === void 0 ? void 0 : _d.text,
|
|
34
|
+
currency: (item === null || item === void 0 ? void 0 : item.price_info) ? (_e = item === null || item === void 0 ? void 0 : item.price_info[0]) === null || _e === void 0 ? void 0 : _e.currency : undefined,
|
|
35
|
+
costPrice: (item === null || item === void 0 ? void 0 : item.price_info) ? (_f = item === null || item === void 0 ? void 0 : item.price_info[0]) === null || _f === void 0 ? void 0 : _f.original_price : undefined,
|
|
36
|
+
sellPrice: (item === null || item === void 0 ? void 0 : item.price_info) ? (_g = item === null || item === void 0 ? void 0 : item.price_info[0]) === null || _g === void 0 ? void 0 : _g.current_price : undefined,
|
|
37
|
+
qty: (_j = (_h = item === null || item === void 0 ? void 0 : item.stock_info_v2) === null || _h === void 0 ? void 0 : _h.summary_info) === null || _j === void 0 ? void 0 : _j.total_available_stock,
|
|
38
|
+
bufferQty: (_l = (_k = item === null || item === void 0 ? void 0 : item.stock_info_v2) === null || _k === void 0 ? void 0 : _k.summary_info) === null || _l === void 0 ? void 0 : _l.total_reserved_stock,
|
|
39
|
+
packageLength: item.dimension.package_length,
|
|
40
|
+
packageWidth: item.dimension.package_width,
|
|
41
|
+
packageHeight: item.dimension.package_height,
|
|
42
|
+
daysToShip: item.pre_order.days_to_ship,
|
|
43
|
+
discountId: item.promotion_id,
|
|
44
|
+
isPreOrder: item.pre_order.is_pre_order,
|
|
45
|
+
hasVariation: item.has_model,
|
|
46
|
+
attributes: ((_m = item === null || item === void 0 ? void 0 : item.attribute_list) === null || _m === void 0 ? void 0 : _m.map(attribute => {
|
|
47
|
+
var _a;
|
|
48
|
+
return {
|
|
49
|
+
attributeId: attribute.attribute_id,
|
|
50
|
+
name: attribute.original_attribute_name,
|
|
51
|
+
isMandatory: attribute.is_mandatory,
|
|
52
|
+
originalValue: JSON.stringify((_a = attribute === null || attribute === void 0 ? void 0 : attribute.attribute_value_list) === null || _a === void 0 ? void 0 : _a.map(v => {
|
|
53
|
+
return v.original_value_name;
|
|
54
|
+
})) || ''
|
|
55
|
+
};
|
|
56
|
+
})) || [],
|
|
57
|
+
variations: item.has_model
|
|
58
|
+
? variations.model.map(variation => {
|
|
59
|
+
var _a, _b, _c, _d;
|
|
60
|
+
return {
|
|
61
|
+
variationId: variation.model_id,
|
|
62
|
+
variationSku: variation.model_sku,
|
|
63
|
+
channelSku: variation.model_sku,
|
|
64
|
+
name: `${item.item_name} - ${variations.tier_variation[0].option_list[variation.tier_index[0]].option}${variations.tier_variation[1]
|
|
65
|
+
? ' - ' + variations.tier_variation[1].option_list[variation.tier_index[1]].option
|
|
66
|
+
: ''}`,
|
|
67
|
+
description: (_d = (_c = (_b = (_a = item.description_info) === null || _a === void 0 ? void 0 : _a.extended_description) === null || _b === void 0 ? void 0 : _b.field_list) === null || _c === void 0 ? void 0 : _c.find(f => f.field_type == 'text')) === null || _d === void 0 ? void 0 : _d.text,
|
|
68
|
+
qty: variation.stock_info_v2.summary_info.total_available_stock,
|
|
69
|
+
bufferQty: variation.stock_info_v2.summary_info.total_reserved_stock,
|
|
70
|
+
costPrice: variation.price_info[0].original_price,
|
|
71
|
+
sellPrice: variation.price_info[0].current_price,
|
|
72
|
+
discountId: variation.promotion_id,
|
|
73
|
+
marketplaceStatus: item.item_status,
|
|
74
|
+
primaryUnitValue: item.weight
|
|
75
|
+
};
|
|
76
|
+
})
|
|
77
|
+
: [
|
|
78
|
+
{
|
|
79
|
+
variationId: item.item_id,
|
|
80
|
+
variationSku: item.item_sku,
|
|
81
|
+
channelSku: item.item_sku,
|
|
82
|
+
name: item.item_name,
|
|
83
|
+
description: (_r = (_q = (_p = (_o = item.description_info) === null || _o === void 0 ? void 0 : _o.extended_description) === null || _p === void 0 ? void 0 : _p.field_list) === null || _q === void 0 ? void 0 : _q.find(f => f.field_type == 'text')) === null || _r === void 0 ? void 0 : _r.text,
|
|
84
|
+
qty: item.stock_info_v2.summary_info.total_available_stock,
|
|
85
|
+
bufferQty: item.stock_info_v2.summary_info.total_reserved_stock,
|
|
86
|
+
costPrice: item.price_info[0].original_price,
|
|
87
|
+
sellPrice: item.price_info[0].current_price,
|
|
88
|
+
discountId: item.promotion_id,
|
|
89
|
+
marketplaceStatus: item.item_status,
|
|
90
|
+
primaryUnitValue: item.weight
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
};
|
|
94
|
+
results.push(result);
|
|
95
|
+
}
|
|
96
|
+
return results;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
exports.getStoreProduct = getStoreProduct;
|
|
101
|
+
//# sourceMappingURL=get-store-product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-store-product.js","sourceRoot":"","sources":["../../../../server/controllers/shopee/apis2/get-store-product.ts"],"names":[],"mappings":";AAAA,yFAAyF;;;AAEzF,+CAA0C;AAE1C,SAAgB,eAAe;IAC7B,OAAO;QACL,IAAI,EAAE,6BAA6B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AAC,CAAC,CAAC,CAAC,cAAc;gCACjD,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,aAAa;gCAChD,UAAU,EAAE,SAAS,CAAC,YAAY;gCAClC,iBAAiB,EAAE,IAAI,CAAC,WAAW;gCACnC,gBAAgB,EAAE,IAAI,CAAC,MAAM;6BAC9B,CAAA;wBACH,CAAC,CAAC;wBACJ,CAAC,CAAC;4BACE;gCACE,WAAW,EAAE,IAAI,CAAC,OAAO;gCACzB,YAAY,EAAE,IAAI,CAAC,QAAQ;gCAC3B,UAAU,EAAE,IAAI,CAAC,QAAQ;gCACzB,IAAI,EAAE,IAAI,CAAC,SAAS;gCACpB,WAAW,EAAE,MAAA,MAAA,MAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,oBAAoB,0CAAE,UAAU,0CAAE,IAAI,CACxE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,MAAM,CAC5B,0CAAE,IAAI;gCACP,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,qBAAqB;gCAC1D,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,oBAAoB;gCAC/D,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,cAAc;gCAC5C,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,aAAa;gCAC3C,UAAU,EAAE,IAAI,CAAC,YAAY;gCAC7B,iBAAiB,EAAE,IAAI,CAAC,WAAW;gCACnC,gBAAgB,EAAE,IAAI,CAAC,MAAM;6BAC9B;yBACF;iBACN,CAAA;gBACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;aACrB;YACD,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC;AApGD,0CAoGC","sourcesContent":["/* https://open.shopee.com/documents/v2/v2.product.get_item_base_info?module=89&type=1 */\n\nimport { StoreAPI } from '../../store-api'\n\nexport function getStoreProduct() {\n return {\n path: '/product/get_item_base_info',\n method: 'getV2',\n denormalize(req) {\n return {\n item_id_list: req.itemIds\n }\n },\n async normalize(res, { store }) {\n let items = res.item_list\n let results = []\n for (let i = 0; i < items.length; i++) {\n const item = items[i]\n let variations\n if (item.has_model) {\n variations = await StoreAPI.getStoreProductVariations(store, { itemId: item.item_id })\n }\n const result = {\n itemId: item.item_id,\n isku: item?.item_sku,\n weight: item.weight,\n categoryId: item.category_id,\n condition: item.condition,\n marketplaceStatus: item.item_status,\n name: item.item_name,\n description: item.description_info?.extended_description?.field_list?.find(f => f.field_type == 'text')?.text,\n currency: item?.price_info ? item?.price_info[0]?.currency : undefined,\n costPrice: item?.price_info ? item?.price_info[0]?.original_price : undefined,\n sellPrice: item?.price_info ? item?.price_info[0]?.current_price : undefined,\n qty: item?.stock_info_v2?.summary_info?.total_available_stock,\n bufferQty: item?.stock_info_v2?.summary_info?.total_reserved_stock,\n packageLength: item.dimension.package_length,\n packageWidth: item.dimension.package_width,\n packageHeight: item.dimension.package_height,\n daysToShip: item.pre_order.days_to_ship,\n discountId: item.promotion_id,\n isPreOrder: item.pre_order.is_pre_order,\n hasVariation: item.has_model,\n attributes: item?.attribute_list?.map(attribute => {\n return {\n attributeId: attribute.attribute_id,\n name: attribute.original_attribute_name,\n isMandatory: attribute.is_mandatory,\n originalValue: JSON.stringify(\n attribute?.attribute_value_list?.map(v => {\n return v.original_value_name\n })\n ) || ''\n }\n }) || [],\n variations: item.has_model\n ? variations.model.map(variation => {\n return {\n variationId: variation.model_id,\n variationSku: variation.model_sku,\n channelSku: variation.model_sku,\n name: `${item.item_name} - ${\n variations.tier_variation[0].option_list[variation.tier_index[0]].option\n }${\n variations.tier_variation[1]\n ? ' - ' + variations.tier_variation[1].option_list[variation.tier_index[1]].option\n : ''\n }`,\n description: item.description_info?.extended_description?.field_list?.find(\n f => f.field_type == 'text'\n )?.text,\n qty: variation.stock_info_v2.summary_info.total_available_stock,\n bufferQty: variation.stock_info_v2.summary_info.total_reserved_stock,\n costPrice: variation.price_info[0].original_price,\n sellPrice: variation.price_info[0].current_price,\n discountId: variation.promotion_id,\n marketplaceStatus: item.item_status,\n primaryUnitValue: item.weight\n }\n })\n : [\n {\n variationId: item.item_id,\n variationSku: item.item_sku,\n channelSku: item.item_sku,\n name: item.item_name,\n description: item.description_info?.extended_description?.field_list?.find(\n f => f.field_type == 'text'\n )?.text,\n qty: item.stock_info_v2.summary_info.total_available_stock,\n bufferQty: item.stock_info_v2.summary_info.total_reserved_stock,\n costPrice: item.price_info[0].original_price,\n sellPrice: item.price_info[0].current_price,\n discountId: item.promotion_id,\n marketplaceStatus: item.item_status,\n primaryUnitValue: item.weight\n }\n ]\n }\n results.push(result)\n }\n return results\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://open.shopee.com/documents/v2/v2.product.get_item_list?module=89&type=1 */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getStoreProducts = void 0;
|
|
5
|
+
const store_api_1 = require("../../store-api");
|
|
6
|
+
function getStoreProducts() {
|
|
7
|
+
return {
|
|
8
|
+
path: '/product/get_item_list',
|
|
9
|
+
method: 'getV2',
|
|
10
|
+
denormalize(req) {
|
|
11
|
+
var { pagination } = req || {};
|
|
12
|
+
var { page = 0, limit = 100 } = pagination || {};
|
|
13
|
+
return {
|
|
14
|
+
offset: page * limit,
|
|
15
|
+
page_size: limit,
|
|
16
|
+
item_status: ['NORMAL']
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
async normalize(res, { store }) {
|
|
20
|
+
const itemIds = res.item.map(product => {
|
|
21
|
+
return product.item_id;
|
|
22
|
+
});
|
|
23
|
+
const results = await store_api_1.StoreAPI.getStoreProduct(store, { itemIds });
|
|
24
|
+
return { results, total: res.total_count };
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.getStoreProducts = getStoreProducts;
|
|
29
|
+
//# sourceMappingURL=get-store-products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-store-products.js","sourceRoot":"","sources":["../../../../server/controllers/shopee/apis2/get-store-products.ts"],"names":[],"mappings":";AAAA,oFAAoF;;;AAEpF,+CAA0C;AAE1C,SAAgB,gBAAgB;IAC9B,OAAO;QACL,IAAI,EAAE,wBAAwB;QAC9B,MAAM,EAAE,OAAO;QACf,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAC9B,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,GAAG,UAAU,IAAI,EAAE,CAAA;YAEhD,OAAO;gBACL,MAAM,EAAE,IAAI,GAAG,KAAK;gBACpB,SAAS,EAAE,KAAK;gBAChB,WAAW,EAAE,CAAC,QAAQ,CAAC;aACxB,CAAA;QACH,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC5B,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;gBACrC,OAAO,OAAO,CAAC,OAAO,CAAA;YACxB,CAAC,CAAC,CAAA;YAEF,MAAM,OAAO,GAAG,MAAM,oBAAQ,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;YAClE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,WAAW,EAAE,CAAA;QAC5C,CAAC;KACF,CAAA;AACH,CAAC;AAvBD,4CAuBC","sourcesContent":["/* https://open.shopee.com/documents/v2/v2.product.get_item_list?module=89&type=1 */\n\nimport { StoreAPI } from '../../store-api'\n\nexport function getStoreProducts() {\n return {\n path: '/product/get_item_list',\n method: 'getV2',\n denormalize(req) {\n var { pagination } = req || {}\n var { page = 0, limit = 100 } = pagination || {}\n\n return {\n offset: page * limit,\n page_size: limit,\n item_status: ['NORMAL']\n }\n },\n async normalize(res, { store }) {\n const itemIds = res.item.map(product => {\n return product.item_id\n })\n\n const results = await StoreAPI.getStoreProduct(store, { itemIds })\n return { results, total: res.total_count }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://open.shopee.com/documents/v2/v2.returns.get_return_detail?module=102&type=1 */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getStoreRefundOrderDetails = void 0;
|
|
5
|
+
function getStoreRefundOrderDetails() {
|
|
6
|
+
return {
|
|
7
|
+
path: '/returns/get_return_detail',
|
|
8
|
+
method: 'getV2',
|
|
9
|
+
denormalize(req) {
|
|
10
|
+
var { refundOrderNo } = req;
|
|
11
|
+
return {
|
|
12
|
+
return_sn: refundOrderNo
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
async normalize(res) {
|
|
16
|
+
let refundItems = res.items.map(item => {
|
|
17
|
+
let { item_id: name, item_id: orderItemId, item_price: price, amount: qty, variation_id: variationId } = item;
|
|
18
|
+
name = name.toString();
|
|
19
|
+
orderItemId = orderItemId.toString();
|
|
20
|
+
return {
|
|
21
|
+
name,
|
|
22
|
+
orderItemId,
|
|
23
|
+
price,
|
|
24
|
+
qty,
|
|
25
|
+
variationId
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
let results = {
|
|
29
|
+
name: res.return_sn.toString(),
|
|
30
|
+
orderNo: res.return_sn.toString(),
|
|
31
|
+
amount: res.refund_amount,
|
|
32
|
+
status: res.status,
|
|
33
|
+
items: refundItems
|
|
34
|
+
};
|
|
35
|
+
return results;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
exports.getStoreRefundOrderDetails = getStoreRefundOrderDetails;
|
|
40
|
+
//# sourceMappingURL=get-store-refund-order-details.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-store-refund-order-details.js","sourceRoot":"","sources":["../../../../server/controllers/shopee/apis2/get-store-refund-order-details.ts"],"names":[],"mappings":";AAAA,yFAAyF;;;AAEzF,SAAgB,0BAA0B;IACxC,OAAO;QACL,IAAI,EAAE,4BAA4B;QAClC,MAAM,EAAE,OAAO;QACf,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,aAAa,EAAE,GAAG,GAAG,CAAA;YAE3B,OAAO;gBACL,SAAS,EAAE,aAAa;aACzB,CAAA;QACH,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,GAAG;YACjB,IAAI,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBACrC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;gBAC7G,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;gBACtB,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAA;gBACpC,OAAO;oBACL,IAAI;oBACJ,WAAW;oBACX,KAAK;oBACL,GAAG;oBACH,WAAW;iBACZ,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,IAAI,OAAO,GAAG;gBACZ,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE;gBAC9B,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE;gBACjC,MAAM,EAAE,GAAG,CAAC,aAAa;gBACzB,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,KAAK,EAAE,WAAW;aACnB,CAAA;YAED,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC;AApCD,gEAoCC","sourcesContent":["/* https://open.shopee.com/documents/v2/v2.returns.get_return_detail?module=102&type=1 */\n\nexport function getStoreRefundOrderDetails() {\n return {\n path: '/returns/get_return_detail',\n method: 'getV2',\n denormalize(req) {\n var { refundOrderNo } = req\n\n return {\n return_sn: refundOrderNo\n }\n },\n async normalize(res) {\n let refundItems = res.items.map(item => {\n let { item_id: name, item_id: orderItemId, item_price: price, amount: qty, variation_id: variationId } = item\n name = name.toString()\n orderItemId = orderItemId.toString()\n return {\n name,\n orderItemId,\n price,\n qty,\n variationId\n }\n })\n\n let results = {\n name: res.return_sn.toString(),\n orderNo: res.return_sn.toString(),\n amount: res.refund_amount,\n status: res.status,\n items: refundItems\n }\n\n return results\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://open.shopee.com/documents/v2/v2.returns.get_return_list?module=102&type=1 */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getStoreRefundOrders = void 0;
|
|
5
|
+
const store_api_1 = require("../../store-api");
|
|
6
|
+
function getStoreRefundOrders() {
|
|
7
|
+
return {
|
|
8
|
+
path: '/returns/get_return_list',
|
|
9
|
+
method: 'getV2',
|
|
10
|
+
denormalize(req) {
|
|
11
|
+
var { pagination, fromDate, toDate } = req || {};
|
|
12
|
+
var { page = 0, limit = 100 } = pagination || {};
|
|
13
|
+
var create_time_from = Math.floor(new Date(fromDate).getTime() / 1000);
|
|
14
|
+
var create_time_to = Math.floor(new Date(toDate).getTime() / 1000);
|
|
15
|
+
return {
|
|
16
|
+
page_size: limit,
|
|
17
|
+
page_no: page * limit,
|
|
18
|
+
create_time_from,
|
|
19
|
+
create_time_to
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
async normalize(res, { store }) {
|
|
23
|
+
var _a;
|
|
24
|
+
let results = [];
|
|
25
|
+
for (var i = 0; i < ((_a = res.return) === null || _a === void 0 ? void 0 : _a.length); i++) {
|
|
26
|
+
const refundOrder = res.return[i];
|
|
27
|
+
const refundOrderNo = refundOrder.return_sn;
|
|
28
|
+
const result = await store_api_1.StoreAPI.getStoreRefundOrderDetails(store, { refundOrderNo });
|
|
29
|
+
results.push(Object.assign(Object.assign({}, result), { originalOrderNo: refundOrder.order_sn }));
|
|
30
|
+
}
|
|
31
|
+
return { results, more: res.more };
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.getStoreRefundOrders = getStoreRefundOrders;
|
|
36
|
+
//# sourceMappingURL=get-store-refund-orders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-store-refund-orders.js","sourceRoot":"","sources":["../../../../server/controllers/shopee/apis2/get-store-refund-orders.ts"],"names":[],"mappings":";AAAA,uFAAuF;;;AAEvF,+CAA0C;AAE1C,SAAgB,oBAAoB;IAClC,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,MAAM,EAAE,OAAO;QACf,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAChD,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,GAAG,UAAU,IAAI,EAAE,CAAA;YAEhD,IAAI,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;YACtE,IAAI,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;YAElE,OAAO;gBACL,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,IAAI,GAAG,KAAK;gBACrB,gBAAgB;gBAChB,cAAc;aACf,CAAA;QACH,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;;YAC5B,IAAI,OAAO,GAAU,EAAE,CAAA;YAEvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAG,MAAA,GAAG,CAAC,MAAM,0CAAE,MAAM,CAAA,EAAE,CAAC,EAAE,EAAE;gBAC3C,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;gBACjC,MAAM,aAAa,GAAG,WAAW,CAAC,SAAS,CAAA;gBAE3C,MAAM,MAAM,GAAG,MAAM,oBAAQ,CAAC,0BAA0B,CAAC,KAAK,EAAE,EAAE,aAAa,EAAE,CAAC,CAAA;gBAElF,OAAO,CAAC,IAAI,iCAAM,MAAM,KAAE,eAAe,EAAE,WAAW,CAAC,QAAQ,IAAG,CAAA;aACnE;YACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAA;QACpC,CAAC;KACF,CAAA;AACH,CAAC;AAhCD,oDAgCC","sourcesContent":["/* https://open.shopee.com/documents/v2/v2.returns.get_return_list?module=102&type=1 */\n\nimport { StoreAPI } from '../../store-api'\n\nexport function getStoreRefundOrders() {\n return {\n path: '/returns/get_return_list',\n method: 'getV2',\n denormalize(req) {\n var { pagination, fromDate, toDate } = req || {}\n var { page = 0, limit = 100 } = pagination || {}\n\n var create_time_from = Math.floor(new Date(fromDate).getTime() / 1000)\n var create_time_to = Math.floor(new Date(toDate).getTime() / 1000)\n\n return {\n page_size: limit,\n page_no: page * limit,\n create_time_from,\n create_time_to\n }\n },\n async normalize(res, { store }) {\n let results: any[] = []\n\n for (var i = 0; i < res.return?.length; i++) {\n const refundOrder = res.return[i]\n const refundOrderNo = refundOrder.return_sn\n\n const result = await StoreAPI.getStoreRefundOrderDetails(store, { refundOrderNo })\n\n results.push({ ...result, originalOrderNo: refundOrder.order_sn })\n }\n return { results, more: res.more }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://open.shopee.com/documents/v2/v2.logistics.get_tracking_number?module=95&type=1 */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getTrackingNumber = void 0;
|
|
5
|
+
function getTrackingNumber() {
|
|
6
|
+
return {
|
|
7
|
+
path: '/logistics/get_tracking_number',
|
|
8
|
+
method: 'getV2',
|
|
9
|
+
denormalize(req) {
|
|
10
|
+
const { orderNo } = req;
|
|
11
|
+
return {
|
|
12
|
+
order_sn: orderNo
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
normalize(res) {
|
|
16
|
+
return (res === null || res === void 0 ? void 0 : res.tracking_number) || null;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.getTrackingNumber = getTrackingNumber;
|
|
21
|
+
//# sourceMappingURL=get-tracking-number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-tracking-number.js","sourceRoot":"","sources":["../../../../server/controllers/shopee/apis2/get-tracking-number.ts"],"names":[],"mappings":";AAAA,4FAA4F;;;AAE5F,SAAgB,iBAAiB;IAC/B,OAAO;QACL,IAAI,EAAE,gCAAgC;QACtC,MAAM,EAAE,OAAO;QACf,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;YACvB,OAAO;gBACL,QAAQ,EAAE,OAAO;aAClB,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,eAAe,KAAI,IAAI,CAAA;QACrC,CAAC;KACF,CAAA;AACH,CAAC;AAdD,8CAcC","sourcesContent":["/* https://open.shopee.com/documents/v2/v2.logistics.get_tracking_number?module=95&type=1 */\n\nexport function getTrackingNumber() {\n return {\n path: '/logistics/get_tracking_number',\n method: 'getV2',\n denormalize(req) {\n const { orderNo } = req\n return {\n order_sn: orderNo\n }\n },\n normalize(res) {\n return res?.tracking_number || null\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./echo"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./get-store-products"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./get-store-product"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./get-store-product-variations"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./get-store-orders"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./get-store-order"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./get-store-order-by-batch"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./get-store-order-transaction-details"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./update-store-product-stock"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./update-store-product-variation-stock"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./get-store-order-payout-dates"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./get-store-refund-orders"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./get-store-refund-order-details"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./get-store-logistics"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./get-logistics-param"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./get-tracking-number"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./init-logistics"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./create-shipping-document"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./get-shipping-document-result"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./get-store-order-document"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/shopee/apis2/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB;AACtB,+DAAoC;AACpC,8DAAmC;AACnC,yEAA8C;AAC9C,6DAAkC;AAClC,4DAAiC;AACjC,qEAA0C;AAC1C,gFAAqD;AACrD,uEAA4C;AAC5C,iFAAsD;AACtD,yEAA8C;AAC9C,oEAAyC;AACzC,2EAAgD;AAChD,gEAAqC;AACrC,gEAAqC;AACrC,gEAAqC;AACrC,2DAAgC;AAChC,qEAA0C;AAC1C,yEAA8C;AAC9C,qEAA0C","sourcesContent":["export * from './echo'\nexport * from './get-store-products'\nexport * from './get-store-product'\nexport * from './get-store-product-variations'\nexport * from './get-store-orders'\nexport * from './get-store-order'\nexport * from './get-store-order-by-batch'\nexport * from './get-store-order-transaction-details'\nexport * from './update-store-product-stock'\nexport * from './update-store-product-variation-stock'\nexport * from './get-store-order-payout-dates'\nexport * from './get-store-refund-orders'\nexport * from './get-store-refund-order-details'\nexport * from './get-store-logistics'\nexport * from './get-logistics-param'\nexport * from './get-tracking-number'\nexport * from './init-logistics'\nexport * from './create-shipping-document'\nexport * from './get-shipping-document-result'\nexport * from './get-store-order-document'\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://open.shopee.com/documents?module=3&type=1&id=389 */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.initLogistics = void 0;
|
|
5
|
+
function initLogistics() {
|
|
6
|
+
return {
|
|
7
|
+
path: '/logistics/ship_order',
|
|
8
|
+
method: 'postV2',
|
|
9
|
+
denormalize(req) {
|
|
10
|
+
var { orderNo: order_sn, deliveryType } = req;
|
|
11
|
+
let pickup = {};
|
|
12
|
+
let dropoff = {};
|
|
13
|
+
let non_integrated = {};
|
|
14
|
+
let args = {};
|
|
15
|
+
if (deliveryType === null || deliveryType === void 0 ? void 0 : deliveryType.pickup) {
|
|
16
|
+
var { addressId, pickupTimeId: pickup_time_id } = deliveryType.pickup;
|
|
17
|
+
var address_id = parseInt(addressId);
|
|
18
|
+
pickup = { address_id, pickup_time_id };
|
|
19
|
+
args = { order_sn, pickup: Object.assign({}, pickup) };
|
|
20
|
+
}
|
|
21
|
+
if (deliveryType === null || deliveryType === void 0 ? void 0 : deliveryType.non_integrated) {
|
|
22
|
+
var { trackingNo: tracking_number } = deliveryType.non_integrated;
|
|
23
|
+
non_integrated = { tracking_number };
|
|
24
|
+
args = { order_sn, non_integrated: { tracking_number } };
|
|
25
|
+
}
|
|
26
|
+
if (deliveryType === null || deliveryType === void 0 ? void 0 : deliveryType.dropoff) {
|
|
27
|
+
var { branchId: branch_id } = deliveryType.dropoff;
|
|
28
|
+
dropoff = { branch_id };
|
|
29
|
+
args = { order_sn, dropoff: Object.assign({}, dropoff) };
|
|
30
|
+
}
|
|
31
|
+
return args;
|
|
32
|
+
},
|
|
33
|
+
normalize(res) {
|
|
34
|
+
return res;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.initLogistics = initLogistics;
|
|
39
|
+
//# sourceMappingURL=init-logistics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-logistics.js","sourceRoot":"","sources":["../../../../server/controllers/shopee/apis2/init-logistics.ts"],"names":[],"mappings":";AAAA,8DAA8D;;;AAE9D,SAAgB,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,QAAQ;QAChB,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,GAAG,CAAA;YAC7C,IAAI,MAAM,GAAG,EAAE,CAAA;YACf,IAAI,OAAO,GAAG,EAAE,CAAA;YAChB,IAAI,cAAc,GAAG,EAAE,CAAA;YACvB,IAAI,IAAI,GAAG,EAAE,CAAA;YAEb,IAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,EAAE;gBACxB,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,YAAY,CAAC,MAAM,CAAA;gBACrE,IAAI,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAA;gBACpC,MAAM,GAAG,EAAE,UAAU,EAAE,cAAc,EAAE,CAAA;gBACvC,IAAI,GAAG,EAAE,QAAQ,EAAE,MAAM,oBAAO,MAAM,CAAE,EAAE,CAAA;aAC3C;YAED,IAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,cAAc,EAAE;gBAChC,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,YAAY,CAAC,cAAc,CAAA;gBACjE,cAAc,GAAG,EAAE,eAAe,EAAE,CAAA;gBACpC,IAAI,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,eAAe,EAAE,EAAE,CAAA;aACzD;YAED,IAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,EAAE;gBACzB,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC,OAAO,CAAA;gBAClD,OAAO,GAAG,EAAE,SAAS,EAAE,CAAA;gBACvB,IAAI,GAAG,EAAE,QAAQ,EAAE,OAAO,oBAAO,OAAO,CAAE,EAAE,CAAA;aAC7C;YAED,OAAO,IAAI,CAAA;QACb,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AApCD,sCAoCC","sourcesContent":["/* https://open.shopee.com/documents?module=3&type=1&id=389 */\n\nexport function initLogistics() {\n return {\n path: '/logistics/ship_order',\n method: 'postV2',\n denormalize(req) {\n var { orderNo: order_sn, deliveryType } = req\n let pickup = {}\n let dropoff = {}\n let non_integrated = {}\n let args = {}\n\n if (deliveryType?.pickup) {\n var { addressId, pickupTimeId: pickup_time_id } = deliveryType.pickup\n var address_id = parseInt(addressId)\n pickup = { address_id, pickup_time_id }\n args = { order_sn, pickup: { ...pickup } }\n }\n\n if (deliveryType?.non_integrated) {\n var { trackingNo: tracking_number } = deliveryType.non_integrated\n non_integrated = { tracking_number }\n args = { order_sn, non_integrated: { tracking_number } }\n }\n\n if (deliveryType?.dropoff) {\n var { branchId: branch_id } = deliveryType.dropoff\n dropoff = { branch_id }\n args = { order_sn, dropoff: { ...dropoff } }\n }\n\n return args\n },\n normalize(res) {\n return res\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://open.shopee.com/documents/v2/v2.product.update_stock?module=89&type=1 */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.updateStoreProductStock = void 0;
|
|
5
|
+
function updateStoreProductStock() {
|
|
6
|
+
return {
|
|
7
|
+
path: '/product/update_stock',
|
|
8
|
+
method: 'postV2',
|
|
9
|
+
denormalize(req) {
|
|
10
|
+
let data = req[0];
|
|
11
|
+
return {
|
|
12
|
+
item_id: parseInt(data.itemId),
|
|
13
|
+
stock_list: [
|
|
14
|
+
{
|
|
15
|
+
seller_stock: [
|
|
16
|
+
{
|
|
17
|
+
stock: data.qty
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
normalize(res) {
|
|
25
|
+
return res;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.updateStoreProductStock = updateStoreProductStock;
|
|
30
|
+
//# sourceMappingURL=update-store-product-stock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-store-product-stock.js","sourceRoot":"","sources":["../../../../server/controllers/shopee/apis2/update-store-product-stock.ts"],"names":[],"mappings":";AAAA,mFAAmF;;;AAEnF,SAAgB,uBAAuB;IACrC,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,QAAQ;QAChB,WAAW,CAAC,GAAG;YACb,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;YACjB,OAAO;gBACL,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC9B,UAAU,EAAE;oBACV;wBACE,YAAY,EAAE;4BACZ;gCACE,KAAK,EAAE,IAAI,CAAC,GAAG;6BAChB;yBACF;qBACF;iBACF;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAvBD,0DAuBC","sourcesContent":["/* https://open.shopee.com/documents/v2/v2.product.update_stock?module=89&type=1 */\n\nexport function updateStoreProductStock() {\n return {\n path: '/product/update_stock',\n method: 'postV2',\n denormalize(req) {\n let data = req[0]\n return {\n item_id: parseInt(data.itemId),\n stock_list: [\n {\n seller_stock: [\n {\n stock: data.qty\n }\n ]\n }\n ]\n }\n },\n normalize(res) {\n return res\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://open.shopee.com/documents/v2/v2.product.update_stock?module=89&type=1 */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.updateStoreProductVariationStock = void 0;
|
|
5
|
+
function updateStoreProductVariationStock() {
|
|
6
|
+
return {
|
|
7
|
+
path: '/product/update_stock',
|
|
8
|
+
method: 'postV2',
|
|
9
|
+
denormalize(req) {
|
|
10
|
+
let data = req[0];
|
|
11
|
+
return {
|
|
12
|
+
item_id: parseInt(data.itemId),
|
|
13
|
+
stock_list: [
|
|
14
|
+
{
|
|
15
|
+
model_id: parseInt(data.variationId),
|
|
16
|
+
seller_stock: [
|
|
17
|
+
{
|
|
18
|
+
stock: data.qty
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
normalize(res) {
|
|
26
|
+
return res;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.updateStoreProductVariationStock = updateStoreProductVariationStock;
|
|
31
|
+
//# sourceMappingURL=update-store-product-variation-stock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-store-product-variation-stock.js","sourceRoot":"","sources":["../../../../server/controllers/shopee/apis2/update-store-product-variation-stock.ts"],"names":[],"mappings":";AAAA,mFAAmF;;;AAGnF,SAAgB,gCAAgC;IAC9C,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,QAAQ;QAChB,WAAW,CAAC,GAAG;YACb,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;YACjB,OAAO;gBACL,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC9B,UAAU,EAAE;oBACV;wBACE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC;wBACpC,YAAY,EAAE;4BACZ;gCACE,KAAK,EAAE,IAAI,CAAC,GAAG;6BAChB;yBACF;qBACF;iBACF;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAxBD,4EAwBC","sourcesContent":["/* https://open.shopee.com/documents/v2/v2.product.update_stock?module=89&type=1 */\n\n\nexport function updateStoreProductVariationStock() {\n return {\n path: '/product/update_stock',\n method: 'postV2',\n denormalize(req) {\n let data = req[0]\n return {\n item_id: parseInt(data.itemId),\n stock_list: [\n {\n model_id: parseInt(data.variationId),\n seller_stock: [\n {\n stock: data.qty\n }\n ]\n }\n ]\n }\n },\n normalize(res) {\n return res\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.refreshAccessToken = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
6
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
7
|
+
const typeorm_1 = require("typeorm");
|
|
8
|
+
const env_1 = require("@things-factory/env");
|
|
9
|
+
const entities_1 = require("../../entities");
|
|
10
|
+
const shopeeConfig = env_1.config.get('marketplaceIntegrationShopee', {});
|
|
11
|
+
const { partnerId, partnerKey, isUAT } = shopeeConfig;
|
|
12
|
+
const refreshPath = '/auth/access_token/get';
|
|
13
|
+
const refreshAccessToken = async (store_uuid, shop_id, refresh_token, old_access_token) => {
|
|
14
|
+
let marketplaceStore = await (0, typeorm_1.getRepository)(entities_1.MarketplaceStore)
|
|
15
|
+
.createQueryBuilder('ms')
|
|
16
|
+
.where('ms.id = :id', { id: store_uuid })
|
|
17
|
+
.getOne();
|
|
18
|
+
if (old_access_token != marketplaceStore.accessToken) {
|
|
19
|
+
return {
|
|
20
|
+
accessToken: marketplaceStore.accessToken
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const timestamp = Math.floor(Date.now() / 1000);
|
|
24
|
+
const sign = crypto_1.default
|
|
25
|
+
.createHmac('sha256', partnerKey)
|
|
26
|
+
.update(partnerId + '/api/v2' + refreshPath + timestamp)
|
|
27
|
+
.digest('hex');
|
|
28
|
+
const auth = {
|
|
29
|
+
partner_id: partnerId,
|
|
30
|
+
sign: sign,
|
|
31
|
+
timestamp: timestamp
|
|
32
|
+
};
|
|
33
|
+
const qs = Object.entries(auth)
|
|
34
|
+
.map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
|
|
35
|
+
.join('&');
|
|
36
|
+
const data = {
|
|
37
|
+
refresh_token: refresh_token,
|
|
38
|
+
partner_id: partnerId,
|
|
39
|
+
shop_id: parseInt(shop_id)
|
|
40
|
+
};
|
|
41
|
+
const jsondata = JSON.stringify(data);
|
|
42
|
+
const response = await (0, node_fetch_1.default)(`${getAuthUrl()}?${qs}`, {
|
|
43
|
+
method: 'post',
|
|
44
|
+
body: jsondata
|
|
45
|
+
});
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
throw 'Failed to get response to refresh Shopee access token';
|
|
48
|
+
}
|
|
49
|
+
const result = await response.json();
|
|
50
|
+
if (result.error) {
|
|
51
|
+
env_1.logger.error(`Failed to refresh Shopee token: ${result.error} - shop ID (${shop_id})`);
|
|
52
|
+
throw result.error;
|
|
53
|
+
}
|
|
54
|
+
const tokens = {
|
|
55
|
+
accessToken: result.access_token,
|
|
56
|
+
refreshToken: result.refresh_token // expires in 30 days
|
|
57
|
+
};
|
|
58
|
+
await (0, typeorm_1.createQueryBuilder)().update(entities_1.MarketplaceStore).set(tokens).where('id = :id', { id: store_uuid }).execute();
|
|
59
|
+
return tokens;
|
|
60
|
+
};
|
|
61
|
+
exports.refreshAccessToken = refreshAccessToken;
|
|
62
|
+
function getAuthUrl() {
|
|
63
|
+
return `https://partner${isUAT ? '.test-stable' : ''}.shopeemobile.com/api/v2${refreshPath}`;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=refresh-access-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh-access-token.js","sourceRoot":"","sources":["../../../server/controllers/shopee/refresh-access-token.ts"],"names":[],"mappings":";;;;AAAA,4DAA2B;AAC3B,oEAA8B;AAC9B,qCAA2D;AAC3D,6CAAoD;AACpD,6CAAiD;AAEjD,MAAM,YAAY,GAAG,YAAM,CAAC,GAAG,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAA;AACnE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,YAAY,CAAA;AACrD,MAAM,WAAW,GAAG,wBAAwB,CAAA;AAErC,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,EAAE;IAC/F,IAAI,gBAAgB,GAAqB,MAAM,IAAA,uBAAa,EAAC,2BAAgB,CAAC;SAC3E,kBAAkB,CAAC,IAAI,CAAC;SACxB,KAAK,CAAC,aAAa,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;SACxC,MAAM,EAAE,CAAA;IAEX,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,WAAW,EAAE;QACpD,OAAO;YACL,WAAW,EAAE,gBAAg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C,KAAK,eAAe,OAAO,GAAG,CAAC,CAAA;QACtF,MAAM,MAAM,CAAC,KAAK,CAAA;KACnB;IAED,MAAM,MAAM,GAAG;QACb,WAAW,EAAE,MAAM,CAAC,YAAY;QAChC,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,qBAAqB;KACzD,CAAA;IAED,MAAM,IAAA,4BAAkB,GAAE,CAAC,MAAM,CAAC,2BAAgB,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAA;IAE/G,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AA5DY,QAAA,kBAAkB,sBA4D9B;AAED,SAAS,UAAU;IACjB,OAAO,kBAAkB,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,2BAA2B,WAAW,EAAE,CAAA;AAC9F,CAAC","sourcesContent":["import crypto from 'crypto'\nimport fetch from 'node-fetch'\nimport { createQueryBuilder, getRepository } from 'typeorm'\nimport { config, logger } from '@things-factory/env'\nimport { MarketplaceStore } from '../../entities'\n\nconst shopeeConfig = config.get('marketplaceIntegrationShopee', {})\nconst { partnerId, partnerKey, isUAT } = shopeeConfig\nconst refreshPath = '/auth/access_token/get'\n\nexport const refreshAccessToken = async (store_uuid, shop_id, refresh_token, old_access_token) => {\n let marketplaceStore: MarketplaceStore = await getRepository(MarketplaceStore)\n .createQueryBuilder('ms')\n .where('ms.id = :id', { id: store_uuid })\n .getOne()\n\n if (old_access_token != marketplaceStore.accessToken) {\n return {\n accessToken: marketplaceStore.accessToken\n }\n }\n\n const timestamp = Math.floor(Date.now() / 1000)\n const sign = crypto\n .createHmac('sha256', partnerKey)\n .update(partnerId + '/api/v2' + refreshPath + timestamp)\n .digest('hex')\n\n const auth = {\n partner_id: partnerId,\n sign: sign,\n timestamp: timestamp\n }\n\n const qs = Object.entries(auth)\n .map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)\n .join('&')\n\n const data = {\n refresh_token: refresh_token,\n partner_id: partnerId,\n shop_id: parseInt(shop_id)\n }\n\n const jsondata = JSON.stringify(data)\n\n const response = await fetch(`${getAuthUrl()}?${qs}`, {\n method: 'post',\n body: jsondata\n })\n\n if (!response.ok) {\n throw 'Failed to get response to refresh Shopee access token'\n }\n\n const result = await response.json()\n\n if (result.error) {\n logger.error(`Failed to refresh Shopee token: ${result.error} - shop ID (${shop_id})`)\n throw result.error\n }\n\n const tokens = {\n accessToken: result.access_token, // expires in 4 hours\n refreshToken: result.refresh_token // expires in 30 days\n }\n\n await createQueryBuilder().update(MarketplaceStore).set(tokens).where('id = :id', { id: store_uuid }).execute()\n\n return tokens\n}\n\nfunction getAuthUrl() {\n return `https://partner${isUAT ? '.test-stable' : ''}.shopeemobile.com/api/v2${refreshPath}`\n}\n"]}
|