@pinelab/vendure-plugin-qls-fulfillment 1.0.0-beta.7 → 1.0.0-beta.9

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,
@@ -277,6 +278,9 @@ let QlsProductService = class QlsProductService {
277
278
  createdOrUpdated = 'updated';
278
279
  }
279
280
  }
281
+ if (createdOrUpdated === 'not-changed') {
282
+ core_1.Logger.info(`Variant '${variant.sku}' not updated in QLS, because no changes were found.`, constants_1.loggerCtx);
283
+ }
280
284
  return createdOrUpdated;
281
285
  }
282
286
  /**
@@ -288,17 +292,26 @@ let QlsProductService = class QlsProductService {
288
292
  existingEans: existingAdditionalEANs,
289
293
  desiredEans: additionalEANs,
290
294
  });
291
- if (!eansToUpdate) {
295
+ if (!eansToUpdate || eansToUpdate.eansToAdd.length === 0 && eansToUpdate.eansToRemove.length === 0) {
292
296
  // No updates needed
293
297
  return false;
294
298
  }
299
+ // Add additional EANs
300
+ eansToUpdate.eansToAdd = (0, util_2.normalizeEans)(eansToUpdate.eansToAdd);
295
301
  await Promise.all(eansToUpdate.eansToAdd.map((ean) => client.addBarcode(qlsProduct.id, ean)));
302
+ if (eansToUpdate.eansToAdd.length > 0) {
303
+ core_1.Logger.info(`Added additional EANs: ${eansToUpdate.eansToAdd.join(',')} to product '${qlsProduct.sku}' in QLS`, constants_1.loggerCtx);
304
+ }
305
+ // Remove EANs, normalize first
306
+ eansToUpdate.eansToRemove = (0, util_2.normalizeEans)(eansToUpdate.eansToRemove);
296
307
  // get barcode ID's to remove, because deletion goes via barcode ID, not barcode value
297
308
  const barcodeIdsToRemove = qlsProduct.barcodes
298
309
  .filter((barcode) => eansToUpdate.eansToRemove.includes(barcode.barcode))
299
310
  .map((barcode) => barcode.id);
300
311
  await Promise.all(barcodeIdsToRemove.map((barcodeId) => client.removeBarcode(qlsProduct.id, barcodeId)));
301
- core_1.Logger.info(`Added additional EANs '${eansToUpdate.eansToAdd.join(',')}', and removed EANs '${eansToUpdate.eansToRemove.join(',')}' for product '${qlsProduct.sku}' in QLS`, constants_1.loggerCtx);
312
+ if (eansToUpdate.eansToRemove.length > 0) {
313
+ core_1.Logger.info(`Removed EANs '${eansToUpdate.eansToRemove.join(',')} from product '${qlsProduct.sku}' in QLS`, constants_1.loggerCtx);
314
+ }
302
315
  return true;
303
316
  }
304
317
  /**
@@ -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 and null/undefined when determining additions', () => {
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'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinelab/vendure-plugin-qls-fulfillment",
3
- "version": "1.0.0-beta.7",
3
+ "version": "1.0.0-beta.9",
4
4
  "description": "Vendure plugin to fulfill orders via QLS.",
5
5
  "keywords": [
6
6
  "fulfillment",