@pinelab/vendure-plugin-qls-fulfillment 1.0.0-beta.7 → 1.0.0-beta.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.
|
@@ -132,6 +132,7 @@ let QlsProductService = class QlsProductService {
|
|
|
132
132
|
}
|
|
133
133
|
core_1.Logger.info(`Created ${createdQlsProductsCount} products in QLS`, constants_1.loggerCtx);
|
|
134
134
|
core_1.Logger.info(`Updated ${updatedQlsProductsCount} products in QLS`, constants_1.loggerCtx);
|
|
135
|
+
core_1.Logger.info(`Finished full sync with ${failedCount} failures`, constants_1.loggerCtx);
|
|
135
136
|
return {
|
|
136
137
|
updatedInQls: updatedQlsProductsCount,
|
|
137
138
|
createdInQls: createdQlsProductsCount,
|
|
@@ -292,13 +293,22 @@ let QlsProductService = class QlsProductService {
|
|
|
292
293
|
// No updates needed
|
|
293
294
|
return false;
|
|
294
295
|
}
|
|
296
|
+
// Add additional EANs
|
|
297
|
+
eansToUpdate.eansToAdd = (0, util_2.normalizeEans)(eansToUpdate.eansToAdd);
|
|
295
298
|
await Promise.all(eansToUpdate.eansToAdd.map((ean) => client.addBarcode(qlsProduct.id, ean)));
|
|
299
|
+
if (eansToUpdate.eansToAdd.length > 0) {
|
|
300
|
+
core_1.Logger.info(`Added additional EANs: ${eansToUpdate.eansToAdd.join(',')} to product '${qlsProduct.sku}' in QLS`, constants_1.loggerCtx);
|
|
301
|
+
}
|
|
302
|
+
// Remove EANs, normalize first
|
|
303
|
+
eansToUpdate.eansToRemove = (0, util_2.normalizeEans)(eansToUpdate.eansToRemove);
|
|
296
304
|
// get barcode ID's to remove, because deletion goes via barcode ID, not barcode value
|
|
297
305
|
const barcodeIdsToRemove = qlsProduct.barcodes
|
|
298
306
|
.filter((barcode) => eansToUpdate.eansToRemove.includes(barcode.barcode))
|
|
299
307
|
.map((barcode) => barcode.id);
|
|
300
308
|
await Promise.all(barcodeIdsToRemove.map((barcodeId) => client.removeBarcode(qlsProduct.id, barcodeId)));
|
|
301
|
-
|
|
309
|
+
if (eansToUpdate.eansToRemove.length > 0) {
|
|
310
|
+
core_1.Logger.info(`Removed EANs '${eansToUpdate.eansToRemove.join(',')} from product '${qlsProduct.sku}' in QLS`, constants_1.loggerCtx);
|
|
311
|
+
}
|
|
302
312
|
return true;
|
|
303
313
|
}
|
|
304
314
|
/**
|
|
@@ -9,9 +9,9 @@ const util_1 = require("./util");
|
|
|
9
9
|
desiredEans: ['456', '123'],
|
|
10
10
|
})).toBe(false);
|
|
11
11
|
});
|
|
12
|
-
(0, vitest_1.it)('ignores ordering, whitespace
|
|
12
|
+
(0, vitest_1.it)('ignores ordering, whitespace, null/undefined and empty stringswhen determining additions', () => {
|
|
13
13
|
(0, vitest_1.expect)((0, util_1.getEansToUpdate)({
|
|
14
|
-
existingEans: [null, '123'],
|
|
14
|
+
existingEans: [null, '123', ''],
|
|
15
15
|
desiredEans: [' 123', '456 ', undefined, null],
|
|
16
16
|
})).toEqual({
|
|
17
17
|
eansToAdd: ['456'],
|