repzo-sap-absjo 1.0.16 → 1.0.18

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.
@@ -6,7 +6,7 @@ import {
6
6
  set_error,
7
7
  } from "../util.js";
8
8
  export const sync_disabled_product = async (commandEvent) => {
9
- var _a, _b, _c;
9
+ var _a, _b;
10
10
  const repzo = new Repzo(
11
11
  (_a = commandEvent.app.formData) === null || _a === void 0
12
12
  ? void 0
@@ -56,25 +56,21 @@ export const sync_disabled_product = async (commandEvent) => {
56
56
  sap_products === null || sap_products === void 0
57
57
  ? void 0
58
58
  : sap_products.map((product) => `${nameSpace}_${product.ITEMCODE}`);
59
- const repzo_products = [];
60
- const per_page = 200;
61
- const pages = Math.ceil(sap_product_query.length / per_page);
62
- for (let i = 0; i < pages; i += per_page) {
63
- const repzo_product_per_page = await repzo.product.find({
64
- active: true,
65
- per_page: 50000,
66
- "integration_meta.id": sap_product_query.slice(i, i + per_page),
67
- });
68
- if (
69
- (_b =
70
- repzo_product_per_page === null || repzo_product_per_page === void 0
71
- ? void 0
72
- : repzo_product_per_page.data) === null || _b === void 0
73
- ? void 0
74
- : _b.length
75
- )
76
- repzo_products.push(...repzo_product_per_page.data);
77
- }
59
+ const repzo_product_per_page = await repzo.patchAction.create(
60
+ {
61
+ slug: "product",
62
+ readQuery: [
63
+ { key: "active", value: [true], operator: "eq" },
64
+ {
65
+ key: "integration_meta.id",
66
+ value: sap_product_query,
67
+ operator: "in",
68
+ },
69
+ ],
70
+ },
71
+ { per_page: 50000 }
72
+ );
73
+ const repzo_products = repzo_product_per_page.data;
78
74
  result.repzo_total =
79
75
  repzo_products === null || repzo_products === void 0
80
76
  ? void 0
@@ -146,10 +142,10 @@ export const sync_disabled_product = async (commandEvent) => {
146
142
  } catch (e) {
147
143
  //@ts-ignore
148
144
  console.error(
149
- ((_c = e === null || e === void 0 ? void 0 : e.response) === null ||
150
- _c === void 0
145
+ ((_b = e === null || e === void 0 ? void 0 : e.response) === null ||
146
+ _b === void 0
151
147
  ? void 0
152
- : _c.data) || e
148
+ : _b.data) || e
153
149
  );
154
150
  await commandLog.setStatus("fail", e).commit();
155
151
  throw e;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "repzo-sap-absjo",
3
3
  "description": "repzo SAP ABS jo integration",
4
- "version": "1.0.16",
4
+ "version": "1.0.18",
5
5
  "homepage": "",
6
6
  "keywords": [],
7
7
  "author": {
@@ -45,7 +45,7 @@
45
45
  "jsonwebtoken": "^8.5.1",
46
46
  "lodash": "^4.17.21",
47
47
  "moment-timezone": "^0.5.34",
48
- "repzo": "^1.0.24",
48
+ "repzo": "^1.0.29",
49
49
  "uuid": "^8.3.2"
50
50
  }
51
51
  }
@@ -333,7 +333,10 @@ function getUniqueConcatenatedValues(
333
333
  ): string {
334
334
  item.general_promotions = item.general_promotions || [];
335
335
  item.used_promotions = item.used_promotions || [];
336
- const allPromotions = [...item.general_promotions, ...item.used_promotions];
336
+ const allPromotions: { name: string; ref?: string; [key: string]: any }[] = [
337
+ ...item.general_promotions,
338
+ ...item.used_promotions,
339
+ ];
337
340
  const uniqueValues = new Set(
338
341
  allPromotions.map((promotion) => promotion[key]).filter((value) => value)
339
342
  );
@@ -62,18 +62,21 @@ export const sync_disabled_product = async (commandEvent: CommandEvent) => {
62
62
  (product) => `${nameSpace}_${product.ITEMCODE}`
63
63
  );
64
64
 
65
- const repzo_products = [];
66
- const per_page = 200;
67
- const pages = Math.ceil(sap_product_query.length / per_page);
68
- for (let i = 0; i < pages; i += per_page) {
69
- const repzo_product_per_page = await repzo.product.find({
70
- active: true,
71
- per_page: 50000,
72
- "integration_meta.id": sap_product_query.slice(i, i + per_page),
73
- });
74
- if (repzo_product_per_page?.data?.length)
75
- repzo_products.push(...repzo_product_per_page.data);
76
- }
65
+ const repzo_product_per_page = await repzo.patchAction.create(
66
+ {
67
+ slug: "product",
68
+ readQuery: [
69
+ { key: "active", value: [true], operator: "eq" },
70
+ {
71
+ key: "integration_meta.id",
72
+ value: sap_product_query,
73
+ operator: "in",
74
+ },
75
+ ],
76
+ },
77
+ { per_page: 50000 }
78
+ );
79
+ const repzo_products = repzo_product_per_page.data;
77
80
 
78
81
  result.repzo_total = repzo_products?.length;
79
82
  await commandLog