@things-factory/integration-marketplace 4.2.3 → 4.2.8

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 (79) hide show
  1. package/dist-server/controllers/index.js +1 -0
  2. package/dist-server/controllers/index.js.map +1 -1
  3. package/dist-server/controllers/magento/apis/get-store-orders.js +2 -1
  4. package/dist-server/controllers/magento/apis/get-store-orders.js.map +1 -1
  5. package/dist-server/controllers/magento/apis/get-store-products.js +8 -9
  6. package/dist-server/controllers/magento/apis/get-store-products.js.map +1 -1
  7. package/dist-server/controllers/magento/apis/update-order-status.js +39 -14
  8. package/dist-server/controllers/magento/apis/update-order-status.js.map +1 -1
  9. package/dist-server/controllers/store-api/index.js +14 -0
  10. package/dist-server/controllers/store-api/index.js.map +1 -1
  11. package/dist-server/controllers/tiktok/apis/echo.js +19 -0
  12. package/dist-server/controllers/tiktok/apis/echo.js.map +1 -0
  13. package/dist-server/controllers/tiktok/apis/get-store-order-document.js +27 -0
  14. package/dist-server/controllers/tiktok/apis/get-store-order-document.js.map +1 -0
  15. package/dist-server/controllers/tiktok/apis/get-store-order-package.js +47 -0
  16. package/dist-server/controllers/tiktok/apis/get-store-order-package.js.map +1 -0
  17. package/dist-server/controllers/tiktok/apis/get-store-order-packages.js +39 -0
  18. package/dist-server/controllers/tiktok/apis/get-store-order-packages.js.map +1 -0
  19. package/dist-server/controllers/tiktok/apis/get-store-order.js +137 -0
  20. package/dist-server/controllers/tiktok/apis/get-store-order.js.map +1 -0
  21. package/dist-server/controllers/tiktok/apis/get-store-orders.js +47 -0
  22. package/dist-server/controllers/tiktok/apis/get-store-orders.js.map +1 -0
  23. package/dist-server/controllers/tiktok/apis/get-store-product-attributes.js +30 -0
  24. package/dist-server/controllers/tiktok/apis/get-store-product-attributes.js.map +1 -0
  25. package/dist-server/controllers/tiktok/apis/get-store-product-categories.js +28 -0
  26. package/dist-server/controllers/tiktok/apis/get-store-product-categories.js.map +1 -0
  27. package/dist-server/controllers/tiktok/apis/get-store-product.js +91 -0
  28. package/dist-server/controllers/tiktok/apis/get-store-product.js.map +1 -0
  29. package/dist-server/controllers/tiktok/apis/get-store-products.js +36 -0
  30. package/dist-server/controllers/tiktok/apis/get-store-products.js.map +1 -0
  31. package/dist-server/controllers/tiktok/apis/index.js +26 -0
  32. package/dist-server/controllers/tiktok/apis/index.js.map +1 -0
  33. package/dist-server/controllers/tiktok/apis/update-order-status.js +27 -0
  34. package/dist-server/controllers/tiktok/apis/update-order-status.js.map +1 -0
  35. package/dist-server/controllers/tiktok/apis/update-store-product-variation-price.js +28 -0
  36. package/dist-server/controllers/tiktok/apis/update-store-product-variation-price.js.map +1 -0
  37. package/dist-server/controllers/tiktok/apis/update-store-product-variation-stock.js +32 -0
  38. package/dist-server/controllers/tiktok/apis/update-store-product-variation-stock.js.map +1 -0
  39. package/dist-server/controllers/tiktok/client/index.js +15 -0
  40. package/dist-server/controllers/tiktok/client/index.js.map +1 -0
  41. package/dist-server/controllers/tiktok/client/signature.js +63 -0
  42. package/dist-server/controllers/tiktok/client/signature.js.map +1 -0
  43. package/dist-server/controllers/tiktok/client/tiktok.js +93 -0
  44. package/dist-server/controllers/tiktok/client/tiktok.js.map +1 -0
  45. package/dist-server/controllers/tiktok/client/types.js +3 -0
  46. package/dist-server/controllers/tiktok/client/types.js.map +1 -0
  47. package/dist-server/controllers/tiktok/index.js +30 -0
  48. package/dist-server/controllers/tiktok/index.js.map +1 -0
  49. package/dist-server/controllers/tiktok/platform-action.js +44 -0
  50. package/dist-server/controllers/tiktok/platform-action.js.map +1 -0
  51. package/dist-server/controllers/woocommerce/apis/get-store-products.js +17 -6
  52. package/dist-server/controllers/woocommerce/apis/get-store-products.js.map +1 -1
  53. package/package.json +2 -2
  54. package/server/controllers/index.ts +1 -0
  55. package/server/controllers/magento/apis/get-store-orders.ts +3 -1
  56. package/server/controllers/magento/apis/get-store-products.ts +1 -2
  57. package/server/controllers/magento/apis/update-order-status.ts +43 -15
  58. package/server/controllers/store-api/index.ts +6 -0
  59. package/server/controllers/tiktok/apis/echo.ts +14 -0
  60. package/server/controllers/tiktok/apis/get-store-order-document.ts +26 -0
  61. package/server/controllers/tiktok/apis/get-store-order-package.ts +46 -0
  62. package/server/controllers/tiktok/apis/get-store-order-packages.ts +43 -0
  63. package/server/controllers/tiktok/apis/get-store-order.ts +169 -0
  64. package/server/controllers/tiktok/apis/get-store-orders.ts +52 -0
  65. package/server/controllers/tiktok/apis/get-store-product-attributes.ts +29 -0
  66. package/server/controllers/tiktok/apis/get-store-product-categories.ts +27 -0
  67. package/server/controllers/tiktok/apis/get-store-product.ts +95 -0
  68. package/server/controllers/tiktok/apis/get-store-products.ts +38 -0
  69. package/server/controllers/tiktok/apis/index.ts +13 -0
  70. package/server/controllers/tiktok/apis/update-order-status.ts +22 -0
  71. package/server/controllers/tiktok/apis/update-store-product-variation-price.ts +24 -0
  72. package/server/controllers/tiktok/apis/update-store-product-variation-stock.ts +28 -0
  73. package/server/controllers/tiktok/client/index.ts +2 -0
  74. package/server/controllers/tiktok/client/signature.ts +78 -0
  75. package/server/controllers/tiktok/client/tiktok.ts +139 -0
  76. package/server/controllers/tiktok/client/types.ts +20 -0
  77. package/server/controllers/tiktok/index.ts +8 -0
  78. package/server/controllers/tiktok/platform-action.ts +48 -0
  79. package/server/controllers/woocommerce/apis/get-store-products.ts +33 -22
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-store-orders.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/get-store-orders.ts"],"names":[],"mappings":";AAAA,yEAAyE;;;AAEzE,+CAA0C;AAE1C,SAAgB,cAAc;IAC5B,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,oBAAoB;QAC1B,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAC5D,IAAI,EAAE,IAAI,EAAE,KAAK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WAAW,GAAQ,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;oBAClE,MAAM,YAAY,GAAU,MAAM,oBAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,CAAA;oBAChF,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;wBAC7B,OAAO,CAAC,IAAI,mBAAM,WAAW,EAAG,CAAA;oBAClC,CAAC,CAAC,CAAA;oBAEF,QAAQ,GAAG,EAAE,CAAA;iBACd;aACF;YAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;QACtC,CAAC;KACF,CAAA;AACH,CAAC;AA/CD,wCA+CC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /* https://bytedance.feishu.cn/docs/doccnDyz5Bbk26iOdejbBRBlLrb#WBz4V0 */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getStoreProductAttributes = void 0;
5
+ function getStoreProductAttributes() {
6
+ return {
7
+ method: 'get',
8
+ path: '/api/products/attributes',
9
+ denormalize(req) {
10
+ const { categoryId } = req;
11
+ return { payload: { category_id: categoryId } };
12
+ },
13
+ normalize(res) {
14
+ const { data } = res;
15
+ let results = [];
16
+ data.attributes.map(item => {
17
+ let result = {
18
+ id: item.id,
19
+ name: item.local_display_name,
20
+ attributeType: item.attribute_type,
21
+ parent: !item.is_leaf ? 0 : item.parent_id
22
+ };
23
+ results.push(result);
24
+ });
25
+ return results;
26
+ }
27
+ };
28
+ }
29
+ exports.getStoreProductAttributes = getStoreProductAttributes;
30
+ //# sourceMappingURL=get-store-product-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-store-product-attributes.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/get-store-product-attributes.ts"],"names":[],"mappings":";AAAA,yEAAyE;;;AAEzE,SAAgB,yBAAyB;IACvC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,0BAA0B;QAChC,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;YAC1B,OAAO,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,CAAA;QACjD,CAAC;QACD,SAAS,CAAC,GAAG;YACX,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;YAEpB,IAAI,OAAO,GAAQ,EAAE,CAAA;YACrB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBACzB,IAAI,MAAM,GAAQ;oBAChB,EAAE,EAAE,IAAI,CAAC,EAAE;oBACX,IAAI,EAAE,IAAI,CAAC,kBAAkB;oBAC7B,aAAa,EAAE,IAAI,CAAC,cAAc;oBAClC,MAAM,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS;iBAC3C,CAAA;gBAED,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YACtB,CAAC,CAAC,CAAA;YAEF,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC;AA1BD,8DA0BC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /* https://bytedance.feishu.cn/docs/doccnDyz5Bbk26iOdejbBRBlLrb#jIY8hJ */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getStoreProductCategories = void 0;
5
+ function getStoreProductCategories() {
6
+ return {
7
+ method: 'get',
8
+ path: '/api/products/categories',
9
+ denormalize(req) {
10
+ return { payload: {} };
11
+ },
12
+ normalize(res) {
13
+ const { data } = res;
14
+ let results = [];
15
+ data.category_list.map(item => {
16
+ let result = {
17
+ id: item.id,
18
+ name: item.local_display_name,
19
+ parent: item.is_leaf ? item.parent_id : 0
20
+ };
21
+ results.push(result);
22
+ });
23
+ return { results, total: 1 };
24
+ }
25
+ };
26
+ }
27
+ exports.getStoreProductCategories = getStoreProductCategories;
28
+ //# sourceMappingURL=get-store-product-categories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-store-product-categories.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/get-store-product-categories.ts"],"names":[],"mappings":";AAAA,yEAAyE;;;AAEzE,SAAgB,yBAAyB;IACvC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,0BAA0B;QAChC,WAAW,CAAC,GAAG;YACb,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAA;QACxB,CAAC;QACD,SAAS,CAAC,GAAG;YACX,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;YAEpB,IAAI,OAAO,GAAQ,EAAE,CAAA;YACrB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBAC5B,IAAI,MAAM,GAAQ;oBAChB,EAAE,EAAE,IAAI,CAAC,EAAE;oBACX,IAAI,EAAE,IAAI,CAAC,kBAAkB;oBAC7B,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;iBAC1C,CAAA;gBAED,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YACtB,CAAC,CAAC,CAAA;YAEF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAA;QAC9B,CAAC;KACF,CAAA;AACH,CAAC;AAxBD,8DAwBC"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ /* https://bytedance.feishu.cn/docs/doccnDyz5Bbk26iOdejbBRBlLrb#ytBXoS */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getStoreProduct = void 0;
5
+ /* status: 0-all, 1-draft, 2-pending, 3-failed, 4-live, 5-seller_deactivated,
6
+ 6-platform-deactivated, 7-freeze, 8-deleted
7
+ */
8
+ function getStoreProduct() {
9
+ return {
10
+ method: 'get',
11
+ path: '/api/products/details',
12
+ denormalize(req) {
13
+ var { productId } = req || {};
14
+ return { payload: { product_id: productId } };
15
+ },
16
+ async normalize(res) {
17
+ var _a, _b;
18
+ const { data } = res;
19
+ const productVariations = data.skus;
20
+ let variants = [];
21
+ if (productVariations && (productVariations === null || productVariations === void 0 ? void 0 : productVariations.length) > 0) {
22
+ variants = productVariations.map(variant => {
23
+ let totalProductQty = 0;
24
+ let stockInfos = variant.stock_infos;
25
+ stockInfos.map(stockInfo => {
26
+ totalProductQty += stockInfo.available_stock;
27
+ });
28
+ return {
29
+ variationId: variant.id,
30
+ variationSku: variant.seller_sku || variant.id.toString(),
31
+ channelSku: variant.seller_sku || variant.id.toString(),
32
+ name: data.product_name,
33
+ qty: totalProductQty,
34
+ primaryUnit: 'N/A',
35
+ primaryUnitValue: data.package_weight === '' ? null : parseFloat(data.package_weight),
36
+ costPrice: variant.price.original_price === '' ? null : parseFloat(variant.price.original_price),
37
+ sellPrice: variant.price.original_price === '' ? null : parseFloat(variant.price.original_price),
38
+ isEnabled: data.product_status == 4 ? true : false,
39
+ length: (data === null || data === void 0 ? void 0 : data.package_length) ? data.package_length * 10 : 1,
40
+ width: (data === null || data === void 0 ? void 0 : data.package_width) ? data.package_width * 10 : 1,
41
+ height: (data === null || data === void 0 ? void 0 : data.package_height) ? data.package_height * 10 : 1,
42
+ weight: data.package_weight === '' ? null : parseFloat(data.package_weight)
43
+ };
44
+ });
45
+ }
46
+ else {
47
+ variants = [
48
+ {
49
+ variationId: data.product_id,
50
+ variationSku: data.product_name,
51
+ channelSku: data.product_name,
52
+ name: data.product_name,
53
+ qty: 0,
54
+ primaryUnit: 'N/A',
55
+ primaryUnitValue: data.package_weight === '' ? null : parseFloat(data.package_weight),
56
+ costPrice: null,
57
+ sellPrice: null,
58
+ isEnabled: data.product_status == 4 ? true : false,
59
+ length: (data === null || data === void 0 ? void 0 : data.package_length) ? data.package_length * 10 : 1,
60
+ width: (data === null || data === void 0 ? void 0 : data.package_width) ? data.package_width * 10 : 1,
61
+ height: (data === null || data === void 0 ? void 0 : data.package_height) ? data.package_height * 10 : 1,
62
+ weight: data.package_weight === '' ? null : parseFloat(data.package_weight)
63
+ }
64
+ ];
65
+ }
66
+ const result = {
67
+ itemId: data.product_id,
68
+ name: data.product_name,
69
+ brand: ((_a = data === null || data === void 0 ? void 0 : data.brand) === null || _a === void 0 ? void 0 : _a.name) || null,
70
+ isVerified: data.product_status == 4 ? true : false,
71
+ categoryId: ((_b = data === null || data === void 0 ? void 0 : data.category_list) === null || _b === void 0 ? void 0 : _b.length) > 0 ? data.category_list[0].id : '',
72
+ images: getImageUrl(data.images),
73
+ variations: variants
74
+ };
75
+ return result;
76
+ }
77
+ };
78
+ }
79
+ exports.getStoreProduct = getStoreProduct;
80
+ function getImageUrl(images) {
81
+ let imageSrc = [];
82
+ if (images) {
83
+ images.map(image => {
84
+ image.url_list.map(url => {
85
+ imageSrc.push(url);
86
+ });
87
+ });
88
+ }
89
+ return imageSrc;
90
+ }
91
+ //# sourceMappingURL=get-store-product.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-store-product.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/get-store-product.ts"],"names":[],"mappings":";AAAA,yEAAyE;;;AAEzE;;EAEE;AAEF,SAAgB,eAAe;IAC7B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,uBAAuB;QAC7B,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,SAAS,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAE7B,OAAO,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,CAAA;QAC/C,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,GAAG;;YACjB,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;YAEpB,MAAM,iBAAiB,GAAU,IAAI,CAAC,IAAI,CAAA;YAE1C,IAAI,QAAQ,GAAU,EAAE,CAAA;YACxB,IAAI,iBAAiB,IA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,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBACvB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACpB,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;KACH;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /* https://bytedance.feishu.cn/docs/doccnDyz5Bbk26iOdejbBRBlLrb#ytBXoS */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getStoreProducts = void 0;
5
+ /* status: 0-all, 1-draft, 2-pending, 3-failed, 4-live, 5-seller_deactivated,
6
+ 6-platform-deactivated, 7-freeze, 8-deleted
7
+ */
8
+ const store_api_1 = require("../../store-api");
9
+ function getStoreProducts() {
10
+ return {
11
+ method: 'post',
12
+ path: '/api/products/search',
13
+ denormalize(req) {
14
+ var { pagination } = req || {};
15
+ var { page, limit } = pagination || { page: 0, limit: 100 };
16
+ return {
17
+ payload: { page_size: limit, page_number: page + 1, search_status: 0 },
18
+ resource: {}
19
+ };
20
+ },
21
+ async normalize(res, { store }) {
22
+ const { data } = res;
23
+ const products = (data === null || data === void 0 ? void 0 : data.products) || [];
24
+ const total = (data === null || data === void 0 ? void 0 : data.total) || 0;
25
+ let results = [];
26
+ for (let i = 0; i < products.length; i++) {
27
+ const product = products[i];
28
+ const productDetails = await store_api_1.StoreAPI.getStoreProduct(store, { productId: product.id });
29
+ results.push(Object.assign({}, productDetails));
30
+ }
31
+ return { results, total };
32
+ }
33
+ };
34
+ }
35
+ exports.getStoreProducts = getStoreProducts;
36
+ //# sourceMappingURL=get-store-products.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-store-products.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/get-store-products.ts"],"names":[],"mappings":";AAAA,yEAAyE;;;AAEzE;;EAEE;AAEF,+CAA0C;AAE1C,SAAgB,gBAAgB;IAC9B,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAA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? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./echo"), exports);
14
+ __exportStar(require("./get-store-order"), exports);
15
+ __exportStar(require("./get-store-orders"), exports);
16
+ __exportStar(require("./get-store-order-document"), exports);
17
+ __exportStar(require("./get-store-order-packages"), exports);
18
+ __exportStar(require("./get-store-order-package"), exports);
19
+ __exportStar(require("./get-store-product-attributes"), exports);
20
+ __exportStar(require("./get-store-product-categories"), exports);
21
+ __exportStar(require("./get-store-product"), exports);
22
+ __exportStar(require("./get-store-products"), exports);
23
+ __exportStar(require("./update-store-product-variation-stock"), exports);
24
+ __exportStar(require("./update-store-product-variation-price"), exports);
25
+ __exportStar(require("./update-order-status"), exports);
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,oDAAiC;AACjC,qDAAkC;AAClC,6DAA0C;AAC1C,6DAA0C;AAC1C,4DAAyC;AACzC,iEAA8C;AAC9C,iEAA8C;AAC9C,sDAAmC;AACnC,uDAAoC;AACpC,yEAAsD;AACtD,yEAAsD;AACtD,wDAAqC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateOrderStatus = void 0;
4
+ function updateOrderStatus() {
5
+ return {
6
+ path: '/api/order/rts',
7
+ method: 'post',
8
+ async denormalize(req, { store }) {
9
+ let { orderId, status } = req;
10
+ if (status == 'ready_to_ship') {
11
+ return {
12
+ payload: {
13
+ order_id: orderId
14
+ }
15
+ };
16
+ }
17
+ else {
18
+ return;
19
+ }
20
+ },
21
+ normalize(res) {
22
+ return res;
23
+ }
24
+ };
25
+ }
26
+ exports.updateOrderStatus = updateOrderStatus;
27
+ //# sourceMappingURL=update-order-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-order-status.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/update-order-status.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB;IAC/B,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,MAAM;QACd,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC9B,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;YAE7B,IAAI,MAAM,IAAI,eAAe,EAAE;gBAC7B,OAAO;oBACL,OAAO,EAAE;wBACP,QAAQ,EAAE,OAAO;qBAClB;iBACF,CAAA;aACF;iBAAM;gBACL,OAAM;aACP;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AArBD,8CAqBC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateStoreProductVariationPrice = void 0;
4
+ function updateStoreProductVariationPrice() {
5
+ return {
6
+ path: '/api/products/prices',
7
+ method: 'put',
8
+ denormalize(req) {
9
+ const { variationId, sellPrice, productId } = (Array.isArray(req) ? req[0] : req) || {};
10
+ return {
11
+ payload: {
12
+ product_id: productId,
13
+ skus: [
14
+ {
15
+ id: variationId,
16
+ original_price: sellPrice.toString()
17
+ }
18
+ ]
19
+ }
20
+ };
21
+ },
22
+ normalize(res) {
23
+ return res;
24
+ }
25
+ };
26
+ }
27
+ exports.updateStoreProductVariationPrice = updateStoreProductVariationPrice;
28
+ //# sourceMappingURL=update-store-product-variation-price.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-store-product-variation-price.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/update-store-product-variation-price.ts"],"names":[],"mappings":";;;AAAA,SAAgB,gCAAgC;IAC9C,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,MAAM,EAAE,KAAK;QACb,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YAEvF,OAAO;gBACL,OAAO,EAAE;oBACP,UAAU,EAAE,SAAS;oBACrB,IAAI,EAAE;wBACJ;4BACE,EAAE,EAAE,WAAW;4BACf,cAAc,EAAE,SAAS,CAAC,QAAQ,EAAE;yBACrC;qBACF;iBACF;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACT,OAAO,GAAG,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC;AAvBD,4EAuBC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateStoreProductVariationStock = void 0;
4
+ function updateStoreProductVariationStock() {
5
+ return {
6
+ method: 'put',
7
+ path: '/api/products/stocks',
8
+ denormalize(req) {
9
+ const { variationId, qty, itemId } = (Array.isArray(req) ? req[0] : req) || {};
10
+ return {
11
+ payload: {
12
+ product_id: itemId,
13
+ skus: [
14
+ {
15
+ id: variationId,
16
+ stock_infos: [
17
+ {
18
+ available_stock: qty
19
+ }
20
+ ]
21
+ }
22
+ ]
23
+ }
24
+ };
25
+ },
26
+ normalize(res) {
27
+ return res;
28
+ }
29
+ };
30
+ }
31
+ exports.updateStoreProductVariationStock = updateStoreProductVariationStock;
32
+ //# 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/tiktok/apis/update-store-product-variation-stock.ts"],"names":[],"mappings":";;;AAAA,SAAgB,gCAAgC;IAC9C,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,sBAAsB;QAC5B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YAE9E,OAAO;gBACL,OAAO,EAAE;oBACP,UAAU,EAAE,MAAM;oBAClB,IAAI,EAAE;wBACJ;4BACE,EAAE,EAAE,WAAW;4BACf,WAAW,EAAE;gCACX;oCACE,eAAe,EAAE,GAAG;iCACrB;6BACF;yBACF;qBACF;iBACF;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AA3BD,4EA2BC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./types"), exports);
14
+ __exportStar(require("./tiktok"), exports);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAuB;AACvB,2CAAwB"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.makePublicRequestParameters = exports.signRequest = void 0;
7
+ const crypto_1 = __importDefault(require("crypto"));
8
+ /**
9
+ * { key: value } => 'keyvalue'
10
+ * @param {Object} parameters
11
+ * @return {string} concatString
12
+ */
13
+ const concatObjectKeyValue = (parameters) => {
14
+ if (!parameters)
15
+ return '';
16
+ return Object.entries(parameters)
17
+ .sort(([k1, v1], [k2, v2]) => (k2 > k1 ? -1 : 1))
18
+ .map(([k, v]) => `${k}${v}`)
19
+ .join('');
20
+ };
21
+ /**
22
+ * Calculate a signature hash
23
+ * @param {string} appSecret
24
+ * @param {string} apiPath e.g. /order/get
25
+ * @param {Object} params
26
+ * @return {string} signature hash
27
+ */
28
+ const signRequest = (appSecret, apiPath, params) => {
29
+ const hash = crypto_1.default
30
+ .createHmac('sha256', appSecret)
31
+ .update(appSecret + apiPath + concatObjectKeyValue(params) + appSecret)
32
+ .digest('hex');
33
+ return hash;
34
+ };
35
+ exports.signRequest = signRequest;
36
+ /**
37
+ * Gather system and business parameters to compute signature
38
+ * @param {string} appKey
39
+ * @param {string} appSecret
40
+ * @param {string} apiPath
41
+ * @param {string?} accessToken
42
+ * @param {Parameter?} payload
43
+ * @return {SystemParameters}
44
+ */
45
+ function makePublicRequestParameters(appKey, appSecret, apiPath, accessToken, shopId, payload) {
46
+ const ts = Math.floor(new Date(new Date().toUTCString()).getTime() / 1000).toString();
47
+ const publicRequestParams = {
48
+ app_key: appKey,
49
+ timestamp: ts,
50
+ access_token: accessToken
51
+ };
52
+ let signatureParams = {
53
+ app_key: publicRequestParams.app_key,
54
+ timestamp: publicRequestParams.timestamp
55
+ };
56
+ if (shopId) {
57
+ publicRequestParams.shop_id = shopId;
58
+ signatureParams.shop_id = shopId;
59
+ }
60
+ return Object.assign(Object.assign({}, publicRequestParams), { sign: (0, exports.signRequest)(appSecret, apiPath, Object.assign(Object.assign({}, payload), signatureParams)) });
61
+ }
62
+ exports.makePublicRequestParameters = makePublicRequestParameters;
63
+ //# sourceMappingURL=signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/client/signature.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAG3B;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,CAAC,UAAqB,EAAU,EAAE;IAC7D,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAA;IAC1B,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;SAC9B,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAChD,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;SAC3B,IAAI,CAAC,EAAE,CAAC,CAAA;AACb,CAAC,CAAA;AAED;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,OAAe,EAAE,MAAiB,EAAU,EAAE;IAC3F,MAAM,IAAI,GAAG,gBAAM;SAChB,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC;SAC/B,MAAM,CAAC,SAAS,GAAG,OAAO,GAAG,oBAAoB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;SACtE,MAAM,CAAC,KAAK,CAAC,CAAA;IAEhB,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAPY,QAAA,WAAW,eAOvB;AAED;;;;;;;;GAQG;AACH,SAAgB,2BAA2B,CACzC,MAAc,EACd,SAAiB,EACjB,OAAe,EACf,WAAmB,EACnB,MAAc,EACd,OAAmB;IAEnB,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;IAErF,MAAM,mBAAmB,GAKrB;QACF,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,EAAE;QACb,YAAY,EAAE,WAAW;KAC1B,CAAA;IAED,IAAI,eAAe,GAAQ;QACzB,OAAO,EAAE,mBAAmB,CAAC,OAAO;QACpC,SAAS,EAAE,mBAAmB,CAAC,SAAS;KACzC,CAAA;IAED,IAAI,MAAM,EAAE;QACV,mBAAmB,CAAC,OAAO,GAAG,MAAM,CAAA;QAEpC,eAAe,CAAC,OAAO,GAAG,MAAM,CAAA;KACjC;IAED,uCACK,mBAAmB,KACtB,IAAI,EAAE,IAAA,mBAAW,EAAC,SAAS,EAAE,OAAO,kCAAO,OAAO,GAAK,eAAe,EAAG,IAC1E;AACH,CAAC;AApCD,kEAoCC"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Tiktok = void 0;
7
+ const node_fetch_1 = __importDefault(require("node-fetch"));
8
+ const signature_1 = require("./signature");
9
+ const debug = require('debug')('things-factory:integration-marketplace:tiktok');
10
+ class Tiktok {
11
+ constructor(config) {
12
+ this.config = Object.assign({}, config);
13
+ }
14
+ getBaseURL() {
15
+ return `https://open-api.tiktokglobalshop.com`;
16
+ }
17
+ /**
18
+ * @summary Get Method
19
+ * @description Using v3 API, map the consumer_key, consumer_secret to the endpoint path.
20
+ * X-WP-Total is to get the total items from the response
21
+ */
22
+ async get(path, params) {
23
+ const { appKey, appSecret, accessToken, channelShopId } = this.config;
24
+ const qs = Object.entries(Object.assign(Object.assign({}, params), (0, signature_1.makePublicRequestParameters)(appKey, appSecret, path, accessToken, channelShopId, params)))
25
+ .map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
26
+ .join('&');
27
+ const endpoint = `${this.getBaseURL()}${path}?${qs ? qs : ''}`;
28
+ debug('endpoint', endpoint);
29
+ const response = await (0, node_fetch_1.default)(endpoint, {
30
+ headers: {
31
+ 'Content-Type': 'application/json'
32
+ }
33
+ });
34
+ var result = {};
35
+ const resResult = await response.json();
36
+ result.data = resResult.data;
37
+ debug('response result', result);
38
+ return result;
39
+ }
40
+ async post(path, data = {}) {
41
+ const { appKey, appSecret, accessToken, channelShopId } = this.config;
42
+ debug('data', data);
43
+ const jsondata = JSON.stringify(data);
44
+ const { app_key, timestamp, access_token, sign, shop_id } = (0, signature_1.makePublicRequestParameters)(appKey, appSecret, path, accessToken, channelShopId);
45
+ const qs = Object.entries({
46
+ app_key,
47
+ timestamp,
48
+ access_token,
49
+ sign,
50
+ shop_id
51
+ })
52
+ .map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
53
+ .join('&');
54
+ const endpoint = `${this.getBaseURL()}${path}?${qs ? '&' + qs : ''}`;
55
+ const response = await (0, node_fetch_1.default)(endpoint, {
56
+ method: 'post',
57
+ headers: {
58
+ 'Content-Type': 'application/json'
59
+ },
60
+ body: jsondata
61
+ });
62
+ const result = await response.json();
63
+ debug('response result', result);
64
+ return result;
65
+ }
66
+ async put(path, data = {}) {
67
+ const { appKey, appSecret, accessToken, channelShopId } = this.config;
68
+ debug('data', data);
69
+ const jsondata = JSON.stringify(data);
70
+ const { app_key, timestamp, access_token, sign } = (0, signature_1.makePublicRequestParameters)(appKey, appSecret, path, accessToken, channelShopId);
71
+ const qs = Object.entries({
72
+ app_key,
73
+ timestamp,
74
+ access_token,
75
+ sign
76
+ })
77
+ .map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
78
+ .join('&');
79
+ const endpoint = `${this.getBaseURL()}${path}?${qs ? '&' + qs : ''}`;
80
+ const response = await (0, node_fetch_1.default)(endpoint, {
81
+ method: 'put',
82
+ headers: {
83
+ 'Content-Type': 'application/json'
84
+ },
85
+ body: jsondata
86
+ });
87
+ const result = await response.json();
88
+ debug('response result', result);
89
+ return result;
90
+ }
91
+ }
92
+ exports.Tiktok = Tiktok;
93
+ //# sourceMappingURL=tiktok.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiktok.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/client/tiktok.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAE9B,2CAAyD;AAGzD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,+CAA+C,CAAC,CAAA;AAS/E,MAAa,MAAM;IAGjB,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,qBACN,MAAM,CACV,CAAA;IACH,CAAC;IAED,UAAU;QACR,OAAO,uCAAuC,CAAA;IAChD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,MAAiB;QACvC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QAErE,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,iCACpB,MAAM,GACN,IAAA,uCAA2B,EAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,CAAC,EAC3F;aACC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aACxD,IAAI,CAAC,GAAG,CAAC,CAAA;QAEZ,MAAM,QAAQ,G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,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;QACpE,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,QAAQ,EAAE;YACrC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,QAAQ;SACf,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QACpC,KAAK,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAA;QAEhC,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AA5HD,wBA4HC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/client/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ __exportStar(require("./client"), exports);
26
+ const store_api_1 = require("../store-api");
27
+ const platform_action_1 = require("./platform-action");
28
+ const APIS = __importStar(require("./apis"));
29
+ store_api_1.StoreAPI.registerPlatform('tiktok', platform_action_1.action, APIS);
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/tiktok/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwB;AAExB,4CAAuC;AAEvC,uDAA0C;AAC1C,6CAA8B;AAE9B,oBAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,wBAAM,EAAE,IAAI,CAAC,CAAA"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.action = void 0;
4
+ const tiktok_1 = require("./client/tiktok");
5
+ function substitute(path, obj) {
6
+ var props = [];
7
+ var re = /{([^}]+)}/g;
8
+ var text;
9
+ while ((text = re.exec(path))) {
10
+ props.push(text[1]);
11
+ }
12
+ var result = path;
13
+ props.forEach(prop => {
14
+ let value = obj[prop.trim()];
15
+ result = result.replace(`{${prop}}`, value === undefined ? '' : value);
16
+ });
17
+ return result;
18
+ }
19
+ /**
20
+ * @summary Building Path Method and Payload
21
+ * @description After denormalise of data is done,
22
+ * platform API method will be called with its path and payload,
23
+ * this section is to build path and substitution of the resource in url as well as the payload for body request.
24
+ * Every Tiktok API call requires consumer_key, consumer_secret, access_token.
25
+ * consumer_key, consumer_secret, access_token are retrieved from tokencraft
26
+ * to avoid permission error from TikTok.
27
+ */
28
+ const action = async ({ store, method = 'get', path, request }) => {
29
+ const client = new tiktok_1.Tiktok({
30
+ appKey: store.accessKey || '5p6q6g',
31
+ appSecret: store.accessSecret || 'c30cf452265ab418514bb81fa49fc333aecbf081',
32
+ accessToken: store.accessToken,
33
+ channelShopId: store.channelShopId
34
+ });
35
+ const { resource = {}, payload = {} } = request;
36
+ path = substitute(path, resource);
37
+ var response = await client[method](path, payload);
38
+ if (response.code) {
39
+ throw response;
40
+ }
41
+ return response;
42
+ };
43
+ exports.action = action;
44
+ //# sourceMappingURL=platform-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-action.js","sourceRoot":"","sources":["../../../server/controllers/tiktok/platform-action.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AAExC,SAAS,UAAU,CAAC,IAAI,EAAE,GAAG;IAC3B,IAAI,KAAK,GAAG,EAAE,CAAA;IACd,IAAI,EAAE,GAAG,YAAY,CAAA;IACrB,IAAI,IAAI,CAAA;IAER,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;QAC7B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;KACpB;IAED,IAAI,MAAM,GAAG,IAAI,CAAA;IACjB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnB,IAAI,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAC5B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,GAAG,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;GAQG;AACI,MAAM,MAAM,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;IACvE,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;QACxB,MA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