@pinelab/vendure-plugin-qls-fulfillment 2.0.1 → 2.0.2
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
# 2.0.2 (2026-07-01)
|
|
2
|
+
|
|
3
|
+
- Verify barcode deletion in QLS by fetching remaining barcodes after removal attempt
|
|
4
|
+
- Emit `QlsVariantSyncFailedEvent` and log an error when barcodes fail to be removed from QLS
|
|
5
|
+
|
|
1
6
|
# 2.0.1 (2026-06-15)
|
|
2
7
|
|
|
3
8
|
- Fixed fulfillment product detail type
|
package/dist/lib/qls-client.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ export declare class QlsClient {
|
|
|
25
25
|
updateFulfillmentProduct(fulfillmentProductId: string, data: FulfillmentProductInput): Promise<void>;
|
|
26
26
|
deleteFulfillmentProduct(fulfillmentProductId: string): Promise<void>;
|
|
27
27
|
createFulfillmentOrder(data: Omit<FulfillmentOrderInput, 'brand_id'>): Promise<FulfillmentOrder>;
|
|
28
|
+
/**
|
|
29
|
+
* Get all barcodes for a fulfillment product in QLS
|
|
30
|
+
*/
|
|
31
|
+
getBarcodes(productId: string): Promise<FulfillmentProduct['barcodes']>;
|
|
28
32
|
/**
|
|
29
33
|
* Add an extra barcode to a fulfillment product in QLS
|
|
30
34
|
*/
|
package/dist/lib/qls-client.js
CHANGED
|
@@ -85,6 +85,13 @@ class QlsClient {
|
|
|
85
85
|
}
|
|
86
86
|
return response.data;
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Get all barcodes for a fulfillment product in QLS
|
|
90
|
+
*/
|
|
91
|
+
async getBarcodes(productId) {
|
|
92
|
+
const result = await this.rawRequest('GET', `fulfillment/products/${productId}/barcodes`);
|
|
93
|
+
return result.data ?? [];
|
|
94
|
+
}
|
|
88
95
|
/**
|
|
89
96
|
* Add an extra barcode to a fulfillment product in QLS
|
|
90
97
|
*/
|
|
@@ -335,7 +335,7 @@ let QlsProductService = class QlsProductService {
|
|
|
335
335
|
core_1.Logger.info(`Set QLS product ID for variant '${variant.sku}' to ${qlsProduct.id}`, constants_1.loggerCtx);
|
|
336
336
|
}
|
|
337
337
|
if (qlsProduct) {
|
|
338
|
-
const updatedEANs = await this.updateAdditionalEANs(ctx, client, qlsProduct, additionalEANs);
|
|
338
|
+
const updatedEANs = await this.updateAdditionalEANs(ctx, client, qlsProduct, additionalEANs, variant);
|
|
339
339
|
if (createdOrUpdated === 'not-changed' && updatedEANs) {
|
|
340
340
|
// If nothing changed so far, but EANs changed, then we did update the product in QLS
|
|
341
341
|
createdOrUpdated = 'updated';
|
|
@@ -349,7 +349,7 @@ let QlsProductService = class QlsProductService {
|
|
|
349
349
|
/**
|
|
350
350
|
* Update the additional EANs/barcodes for a product in QLS if needed
|
|
351
351
|
*/
|
|
352
|
-
async updateAdditionalEANs(ctx, client, qlsProduct, additionalEANs) {
|
|
352
|
+
async updateAdditionalEANs(ctx, client, qlsProduct, additionalEANs, variant) {
|
|
353
353
|
const existingAdditionalEANs = qlsProduct?.barcodes_and_ean.filter((ean) => ean !== qlsProduct.ean); // Remove the main EAN
|
|
354
354
|
const eansToUpdate = (0, util_2.getEansToUpdate)({
|
|
355
355
|
existingEans: existingAdditionalEANs,
|
|
@@ -374,8 +374,16 @@ let QlsProductService = class QlsProductService {
|
|
|
374
374
|
.filter((barcode) => eansToUpdate.eansToRemove.includes(barcode.barcode))
|
|
375
375
|
.map((barcode) => barcode.id);
|
|
376
376
|
await Promise.all(barcodeIdsToRemove.map((barcodeId) => client.removeBarcode(qlsProduct.id, barcodeId)));
|
|
377
|
-
|
|
378
|
-
|
|
377
|
+
// Fetch remaining barcodes from QLS to verify deletion worked
|
|
378
|
+
const remainingBarcodes = await client.getBarcodes(qlsProduct.id);
|
|
379
|
+
const remainingEansToRemove = eansToUpdate.eansToRemove.filter((ean) => remainingBarcodes.some((barcode) => barcode.barcode === ean));
|
|
380
|
+
if (remainingEansToRemove.length > 0) {
|
|
381
|
+
const errorMessage = `Failed to remove EANs '${remainingEansToRemove.join(',')}' from product '${qlsProduct.sku}' in QLS. Barcodes still present after deletion attempt.`;
|
|
382
|
+
core_1.Logger.error(errorMessage, constants_1.loggerCtx);
|
|
383
|
+
await this.eventBus.publish(new qls_variant_sync_failed_event_1.QlsVariantSyncFailedEvent(ctx, variant, new Date(), errorMessage));
|
|
384
|
+
}
|
|
385
|
+
else if (eansToUpdate.eansToRemove.length > 0) {
|
|
386
|
+
core_1.Logger.info(`Removed EANs '${eansToUpdate.eansToRemove.join(',')}' from product '${qlsProduct.sku}' in QLS`, constants_1.loggerCtx);
|
|
379
387
|
}
|
|
380
388
|
return true;
|
|
381
389
|
}
|