@pinelab/vendure-plugin-qls-fulfillment 1.0.0-beta.1 → 1.0.0-beta.3

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/README.md CHANGED
@@ -58,7 +58,11 @@ Make sure to monitor failed jobs: A job that failed after its retries were exhau
58
58
  1. An order was not pushed to QLS
59
59
  2. A product was not synced to QLS
60
60
 
61
- Monitor your logs for the string `QLS webhook error`. This means an incoming stock update webhook was not processed correctly.
61
+ Monitor your logs for the following text:
62
+ * `QLS webhook error` - This means an incoming stock update webhook was not processed correctly.
63
+ * `Error creating or updating variant` - This means a product was not synced to QLS.
64
+
65
+ Make sure to filter by logger context `QlsPlugin`, to prevent false positive alerts.
62
66
 
63
67
  ## Cancelling orders and manually pushing orders to QLS
64
68
 
@@ -108,13 +108,19 @@ let QlsProductService = class QlsProductService {
108
108
  let createdQlsProductsCount = 0;
109
109
  let updatedQlsProductsCount = 0;
110
110
  for (const variant of allVariants) {
111
- const existingQlsProduct = allQlsProducts.find((p) => p.sku == variant.sku);
112
- const result = await this.createOrUpdateProductInQls(ctx, client, variant, existingQlsProduct ?? null);
113
- if (result === 'created') {
114
- createdQlsProductsCount += 1;
111
+ try {
112
+ const existingQlsProduct = allQlsProducts.find((p) => p.sku == variant.sku);
113
+ const result = await this.createOrUpdateProductInQls(ctx, client, variant, existingQlsProduct ?? null);
114
+ if (result === 'created') {
115
+ createdQlsProductsCount += 1;
116
+ }
117
+ else if (result === 'updated') {
118
+ updatedQlsProductsCount += 1;
119
+ }
115
120
  }
116
- else if (result === 'updated') {
117
- updatedQlsProductsCount += 1;
121
+ catch (e) {
122
+ const error = (0, catch_unknown_1.asError)(e);
123
+ core_1.Logger.error(`Error creating or updating variant '${variant.sku}' in QLS: ${error.message}`, constants_1.loggerCtx, error.stack);
118
124
  }
119
125
  }
120
126
  core_1.Logger.info(`Created ${createdQlsProductsCount} products in QLS`, constants_1.loggerCtx);
@@ -0,0 +1,74 @@
1
+ import { addActionBarDropdownMenuItem } from '@vendure/admin-ui/core';
2
+ import gql from 'graphql-tag';
3
+
4
+ export default [
5
+ // Product sync button in product list
6
+ addActionBarDropdownMenuItem({
7
+ id: 'qls-fulfillment-sync',
8
+ label: 'Synchronize with QLS',
9
+ locationId: 'product-list',
10
+ icon: 'resistor',
11
+ requiresPermission: ['QLSFullSync'],
12
+ onClick: (_, { dataService, notificationService }) => {
13
+ dataService
14
+ .mutate(
15
+ gql`
16
+ mutation TriggerQlsProductSync {
17
+ triggerQlsProductSync
18
+ }
19
+ `
20
+ )
21
+ .subscribe({
22
+ next: () => {
23
+ notificationService.notify({
24
+ message: `Triggered QLS full product sync...`,
25
+ type: 'success',
26
+ });
27
+ },
28
+ error: (err) => {
29
+ notificationService.notify({
30
+ message: err.message,
31
+ type: 'error',
32
+ });
33
+ },
34
+ });
35
+ },
36
+ }),
37
+ // Push order to QLS button on order detail page
38
+ addActionBarDropdownMenuItem({
39
+ id: 'qls-fulfillment-push-order',
40
+ label: 'Push order to QLS',
41
+ locationId: 'order-detail',
42
+ icon: 'resistor',
43
+ requiresPermission: ['QLSFullSync'],
44
+ hasDivider: true,
45
+ onClick: (_, { route, dataService, notificationService }) => {
46
+ dataService
47
+ .mutate(
48
+ gql`
49
+ mutation PushOrderToQls($orderId: ID!) {
50
+ pushOrderToQls(orderId: $orderId)
51
+ }
52
+ `,
53
+ {
54
+ orderId: route.snapshot.params.id,
55
+ }
56
+ )
57
+ .subscribe({
58
+ next: (result) => {
59
+ console.log(result);
60
+ notificationService.notify({
61
+ message: (result as any).pushOrderToQls,
62
+ type: 'success',
63
+ });
64
+ },
65
+ error: (err) => {
66
+ notificationService.notify({
67
+ message: err.message,
68
+ type: 'error',
69
+ });
70
+ },
71
+ });
72
+ },
73
+ }),
74
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinelab/vendure-plugin-qls-fulfillment",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "Vendure plugin to fulfill orders via QLS.",
5
5
  "keywords": [
6
6
  "fulfillment",
@@ -23,7 +23,7 @@
23
23
  "CHANGELOG.md"
24
24
  ],
25
25
  "scripts": {
26
- "build": "rimraf dist && yarn generate && tsc",
26
+ "build": "rimraf dist && yarn generate && tsc && copyfiles -u 1 'src/ui/**/*' dist/",
27
27
  "start": "nodemon --watch src --exec ts-node test/dev-server.ts",
28
28
  "generate": "graphql-codegen",
29
29
  "test": "vitest run --bail 1",