@things-factory/operato-hub 4.3.397 → 4.3.398
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.
|
@@ -25,7 +25,7 @@ api_1.restfulApiRouter.post('/v1/company/upsert-product', middlewares_1.business
|
|
|
25
25
|
}
|
|
26
26
|
let patches = context.request.body.data;
|
|
27
27
|
const skus = patches.map(p => p.sku);
|
|
28
|
-
await Promise.all(patches.map(
|
|
28
|
+
await Promise.all(patches.map(p => {
|
|
29
29
|
if (!p.productDetails || p.productDetails.length === 0) {
|
|
30
30
|
throw new error_util_1.ApiError('E01', 'missing product detail');
|
|
31
31
|
}
|
|
@@ -36,6 +36,7 @@ api_1.restfulApiRouter.post('/v1/company/upsert-product', middlewares_1.business
|
|
|
36
36
|
where: { sku: (0, typeorm_1.In)(skus), domain },
|
|
37
37
|
relations: ['productDetails', 'productDetails.productBarcodes']
|
|
38
38
|
});
|
|
39
|
+
checkProductDetails(patches, _foundRecords);
|
|
39
40
|
const _updateRecords = patches.filter((patch) => _foundRecords.some(foundRecord => foundRecord.sku === patch.sku));
|
|
40
41
|
const _createRecords = patches.filter((createPatch) => !_updateRecords.some(updateRecord => updateRecord.sku === createPatch.sku));
|
|
41
42
|
if (_createRecords.length > 0) {
|
|
@@ -62,7 +63,7 @@ api_1.restfulApiRouter.post('/v1/company/upsert-product', middlewares_1.business
|
|
|
62
63
|
}
|
|
63
64
|
// Set up response body
|
|
64
65
|
const updatedResults = results.map(product => {
|
|
65
|
-
const { domain, updater, bizplace, creator, creatorId, updaterId } = product, updatedProduct = __rest(product, ["domain", "updater", "bizplace", "creator", "creatorId", "updaterId"]);
|
|
66
|
+
const { id, domain, updater, bizplace, creator, creatorId, updaterId, domainId, bizplaceId, productRefId, parentProductRefId, routingId } = product, updatedProduct = __rest(product, ["id", "domain", "updater", "bizplace", "creator", "creatorId", "updaterId", "domainId", "bizplaceId", "productRefId", "parentProductRefId", "routingId"]);
|
|
66
67
|
const updatedProductDetails = product.productDetails.map(detail => {
|
|
67
68
|
const { name } = detail, restDetail = __rest(detail, ["name"]);
|
|
68
69
|
return restDetail;
|
|
@@ -82,4 +83,26 @@ api_1.restfulApiRouter.post('/v1/company/upsert-product', middlewares_1.business
|
|
|
82
83
|
(0, error_util_1.throwInternalServerError)(context, e);
|
|
83
84
|
}
|
|
84
85
|
});
|
|
86
|
+
function checkProductDetails(params, data) {
|
|
87
|
+
params.forEach(param => {
|
|
88
|
+
const filteredPd = param.productDetails.filter(item => item.isDefault === true);
|
|
89
|
+
if (filteredPd.length > 1) {
|
|
90
|
+
throw new error_util_1.ApiError('E01', 'cannot have more than one isDefault params true');
|
|
91
|
+
}
|
|
92
|
+
if (filteredPd.length == 0) {
|
|
93
|
+
const foundProduct = data.find(item => item.sku === param.sku); //no records found means new product being added
|
|
94
|
+
if (!foundProduct) {
|
|
95
|
+
throw new error_util_1.ApiError('E01', 'isDefault params need to have atleast one true');
|
|
96
|
+
}
|
|
97
|
+
const foundIsDefaultProdDetail = foundProduct.productDetails.find(itm => itm.isDefault === true);
|
|
98
|
+
const matchProductDetail = param.productDetails.find(pd => pd.packingSize === foundIsDefaultProdDetail.packingSize &&
|
|
99
|
+
pd.packingType === foundIsDefaultProdDetail.packingType &&
|
|
100
|
+
pd.uom === foundIsDefaultProdDetail.uom);
|
|
101
|
+
if (matchProductDetail) {
|
|
102
|
+
throw new error_util_1.ApiError('E01', 'isDefault params need to have atleast one true');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return params;
|
|
107
|
+
}
|
|
85
108
|
//# sourceMappingURL=upsert-product.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsert-product.js","sourceRoot":"","sources":["../../../../../../server/routers/api/restful-apis/v1/company/upsert-product.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,qCAIgB;AAEhB,6CAAgE;AAChE,+DAMqC;AAErC,gDAIuB;AACvB,oDAI4B;AAE5B,sBAAM,CAAC,IAAI,CACT,4BAA4B,EAC5B,gCAAkB,EAClB,kCAAoB,EACpB,+BAAiB,EACjB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACtB,IAAI;QACF,MAAM,IAAA,uBAAa,GAAE,CAAC,WAAW,CAAC,KAAK,EAAE,EAAiB,EAAE,EAAE;YAC5D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YAChC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAC7C,MAAM,IAAI,qBAAQ,CAAC,KAAK,EAAE,4BAA4B,CAAC,CAAA;aACxD;YAED,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA;YACvC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;YAEpC,MAAM,OAAO,CAAC,GAAG,CACf,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"upsert-product.js","sourceRoot":"","sources":["../../../../../../server/routers/api/restful-apis/v1/company/upsert-product.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,qCAIgB;AAEhB,6CAAgE;AAChE,+DAMqC;AAErC,gDAIuB;AACvB,oDAI4B;AAE5B,sBAAM,CAAC,IAAI,CACT,4BAA4B,EAC5B,gCAAkB,EAClB,kCAAoB,EACpB,+BAAiB,EACjB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACtB,IAAI;QACF,MAAM,IAAA,uBAAa,GAAE,CAAC,WAAW,CAAC,KAAK,EAAE,EAAiB,EAAE,EAAE;YAC5D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YAChC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,C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,CAAC,CAAA;SAC7E;QAED,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,EAAE;YAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,CAAA,CAAC,gDAAgD;YAE/G,IAAI,CAAC,YAAY,EAAE;gBACjB,MAAM,IAAI,qBAAQ,CAAC,KAAK,EAAE,gDAAgD,CAAC,CAAA;aAC5E;YACD,MAAM,wBAAwB,GAAG,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,IAAI,CAAC,CAAA;YAEhG,MAAM,kBAAkB,GAAG,KAAK,CAAC,cAAc,CAAC,IAAI,CAClD,EAAE,CAAC,EAAE,CACH,EAAE,CAAC,WAAW,KAAK,wBAAwB,CAAC,WAAW;gBACvD,EAAE,CAAC,WAAW,KAAK,wBAAwB,CAAC,WAAW;gBACvD,EAAE,CAAC,GAAG,KAAK,wBAAwB,CAAC,GAAG,CAC1C,CAAA;YAED,IAAI,kBAAkB,EAAE;gBACtB,MAAM,IAAI,qBAAQ,CAAC,KAAK,EAAE,gDAAgD,CAAC,CAAA;aAC5E;SACF;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
|
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.398",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@things-factory/i18n-base": "^4.3.381",
|
|
78
78
|
"@things-factory/import-ui": "^4.3.381",
|
|
79
79
|
"@things-factory/import-ui-excel": "^4.3.381",
|
|
80
|
-
"@things-factory/integration-accounting": "^4.3.
|
|
80
|
+
"@things-factory/integration-accounting": "^4.3.398",
|
|
81
81
|
"@things-factory/integration-fulfillment": "^4.3.381",
|
|
82
82
|
"@things-factory/integration-lmd": "^4.3.395",
|
|
83
83
|
"@things-factory/integration-marketplace": "^4.3.395",
|
|
@@ -86,13 +86,13 @@
|
|
|
86
86
|
"@things-factory/integration-sellercraft": "^4.3.395",
|
|
87
87
|
"@things-factory/integration-sftp": "^4.3.381",
|
|
88
88
|
"@things-factory/lite-menu": "^4.3.381",
|
|
89
|
-
"@things-factory/marketplace-base": "^4.3.
|
|
89
|
+
"@things-factory/marketplace-base": "^4.3.398",
|
|
90
90
|
"@things-factory/more-ui": "^4.3.381",
|
|
91
91
|
"@things-factory/notification": "^4.3.381",
|
|
92
92
|
"@things-factory/pdf": "^4.3.381",
|
|
93
|
-
"@things-factory/product-ui": "^4.3.
|
|
93
|
+
"@things-factory/product-ui": "^4.3.398",
|
|
94
94
|
"@things-factory/resource-ui": "^4.3.381",
|
|
95
|
-
"@things-factory/sales-base": "^4.3.
|
|
95
|
+
"@things-factory/sales-base": "^4.3.398",
|
|
96
96
|
"@things-factory/scene-data-transform": "^4.3.381",
|
|
97
97
|
"@things-factory/scene-excel": "^4.3.381",
|
|
98
98
|
"@things-factory/scene-firebase": "^4.3.381",
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
"@things-factory/shell": "^4.3.381",
|
|
109
109
|
"@things-factory/system-ui": "^4.3.381",
|
|
110
110
|
"@things-factory/transport-base": "^4.3.381",
|
|
111
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
112
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
111
|
+
"@things-factory/warehouse-base": "^4.3.398",
|
|
112
|
+
"@things-factory/worksheet-base": "^4.3.398",
|
|
113
113
|
"cron-parser": "^4.7.0",
|
|
114
114
|
"koa2-swagger-ui": "^5.0.2",
|
|
115
115
|
"swagger-jsdoc": "^5.0.0",
|
|
@@ -121,5 +121,5 @@
|
|
|
121
121
|
"resolutions": {
|
|
122
122
|
"core-js": "^3.16.0"
|
|
123
123
|
},
|
|
124
|
-
"gitHead": "
|
|
124
|
+
"gitHead": "ccc4a07675eba5fec19a27fded4d0c56291e62e2"
|
|
125
125
|
}
|
|
@@ -42,7 +42,7 @@ router.post(
|
|
|
42
42
|
const skus = patches.map(p => p.sku)
|
|
43
43
|
|
|
44
44
|
await Promise.all(
|
|
45
|
-
patches.map(
|
|
45
|
+
patches.map(p => {
|
|
46
46
|
if (!p.productDetails || p.productDetails.length === 0) {
|
|
47
47
|
throw new ApiError('E01', 'missing product detail')
|
|
48
48
|
}
|
|
@@ -57,6 +57,8 @@ router.post(
|
|
|
57
57
|
relations: ['productDetails', 'productDetails.productBarcodes']
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
+
checkProductDetails(patches, _foundRecords)
|
|
61
|
+
|
|
60
62
|
const _updateRecords = patches.filter((patch: any) =>
|
|
61
63
|
_foundRecords.some(foundRecord => foundRecord.sku === patch.sku)
|
|
62
64
|
)
|
|
@@ -93,7 +95,21 @@ router.post(
|
|
|
93
95
|
|
|
94
96
|
// Set up response body
|
|
95
97
|
const updatedResults = results.map(product => {
|
|
96
|
-
const {
|
|
98
|
+
const {
|
|
99
|
+
id,
|
|
100
|
+
domain,
|
|
101
|
+
updater,
|
|
102
|
+
bizplace,
|
|
103
|
+
creator,
|
|
104
|
+
creatorId,
|
|
105
|
+
updaterId,
|
|
106
|
+
domainId,
|
|
107
|
+
bizplaceId,
|
|
108
|
+
productRefId,
|
|
109
|
+
parentProductRefId,
|
|
110
|
+
routingId,
|
|
111
|
+
...updatedProduct
|
|
112
|
+
} = product
|
|
97
113
|
|
|
98
114
|
const updatedProductDetails = product.productDetails.map(detail => {
|
|
99
115
|
const { name, ...restDetail } = detail
|
|
@@ -117,3 +133,35 @@ router.post(
|
|
|
117
133
|
}
|
|
118
134
|
}
|
|
119
135
|
)
|
|
136
|
+
|
|
137
|
+
function checkProductDetails(params, data) {
|
|
138
|
+
params.forEach(param => {
|
|
139
|
+
const filteredPd = param.productDetails.filter(item => item.isDefault === true)
|
|
140
|
+
|
|
141
|
+
if (filteredPd.length > 1) {
|
|
142
|
+
throw new ApiError('E01', 'cannot have more than one isDefault params true')
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (filteredPd.length == 0) {
|
|
146
|
+
const foundProduct = data.find(item => item.sku === param.sku) //no records found means new product being added
|
|
147
|
+
|
|
148
|
+
if (!foundProduct) {
|
|
149
|
+
throw new ApiError('E01', 'isDefault params need to have atleast one true')
|
|
150
|
+
}
|
|
151
|
+
const foundIsDefaultProdDetail = foundProduct.productDetails.find(itm => itm.isDefault === true)
|
|
152
|
+
|
|
153
|
+
const matchProductDetail = param.productDetails.find(
|
|
154
|
+
pd =>
|
|
155
|
+
pd.packingSize === foundIsDefaultProdDetail.packingSize &&
|
|
156
|
+
pd.packingType === foundIsDefaultProdDetail.packingType &&
|
|
157
|
+
pd.uom === foundIsDefaultProdDetail.uom
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
if (matchProductDetail) {
|
|
161
|
+
throw new ApiError('E01', 'isDefault params need to have atleast one true')
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
return params
|
|
167
|
+
}
|