@pinelab/vendure-plugin-qls-fulfillment 1.1.0 → 1.1.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,13 @@
1
+ # 1.1.2 (2026-01-14)
2
+
3
+ - Run scheduled full sync without job queue, because scheduled tasks already run in the worker only.
4
+ - Export scheduled task instead of automatically adding it to the config.
5
+
6
+ # 1.1.1 (2026-01-07)
7
+
8
+ - Ignoring non-existing order codes in order status updates, instead of throwing an error.
9
+ - Update `syncedToQls` custom field inside same transaction, to prevent `Query runner already released. Cannot run queries anymore` errors.
10
+
1
11
  # 1.1.0 (2026-01-07)
2
12
 
3
13
  - Fix delivery options to be an array of objects with a tag property
@@ -0,0 +1,5 @@
1
+ import { ScheduledTask } from '@vendure/core';
2
+ /**
3
+ * Synchronize all products to QLS for all channels, every day at 3:00 AM.
4
+ */
5
+ export declare const qlsSyncAllProductsTask: ScheduledTask<{}>;
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fullProductSyncTask = void 0;
3
+ exports.qlsSyncAllProductsTask = void 0;
4
4
  const core_1 = require("@vendure/core");
5
5
  const qls_product_service_1 = require("../services/qls-product.service");
6
6
  const constants_1 = require("../constants");
7
- exports.fullProductSyncTask = new core_1.ScheduledTask({
7
+ /**
8
+ * Synchronize all products to QLS for all channels, every day at 3:00 AM.
9
+ */
10
+ exports.qlsSyncAllProductsTask = new core_1.ScheduledTask({
8
11
  id: 'full-sync-qls-products',
9
12
  description: 'Trigger a full sync of products to QLS',
10
13
  params: {},
@@ -16,7 +19,7 @@ exports.fullProductSyncTask = new core_1.ScheduledTask({
16
19
  apiType: 'admin',
17
20
  });
18
21
  const channels = await injector.get(core_1.ChannelService).findAll(ctx);
19
- let triggeredFullSync = 0;
22
+ let fullSyncCompleted = 0;
20
23
  for (const channel of channels.items) {
21
24
  // Create ctx for channel
22
25
  const channelCtx = new core_1.RequestContext({
@@ -32,11 +35,11 @@ exports.fullProductSyncTask = new core_1.ScheduledTask({
32
35
  core_1.Logger.info(`QLS not enabled for channel ${channel.token}`, constants_1.loggerCtx);
33
36
  continue;
34
37
  }
35
- await qlsProductService.triggerFullSync(ctx);
36
- triggeredFullSync += 1;
38
+ await qlsProductService.runFullSync(channelCtx);
39
+ fullSyncCompleted += 1;
37
40
  }
38
41
  return {
39
- message: `Triggered full sync for ${triggeredFullSync} channels`,
42
+ message: `Finnished full sync for ${fullSyncCompleted} channels`,
40
43
  };
41
44
  },
42
45
  });
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './api/generated/graphql';
2
- export * from './config/full-product-sync-task';
2
+ export * from './config/sync-products-scheduled-task';
3
3
  export * from './custom-fields';
4
4
  export * from './lib/client-types';
5
5
  export * from './lib/qls-client';
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./api/generated/graphql"), exports);
18
- __exportStar(require("./config/full-product-sync-task"), exports);
18
+ __exportStar(require("./config/sync-products-scheduled-task"), exports);
19
19
  __exportStar(require("./custom-fields"), exports);
20
20
  __exportStar(require("./lib/client-types"), exports);
21
21
  __exportStar(require("./lib/qls-client"), exports);
@@ -164,17 +164,17 @@ let QlsOrderService = class QlsOrderService {
164
164
  isPublic: false,
165
165
  note: `Created order '${result.id}' in QLS`,
166
166
  });
167
- // Delay 10s to prevent race conditions: OrderPlacedEvent is emitted before transition to PaymentSettled is complete
168
- setTimeout(() => {
169
- this.orderService
170
- .updateCustomFields(ctx, orderId, {
171
- syncedToQls: true,
172
- })
173
- .catch((e) => {
174
- const error = (0, catch_unknown_1.asError)(e);
175
- core_2.Logger.error(`Error updating custom field 'syncedToQls: true' for order '${order.code}': ${error.message}`, constants_1.loggerCtx, error.stack);
176
- });
177
- }, 10000);
167
+ // Delayed custom field update to prevent race conditions: OrderPlacedEvent is emitted before transition to PaymentSettled is complete
168
+ await new Promise((resolve) => setTimeout(resolve, 5000));
169
+ await this.orderService
170
+ .updateCustomFields(ctx, orderId, {
171
+ syncedToQls: true,
172
+ })
173
+ .catch((e) => {
174
+ // catch any errors, because we don't want the job to fail and retry when custom field update fails
175
+ const error = (0, catch_unknown_1.asError)(e);
176
+ core_2.Logger.error(`Error updating custom field 'syncedToQls: true' for order '${order.code}': ${error.message}`, constants_1.loggerCtx, error.stack);
177
+ });
178
178
  return `Order '${order.code}' created in QLS with id '${result.id}'`;
179
179
  }
180
180
  catch (e) {
@@ -196,7 +196,7 @@ let QlsOrderService = class QlsOrderService {
196
196
  const orderCode = body.customer_reference;
197
197
  const order = await this.orderService.findOneByCode(ctx, orderCode, []);
198
198
  if (!order) {
199
- throw new Error(`Order with code '${orderCode}' not found`);
199
+ return core_2.Logger.warn(`Order with code '${orderCode}' not found, ignoring order status update`, constants_1.loggerCtx);
200
200
  }
201
201
  const client = await (0, qls_client_1.getQlsClient)(ctx, this.options);
202
202
  if (!client) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinelab/vendure-plugin-qls-fulfillment",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Vendure plugin to fulfill orders via QLS.",
5
5
  "keywords": [
6
6
  "fulfillment",
@@ -32,5 +32,5 @@
32
32
  "dependencies": {
33
33
  "catch-unknown": "^2.0.0"
34
34
  },
35
- "gitHead": "8f5d76680b66b12b9fb3732a4205b4ce20686076"
35
+ "gitHead": "2e1abb0be4b76adacee78bedad19af28961acfaa"
36
36
  }
@@ -1,2 +0,0 @@
1
- import { ScheduledTask } from '@vendure/core';
2
- export declare const fullProductSyncTask: ScheduledTask<{}>;