@pinelab/vendure-plugin-qls-fulfillment 1.0.0-beta.10 → 1.0.0-beta.11

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.
@@ -133,6 +133,7 @@ let QlsOrderService = class QlsOrderService {
133
133
  ...(additionalOrderFields ?? {}),
134
134
  };
135
135
  const result = await client.createFulfillmentOrder(qlsOrder);
136
+ core_2.Logger.info(`Successfully created order '${order.code}' in QLS with id '${result.id}'`, constants_1.loggerCtx);
136
137
  await this.orderService.addNoteToOrder(ctx, {
137
138
  id: orderId,
138
139
  isPublic: false,
@@ -89,6 +89,8 @@ let QlsProductService = class QlsProductService {
89
89
  * 4. Updates products in QLS if needed
90
90
  */
91
91
  async runFullSync(ctx) {
92
+ // Wait for 700ms to avoid rate limit of 500/5 minutes
93
+ const waitToPreventRateLimit = () => new Promise((resolve) => setTimeout(resolve, 700));
92
94
  try {
93
95
  const client = await (0, qls_client_1.getQlsClient)(ctx, this.options);
94
96
  if (!client) {
@@ -123,14 +125,15 @@ let QlsProductService = class QlsProductService {
123
125
  updatedQlsProductsCount += 1;
124
126
  }
125
127
  if (result === 'created' || result === 'updated') {
126
- // Wait for 700ms to avoid rate limit of 500/5 minutes, but only if we created or updated a product, otherwise no calls have been made yet.
127
- await new Promise((resolve) => setTimeout(resolve, 700));
128
+ // Wait only if we created or updated a product, otherwise no calls have been made yet.
129
+ await waitToPreventRateLimit();
128
130
  }
129
131
  }
130
132
  catch (e) {
131
133
  const error = (0, catch_unknown_1.asError)(e);
132
134
  core_1.Logger.error(`Error creating or updating variant '${variant.sku}' in QLS: ${error.message}`, constants_1.loggerCtx, error.stack);
133
135
  failedCount += 1;
136
+ await waitToPreventRateLimit();
134
137
  }
135
138
  }
136
139
  core_1.Logger.info(`Created ${createdQlsProductsCount} products in QLS`, constants_1.loggerCtx);
@@ -295,7 +298,9 @@ let QlsProductService = class QlsProductService {
295
298
  existingEans: existingAdditionalEANs,
296
299
  desiredEans: additionalEANs,
297
300
  });
298
- if (!eansToUpdate || eansToUpdate.eansToAdd.length === 0 && eansToUpdate.eansToRemove.length === 0) {
301
+ if (!eansToUpdate ||
302
+ (eansToUpdate.eansToAdd.length === 0 &&
303
+ eansToUpdate.eansToRemove.length === 0)) {
299
304
  // No updates needed
300
305
  return false;
301
306
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinelab/vendure-plugin-qls-fulfillment",
3
- "version": "1.0.0-beta.10",
3
+ "version": "1.0.0-beta.11",
4
4
  "description": "Vendure plugin to fulfill orders via QLS.",
5
5
  "keywords": [
6
6
  "fulfillment",