@things-factory/operato-hub 4.3.2 → 4.3.5
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/graphql/resolvers/synchronization/sync-products-to-sellercraft.js +54 -48
- package/dist-server/graphql/resolvers/synchronization/sync-products-to-sellercraft.js.map +1 -1
- package/package.json +8 -8
- package/server/graphql/resolvers/synchronization/sync-products-to-sellercraft.ts +61 -56
|
@@ -5,57 +5,63 @@ const biz_base_1 = require("@things-factory/biz-base");
|
|
|
5
5
|
const integration_fulfillment_1 = require("@things-factory/integration-fulfillment");
|
|
6
6
|
const integration_sellercraft_1 = require("@things-factory/integration-sellercraft");
|
|
7
7
|
const product_base_1 = require("@things-factory/product-base");
|
|
8
|
+
const env_1 = require("@things-factory/env");
|
|
8
9
|
exports.syncProductsToSellercraftResolver = {
|
|
9
10
|
async syncProductsToSellercraft(_, { sellercraftId, fulfillmentCenterId }, context) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
let sellercraftInv = [];
|
|
27
|
-
await Promise.all(items.map(async (item) => {
|
|
28
|
-
const product = await tx.getRepository(product_base_1.Product).findOne({
|
|
29
|
-
where: { domain, sku: item.productSKU },
|
|
30
|
-
relations: ['productDetails', 'productDetails.childProductDetail']
|
|
11
|
+
try {
|
|
12
|
+
const { domain, tx } = context.state;
|
|
13
|
+
let page = 1;
|
|
14
|
+
let hasMorePage = true;
|
|
15
|
+
const limit = 50;
|
|
16
|
+
const sellercraft = await tx
|
|
17
|
+
.getRepository(integration_sellercraft_1.Sellercraft)
|
|
18
|
+
.findOne({ where: { id: sellercraftId }, relations: ['domain'] });
|
|
19
|
+
const customerDomain = sellercraft.domain;
|
|
20
|
+
const fulfilmentCenter = await integration_fulfillment_1.FulfillmentAPI.getFulfillmentCenter(fulfillmentCenterId);
|
|
21
|
+
const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({ where: { domain: customerDomain } });
|
|
22
|
+
while (hasMorePage) {
|
|
23
|
+
const { items, total } = await integration_fulfillment_1.FulfillmentAPI.getInventoryProductGroupOpenAPI(fulfilmentCenter, {
|
|
24
|
+
warehouseId: customerBizplace.id,
|
|
25
|
+
paginationEntriesPerPage: limit,
|
|
26
|
+
paginationOffset: page
|
|
31
27
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
28
|
+
let sellercraftInv = [];
|
|
29
|
+
await Promise.all(items.map(async (item) => {
|
|
30
|
+
const product = await tx.getRepository(product_base_1.Product).findOne({
|
|
31
|
+
where: { domain, sku: item.productSKU },
|
|
32
|
+
relations: ['productDetails', 'productDetails.childProductDetail']
|
|
33
|
+
});
|
|
34
|
+
const productDetails = product.productDetails;
|
|
35
|
+
const defaultProductDetail = productDetails.find(productDetail => productDetail.isDefault);
|
|
36
|
+
let packingSize = 1;
|
|
37
|
+
sellercraftInv.push({
|
|
38
|
+
sku: item.productSKU,
|
|
39
|
+
gtin: (defaultProductDetail === null || defaultProductDetail === void 0 ? void 0 : defaultProductDetail.gtin) ? defaultProductDetail.gtin : '',
|
|
40
|
+
stock: {
|
|
41
|
+
quantity_total: item.totalQty * packingSize,
|
|
42
|
+
quantity_reserved: item.totalLockedQty * packingSize,
|
|
43
|
+
unit_of_measure: 'EA'
|
|
44
|
+
},
|
|
45
|
+
package_weight_gm: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
46
|
+
package_dimensions: {
|
|
47
|
+
length_mm: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
48
|
+
width_mm: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
49
|
+
height_mm: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}));
|
|
53
|
+
const delay = (ms) => {
|
|
54
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
55
|
+
};
|
|
56
|
+
await delay(5000);
|
|
57
|
+
await integration_sellercraft_1.SellercraftAPI.updateProduct(sellercraft, { accountId: sellercraft.accountId, sellercraftInv });
|
|
58
|
+
if ((sellercraftInv === null || sellercraftInv === void 0 ? void 0 : sellercraftInv.length) != 0 && (sellercraftInv === null || sellercraftInv === void 0 ? void 0 : sellercraftInv.length) < total)
|
|
59
|
+
page++;
|
|
60
|
+
hasMorePage = Boolean((sellercraftInv === null || sellercraftInv === void 0 ? void 0 : sellercraftInv.length) != 0 && (sellercraftInv === null || sellercraftInv === void 0 ? void 0 : sellercraftInv.length) < total);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
env_1.logger.error(`syncProductsToSellercraftResolver: ${e}`);
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-products-to-sellercraft.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/sync-products-to-sellercraft.ts"],"names":[],"mappings":";;;AAEA,uDAAmD;AACnD,qFAA2F;AAC3F,qFAAqF;AACrF,+DAAqE;
|
|
1
|
+
{"version":3,"file":"sync-products-to-sellercraft.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/sync-products-to-sellercraft.ts"],"names":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AgB,EAAE;YACjD,MAAM,IAAI,KAAK,CAAC,kDAAkD,uBAAuB,CAAC,IAAI,GAAG,CAAC,CAAA;SACnG;KACF;IAED,OAAO,WAAW,CAAA;AACpB,CAAC;AA9CD,kDA8CC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-hub",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.5",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -80,17 +80,17 @@
|
|
|
80
80
|
"@things-factory/integration-accounting": "^4.3.2",
|
|
81
81
|
"@things-factory/integration-fulfillment": "^4.3.2",
|
|
82
82
|
"@things-factory/integration-lmd": "^4.3.2",
|
|
83
|
-
"@things-factory/integration-marketplace": "^4.3.
|
|
83
|
+
"@things-factory/integration-marketplace": "^4.3.5",
|
|
84
84
|
"@things-factory/integration-pos": "^4.3.2",
|
|
85
|
-
"@things-factory/integration-sellercraft": "^4.3.
|
|
86
|
-
"@things-factory/integration-sftp": "^4.3.
|
|
85
|
+
"@things-factory/integration-sellercraft": "^4.3.5",
|
|
86
|
+
"@things-factory/integration-sftp": "^4.3.5",
|
|
87
87
|
"@things-factory/lite-menu": "^4.3.2",
|
|
88
88
|
"@things-factory/more-ui": "^4.3.2",
|
|
89
89
|
"@things-factory/notification": "^4.3.2",
|
|
90
90
|
"@things-factory/pdf": "^4.3.2",
|
|
91
91
|
"@things-factory/product-ui": "^4.3.2",
|
|
92
92
|
"@things-factory/resource-ui": "^4.3.2",
|
|
93
|
-
"@things-factory/sales-base": "^4.3.
|
|
93
|
+
"@things-factory/sales-base": "^4.3.5",
|
|
94
94
|
"@things-factory/scene-data-transform": "^4.3.2",
|
|
95
95
|
"@things-factory/scene-excel": "^4.3.2",
|
|
96
96
|
"@things-factory/scene-firebase": "^4.3.2",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"@things-factory/setting-ui": "^4.3.2",
|
|
106
106
|
"@things-factory/shell": "^4.3.2",
|
|
107
107
|
"@things-factory/system-ui": "^4.3.2",
|
|
108
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
109
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
108
|
+
"@things-factory/warehouse-base": "^4.3.5",
|
|
109
|
+
"@things-factory/worksheet-base": "^4.3.5",
|
|
110
110
|
"koa2-swagger-ui": "^5.0.2",
|
|
111
111
|
"swagger-jsdoc": "^5.0.0",
|
|
112
112
|
"yamljs": "^0.3.0"
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"resolutions": {
|
|
118
118
|
"core-js": "^3.16.0"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "67b6e7dec5c062108f68b22bcb0b20c67ef61610"
|
|
121
121
|
}
|
|
@@ -5,6 +5,7 @@ import { FulfillmentAPI, FulfillmentCenter } from '@things-factory/integration-f
|
|
|
5
5
|
import { Sellercraft, SellercraftAPI } from '@things-factory/integration-sellercraft'
|
|
6
6
|
import { Product, ProductDetail } from '@things-factory/product-base'
|
|
7
7
|
import { Domain } from '@things-factory/shell'
|
|
8
|
+
import { logger } from '@things-factory/env'
|
|
8
9
|
|
|
9
10
|
export const syncProductsToSellercraftResolver = {
|
|
10
11
|
async syncProductsToSellercraft(
|
|
@@ -15,67 +16,71 @@ export const syncProductsToSellercraftResolver = {
|
|
|
15
16
|
}: { sellercraftId: string; fulfillmentCenterId: string; toCreateSku: boolean },
|
|
16
17
|
context: any
|
|
17
18
|
): Promise<void> {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
let sellercraftInv: any[] = []
|
|
39
|
-
|
|
40
|
-
await Promise.all(
|
|
41
|
-
items.map(async item => {
|
|
42
|
-
const product: Product = await tx.getRepository(Product).findOne({
|
|
43
|
-
where: { domain, sku: item.productSKU },
|
|
44
|
-
relations: ['productDetails', 'productDetails.childProductDetail']
|
|
45
|
-
})
|
|
19
|
+
try {
|
|
20
|
+
const { domain, tx }: { domain: Domain; tx: EntityManager } = context.state
|
|
21
|
+
|
|
22
|
+
let page: number = 1
|
|
23
|
+
let hasMorePage: boolean = true
|
|
24
|
+
const limit: number = 50
|
|
25
|
+
|
|
26
|
+
const sellercraft: Sellercraft = await tx
|
|
27
|
+
.getRepository(Sellercraft)
|
|
28
|
+
.findOne({ where: { id: sellercraftId }, relations: ['domain'] })
|
|
29
|
+
const customerDomain: Domain = sellercraft.domain
|
|
30
|
+
const fulfilmentCenter: FulfillmentCenter = await FulfillmentAPI.getFulfillmentCenter(fulfillmentCenterId)
|
|
31
|
+
const customerBizplace: Bizplace = await tx.getRepository(Bizplace).findOne({ where: { domain: customerDomain } })
|
|
32
|
+
|
|
33
|
+
while (hasMorePage) {
|
|
34
|
+
const { items, total } = await FulfillmentAPI.getInventoryProductGroupOpenAPI(fulfilmentCenter, {
|
|
35
|
+
warehouseId: customerBizplace.id,
|
|
36
|
+
paginationEntriesPerPage: limit,
|
|
37
|
+
paginationOffset: page
|
|
38
|
+
})
|
|
46
39
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
40
|
+
let sellercraftInv: any[] = []
|
|
41
|
+
|
|
42
|
+
await Promise.all(
|
|
43
|
+
items.map(async item => {
|
|
44
|
+
const product: Product = await tx.getRepository(Product).findOne({
|
|
45
|
+
where: { domain, sku: item.productSKU },
|
|
46
|
+
relations: ['productDetails', 'productDetails.childProductDetail']
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const productDetails: ProductDetail[] = product.productDetails
|
|
50
|
+
const defaultProductDetail: ProductDetail = productDetails.find(productDetail => productDetail.isDefault)
|
|
51
|
+
|
|
52
|
+
let packingSize: number = 1
|
|
53
|
+
|
|
54
|
+
sellercraftInv.push({
|
|
55
|
+
sku: item.productSKU,
|
|
56
|
+
gtin: defaultProductDetail?.gtin ? defaultProductDetail.gtin : '',
|
|
57
|
+
stock: {
|
|
58
|
+
quantity_total: item.totalQty * packingSize,
|
|
59
|
+
quantity_reserved: item.totalLockedQty * packingSize,
|
|
60
|
+
unit_of_measure: 'EA'
|
|
61
|
+
},
|
|
62
|
+
package_weight_gm: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
63
|
+
package_dimensions: {
|
|
64
|
+
length_mm: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
65
|
+
width_mm: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
66
|
+
height_mm: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
67
|
+
}
|
|
68
|
+
})
|
|
66
69
|
})
|
|
67
|
-
|
|
68
|
-
)
|
|
70
|
+
)
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
const delay = (ms: number) => {
|
|
73
|
+
return new Promise(resolve => setTimeout(resolve, ms))
|
|
74
|
+
}
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
await delay(5000)
|
|
77
|
+
await SellercraftAPI.updateProduct(sellercraft, { accountId: sellercraft.accountId, sellercraftInv })
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
if (sellercraftInv?.length != 0 && sellercraftInv?.length < total) page++
|
|
80
|
+
hasMorePage = Boolean(sellercraftInv?.length != 0 && sellercraftInv?.length < total)
|
|
81
|
+
}
|
|
82
|
+
} catch (e) {
|
|
83
|
+
logger.error(`syncProductsToSellercraftResolver: ${e}`)
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
}
|