@solution25/n8n-nodes-shopware 1.4.4 → 2.0.0

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.
Files changed (109) hide show
  1. package/README.md +4 -1
  2. package/dist/credentials/ShopwareOAuth2Api.credentials.js +4 -3
  3. package/dist/credentials/ShopwareOAuth2Api.credentials.js.map +1 -1
  4. package/dist/nodes/Shopware/Shopware.node.js.map +1 -1
  5. package/dist/nodes/Shopware/test/v1/helpers/payloadBuilders.test.js +213 -0
  6. package/dist/nodes/Shopware/test/v1/helpers/payloadBuilders.test.js.map +1 -0
  7. package/dist/nodes/Shopware/test/v1/helpers/pricing.test.js +75 -0
  8. package/dist/nodes/Shopware/test/v1/helpers/pricing.test.js.map +1 -0
  9. package/dist/nodes/Shopware/test/v1/helpers/utils.test.js +153 -0
  10. package/dist/nodes/Shopware/test/v1/helpers/utils.test.js.map +1 -0
  11. package/dist/nodes/Shopware/test/v1/helpers/validation.test.d.ts +1 -0
  12. package/dist/nodes/Shopware/test/v1/helpers/validation.test.js +16 -0
  13. package/dist/nodes/Shopware/test/v1/helpers/validation.test.js.map +1 -0
  14. package/dist/nodes/Shopware/v1/actions/category/create.operation.js +17 -39
  15. package/dist/nodes/Shopware/v1/actions/category/create.operation.js.map +1 -1
  16. package/dist/nodes/Shopware/v1/actions/category/deleteCategory.operation.js +2 -1
  17. package/dist/nodes/Shopware/v1/actions/category/deleteCategory.operation.js.map +1 -1
  18. package/dist/nodes/Shopware/v1/actions/category/fields.js +3 -1
  19. package/dist/nodes/Shopware/v1/actions/category/fields.js.map +1 -1
  20. package/dist/nodes/Shopware/v1/actions/category/get.operation.js +4 -0
  21. package/dist/nodes/Shopware/v1/actions/category/get.operation.js.map +1 -1
  22. package/dist/nodes/Shopware/v1/actions/category/getMany.operation.js +1 -1
  23. package/dist/nodes/Shopware/v1/actions/category/getMany.operation.js.map +1 -1
  24. package/dist/nodes/Shopware/v1/actions/category/types.d.ts +3 -2
  25. package/dist/nodes/Shopware/v1/actions/category/update.operation.js +15 -19
  26. package/dist/nodes/Shopware/v1/actions/category/update.operation.js.map +1 -1
  27. package/dist/nodes/Shopware/v1/actions/customer/create.operation.js +49 -64
  28. package/dist/nodes/Shopware/v1/actions/customer/create.operation.js.map +1 -1
  29. package/dist/nodes/Shopware/v1/actions/customer/deleteCustomer.operation.js +2 -1
  30. package/dist/nodes/Shopware/v1/actions/customer/deleteCustomer.operation.js.map +1 -1
  31. package/dist/nodes/Shopware/v1/actions/customer/fields.d.ts +0 -3
  32. package/dist/nodes/Shopware/v1/actions/customer/fields.js +4 -4
  33. package/dist/nodes/Shopware/v1/actions/customer/fields.js.map +1 -1
  34. package/dist/nodes/Shopware/v1/actions/customer/get.operation.js +5 -0
  35. package/dist/nodes/Shopware/v1/actions/customer/get.operation.js.map +1 -1
  36. package/dist/nodes/Shopware/v1/actions/customer/getMany.operation.js +1 -1
  37. package/dist/nodes/Shopware/v1/actions/customer/getMany.operation.js.map +1 -1
  38. package/dist/nodes/Shopware/v1/actions/customer/types.d.ts +7 -14
  39. package/dist/nodes/Shopware/v1/actions/customer/update.operation.js +36 -58
  40. package/dist/nodes/Shopware/v1/actions/customer/update.operation.js.map +1 -1
  41. package/dist/nodes/Shopware/v1/actions/fields.js +4 -1
  42. package/dist/nodes/Shopware/v1/actions/fields.js.map +1 -1
  43. package/dist/nodes/Shopware/v1/actions/order/create.operation.js +192 -276
  44. package/dist/nodes/Shopware/v1/actions/order/create.operation.js.map +1 -1
  45. package/dist/nodes/Shopware/v1/actions/order/deleteOrder.operation.js +2 -1
  46. package/dist/nodes/Shopware/v1/actions/order/deleteOrder.operation.js.map +1 -1
  47. package/dist/nodes/Shopware/v1/actions/order/getMany.operation.js +0 -1
  48. package/dist/nodes/Shopware/v1/actions/order/getMany.operation.js.map +1 -1
  49. package/dist/nodes/Shopware/v1/actions/order/types.d.ts +30 -7
  50. package/dist/nodes/Shopware/v1/actions/order/update.operation.js +216 -245
  51. package/dist/nodes/Shopware/v1/actions/order/update.operation.js.map +1 -1
  52. package/dist/nodes/Shopware/v1/actions/product/create.operation.js +68 -60
  53. package/dist/nodes/Shopware/v1/actions/product/create.operation.js.map +1 -1
  54. package/dist/nodes/Shopware/v1/actions/product/deleteProduct.operation.js +2 -1
  55. package/dist/nodes/Shopware/v1/actions/product/deleteProduct.operation.js.map +1 -1
  56. package/dist/nodes/Shopware/v1/actions/product/fields.d.ts +0 -3
  57. package/dist/nodes/Shopware/v1/actions/product/fields.js +6 -4
  58. package/dist/nodes/Shopware/v1/actions/product/fields.js.map +1 -1
  59. package/dist/nodes/Shopware/v1/actions/product/get.operation.js +6 -0
  60. package/dist/nodes/Shopware/v1/actions/product/get.operation.js.map +1 -1
  61. package/dist/nodes/Shopware/v1/actions/product/getMany.operation.js +3 -3
  62. package/dist/nodes/Shopware/v1/actions/product/getMany.operation.js.map +1 -1
  63. package/dist/nodes/Shopware/v1/actions/product/types.d.ts +12 -14
  64. package/dist/nodes/Shopware/v1/actions/product/update.operation.js +70 -51
  65. package/dist/nodes/Shopware/v1/actions/product/update.operation.js.map +1 -1
  66. package/dist/nodes/Shopware/v1/actions/router.js +2 -1
  67. package/dist/nodes/Shopware/v1/actions/router.js.map +1 -1
  68. package/dist/nodes/Shopware/v1/actions/types.d.ts +14 -0
  69. package/dist/nodes/Shopware/v1/actions/versionDescription.js.map +1 -1
  70. package/dist/nodes/Shopware/v1/helpers/handlers.js +4 -4
  71. package/dist/nodes/Shopware/v1/helpers/handlers.js.map +1 -1
  72. package/dist/nodes/Shopware/v1/helpers/media.d.ts +12 -0
  73. package/dist/nodes/Shopware/v1/helpers/media.js +35 -0
  74. package/dist/nodes/Shopware/v1/helpers/media.js.map +1 -0
  75. package/dist/nodes/Shopware/v1/helpers/params.d.ts +90 -0
  76. package/dist/nodes/Shopware/v1/helpers/params.js +154 -0
  77. package/dist/nodes/Shopware/v1/helpers/params.js.map +1 -0
  78. package/dist/nodes/Shopware/v1/helpers/payloadBuilders.d.ts +143 -0
  79. package/dist/nodes/Shopware/v1/helpers/payloadBuilders.js +441 -0
  80. package/dist/nodes/Shopware/v1/helpers/payloadBuilders.js.map +1 -0
  81. package/dist/nodes/Shopware/v1/helpers/pricing.d.ts +29 -0
  82. package/dist/nodes/Shopware/v1/helpers/pricing.js +108 -0
  83. package/dist/nodes/Shopware/v1/helpers/pricing.js.map +1 -0
  84. package/dist/nodes/Shopware/v1/helpers/utils.d.ts +4 -1
  85. package/dist/nodes/Shopware/v1/helpers/utils.js +260 -21
  86. package/dist/nodes/Shopware/v1/helpers/utils.js.map +1 -1
  87. package/dist/nodes/Shopware/v1/helpers/validation.d.ts +3 -0
  88. package/dist/nodes/Shopware/v1/helpers/validation.js +29 -0
  89. package/dist/nodes/Shopware/v1/helpers/validation.js.map +1 -0
  90. package/dist/nodes/Shopware/v1/methods/loadOptions.js +14 -21
  91. package/dist/nodes/Shopware/v1/methods/loadOptions.js.map +1 -1
  92. package/dist/nodes/Shopware/v1/transport/index.d.ts +1 -1
  93. package/dist/nodes/Shopware/v1/transport/index.js +28 -4
  94. package/dist/nodes/Shopware/v1/transport/index.js.map +1 -1
  95. package/dist/package.json +2 -2
  96. package/dist/tsconfig.tsbuildinfo +1 -1
  97. package/package.json +2 -2
  98. package/dist/nodes/Shopware/test/v1/node/customer/getMany.test.js +0 -98
  99. package/dist/nodes/Shopware/test/v1/node/customer/getMany.test.js.map +0 -1
  100. package/dist/nodes/Shopware/test/v1/node/helpers.d.ts +0 -6
  101. package/dist/nodes/Shopware/test/v1/node/helpers.js +0 -44
  102. package/dist/nodes/Shopware/test/v1/node/helpers.js.map +0 -1
  103. package/dist/nodes/Shopware/test/v1/node/order/getMany.test.js +0 -111
  104. package/dist/nodes/Shopware/test/v1/node/order/getMany.test.js.map +0 -1
  105. package/dist/nodes/Shopware/test/v1/node/product/getMany.test.js +0 -96
  106. package/dist/nodes/Shopware/test/v1/node/product/getMany.test.js.map +0 -1
  107. /package/dist/nodes/Shopware/test/v1/{node/customer/getMany.test.d.ts → helpers/payloadBuilders.test.d.ts} +0 -0
  108. /package/dist/nodes/Shopware/test/v1/{node/order/getMany.test.d.ts → helpers/pricing.test.d.ts} +0 -0
  109. /package/dist/nodes/Shopware/test/v1/{node/product/getMany.test.d.ts → helpers/utils.test.d.ts} +0 -0
package/README.md CHANGED
@@ -45,7 +45,7 @@ Once configured, the node uses these credentials to authenticate against the Sho
45
45
 
46
46
  n8n version: tested with the latest n8n release (keep n8n updated for best compatibility).
47
47
 
48
- Shopware version: compatible with Shopware 6.6.x.x.
48
+ Shopware version: compatible with Shopware 6.6.x and 6.7.x
49
49
 
50
50
  ## Usage
51
51
 
@@ -81,3 +81,6 @@ For general n8n usage, see the [Try it out guide](https://docs.n8n.io/try-it-out
81
81
  | **1.4.1** | Removed deprecated transport method, options and types. |
82
82
  | **1.4.2** | Fixed missing credentials in package definition and resolved icon paths. |
83
83
  | **1.4.3** | Added credentials explicitly to the base versioned node. |
84
+ | **1.4.4** | Added line-items, currency, deliveries and transactions data to order. Changed node icon format to SVG.|
85
+ | **1.4.5** | Removed debug statements from code. |
86
+ | **2.0.0** | Large refactor, validation fixes, correct tax calculations and rounding, significant optimizations, media upload for products, more associations for resources, better error handling and surfacing, line item pricing fix, order delivery versioning fix, complete fields for addresses, filters fix. |
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ShopwareOAuth2Api = void 0;
4
+ const validation_1 = require("../nodes/Shopware/v1/helpers/validation");
4
5
  class ShopwareOAuth2Api {
5
6
  constructor() {
6
7
  this.name = 'shopwareOAuth2Api';
@@ -58,17 +59,17 @@ class ShopwareOAuth2Api {
58
59
  };
59
60
  }
60
61
  async preAuthentication(credentials) {
61
- const url = credentials.url;
62
+ const url = (0, validation_1.normalizeShopwareUrl)(credentials.url);
62
63
  const { access_token } = (await this.helpers.httpRequest({
63
64
  method: 'POST',
64
- url: `${url.endsWith('/') ? url.slice(0, -1) : url}/api/oauth/token`,
65
+ url: `${url}/api/oauth/token`,
65
66
  body: {
66
67
  client_id: credentials.clientId,
67
68
  client_secret: credentials.clientSecret,
68
69
  grant_type: 'client_credentials',
69
70
  },
70
71
  headers: {
71
- 'Content-Type': 'application/x-www-form-urlencoded',
72
+ 'Content-Type': 'application/json',
72
73
  },
73
74
  }));
74
75
  return { accessToken: access_token };
@@ -1 +1 @@
1
- {"version":3,"file":"ShopwareOAuth2Api.credentials.js","sourceRoot":"","sources":["../../credentials/ShopwareOAuth2Api.credentials.ts"],"names":[],"mappings":";;;AASA,MAAa,iBAAiB;IAA9B;QACC,SAAI,GAAG,mBAAmB,CAAC;QAE3B,gBAAW,GAAG,qBAAqB,CAAC;QAEpC,qBAAgB,GAAG,0EAA0E,CAAC;QAE9F,SAAI,GAAG,EAAE,KAAK,EAAE,8BAA8B,EAAE,IAAI,EAAE,8BAA8B,EAAW,CAAC;QAEhG,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBAEd,WAAW,EAAE;oBACZ,SAAS,EAAE,IAAI;iBACf;gBACD,OAAO,EAAE,EAAE;aACX;YACD;gBACC,WAAW,EAAE,KAAK;gBAClB,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;aACX;YACD;gBACC,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;aACX;YACD;gBACC,WAAW,EAAE,eAAe;gBAC5B,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;aACX;SACD,CAAC;QAmBF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,aAAa,EAAE,sCAAsC;iBACrD;aACD;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,wBAAwB;gBACjC,GAAG,EAAE,oBAAoB;aACzB;SACD,CAAC;IACH,CAAC;IAhCA,KAAK,CAAC,iBAAiB,CAA2B,WAA2C;QAC5F,MAAM,GAAG,GAAG,WAAW,CAAC,GAAa,CAAC;QACtC,MAAM,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;YACxD,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,kBAAkB;YACpE,IAAI,EAAE;gBACL,SAAS,EAAE,WAAW,CAAC,QAAQ;gBAC/B,aAAa,EAAE,WAAW,CAAC,YAAY;gBACvC,UAAU,EAAE,oBAAoB;aAChC;YACD,OAAO,EAAE;gBACR,cAAc,EAAE,mCAAmC;aACnD;SACD,CAAC,CAA6B,CAAC;QAChC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;IACtC,CAAC;CAiBD;AA9ED,8CA8EC"}
1
+ {"version":3,"file":"ShopwareOAuth2Api.credentials.js","sourceRoot":"","sources":["../../credentials/ShopwareOAuth2Api.credentials.ts"],"names":[],"mappings":";;;AAQA,wEAA+E;AAE/E,MAAa,iBAAiB;IAA9B;QACC,SAAI,GAAG,mBAAmB,CAAC;QAE3B,gBAAW,GAAG,qBAAqB,CAAC;QAEpC,qBAAgB,GAAG,0EAA0E,CAAC;QAE9F,SAAI,GAAG,EAAE,KAAK,EAAE,8BAA8B,EAAE,IAAI,EAAE,8BAA8B,EAAW,CAAC;QAEhG,eAAU,GAAs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AC,YAAY;gBACvC,UAAU,EAAE,oBAAoB;aAChC;YACD,OAAO,EAAE;gBACR,cAAc,EAAE,kBAAkB;aAClC;SACD,CAAC,CAA6B,CAAC;QAChC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;IACtC,CAAC;CAiBD;AA9ED,8CA8EC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Shopware.node.js","sourceRoot":"","sources":["../../../nodes/Shopware/Shopware.node.ts"],"names":[],"mappings":";;;AACA,+CAAiD;AAEjD,0DAAkD;AAElD,MAAa,QAAS,SAAQ,gCAAiB;IAC9C;QACC,MAAM,eAAe,GAA6B;YACjD,WAAW,EAAE,UAAU;YACvB,IAAI,EAAE,UAAU;YAEhB,IAAI,EAAE,iCAAiC;YACvC,KAAK,EAAE,CAAC,OAAO,CAAC;YAChB,WAAW,EAAE,mDAAmD;YAChE,cAAc,EAAE,CAAC;SACjB,CAAC;QAEF,MAAM,YAAY,GAAuC;YACxD,CAAC,EAAE,IAAI,4BAAU,CAAC,eAAe,CAAC;SAClC,CAAC;QAEF,KAAK,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IACtC,CAAC;CACD;AAlBD,4BAkBC"}
1
+ {"version":3,"file":"Shopware.node.js","sourceRoot":"","sources":["../../../nodes/Shopware/Shopware.node.ts"],"names":[],"mappings":";;;AACA,+CAAiD;AAEjD,0DAAkD;AAElD,MAAa,QAAS,SAAQ,gCAAiB;IAC9C;QACC,MAAM,eAAe,GAA6B;YACjD,WAAW,EAAE,UAAU;YACvB,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,iCAAiC;YACvC,KAAK,EAAE,CAAC,OAAO,CAAC;YAChB,WAAW,EAAE,mDAAmD;YAChE,cAAc,EAAE,CAAC;SACjB,CAAC;QAEF,MAAM,YAAY,GAAuC;YACxD,CAAC,EAAE,IAAI,4BAAU,CAAC,eAAe,CAAC;SAClC,CAAC;QAEF,KAAK,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IACtC,CAAC;CACD;AAjBD,4BAiBC"}
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const payloadBuilders_1 = require("../../../v1/helpers/payloadBuilders");
4
+ const pricing_1 = require("../../../v1/helpers/pricing");
5
+ describe('payload builder helpers', () => {
6
+ it('builds order price with aggregated tax data', () => {
7
+ expect((0, payloadBuilders_1.buildOrderPrice)({
8
+ netPrice: 30,
9
+ totalPrice: 35,
10
+ calculatedTaxes: [
11
+ { tax: 1, taxRate: 10, price: 11 },
12
+ { tax: 4, taxRate: 20, price: 24 },
13
+ ],
14
+ taxRules: [
15
+ { taxRate: 10, percentage: 33.33 },
16
+ { taxRate: 20, percentage: 66.67 },
17
+ ],
18
+ })).toEqual({
19
+ netPrice: 30,
20
+ totalPrice: 35,
21
+ calculatedTaxes: [
22
+ { tax: 1, taxRate: 10, price: 11 },
23
+ { tax: 4, taxRate: 20, price: 24 },
24
+ ],
25
+ taxRules: [
26
+ { taxRate: 10, percentage: 33.33 },
27
+ { taxRate: 20, percentage: 66.67 },
28
+ ],
29
+ positionPrice: 30,
30
+ rawTotal: 30,
31
+ taxStatus: 'gross',
32
+ });
33
+ });
34
+ it('builds transaction amounts from aggregated tax data', () => {
35
+ expect((0, payloadBuilders_1.buildTransactionPayload)({
36
+ paymentMethodId: 'payment-id',
37
+ stateId: 'state-id',
38
+ netPrice: 30,
39
+ totalPrice: 35,
40
+ quantity: 2,
41
+ calculatedTaxes: [
42
+ { tax: 1, taxRate: 10, price: 11 },
43
+ { tax: 4, taxRate: 20, price: 24 },
44
+ ],
45
+ taxRules: [
46
+ { taxRate: 10, percentage: 33.33 },
47
+ { taxRate: 20, percentage: 66.67 },
48
+ ],
49
+ })).toEqual({
50
+ paymentMethodId: 'payment-id',
51
+ stateId: 'state-id',
52
+ amount: {
53
+ unitPrice: 30,
54
+ totalPrice: 35,
55
+ quantity: 2,
56
+ calculatedTaxes: [
57
+ { tax: 1, taxRate: 10, price: 11 },
58
+ { tax: 4, taxRate: 20, price: 24 },
59
+ ],
60
+ taxRules: [
61
+ { taxRate: 10, percentage: 33.33 },
62
+ { taxRate: 20, percentage: 66.67 },
63
+ ],
64
+ },
65
+ });
66
+ });
67
+ it('preserves decimal currencyFactor values in order payloads', () => {
68
+ const orderPayload = (0, payloadBuilders_1.buildOrderCreatePayload)({
69
+ orderId: 'order-id',
70
+ currencyData: [
71
+ 'currency-id',
72
+ 'EUR',
73
+ '0.85',
74
+ JSON.stringify({ decimals: 2, interval: 0.01, roundForNet: true }),
75
+ JSON.stringify({ decimals: 2, interval: 0.01, roundForNet: false }),
76
+ ],
77
+ globalDefaults: {
78
+ languageId: 'language-id',
79
+ salesChannelId: 'sales-channel-id',
80
+ },
81
+ customerData: {
82
+ billingAddress: {
83
+ id: 'billing-id',
84
+ countryId: 'country-id',
85
+ countryStateId: 'state-id',
86
+ salutationId: 'salutation-id',
87
+ firstName: 'Jane',
88
+ lastName: 'Doe',
89
+ zipcode: '10115',
90
+ city: 'Berlin',
91
+ street: 'Example Street 1',
92
+ },
93
+ },
94
+ orderCustomer: {
95
+ firstName: 'Jane',
96
+ lastName: 'Doe',
97
+ email: 'jane@example.com',
98
+ salutationId: 'salutation-id',
99
+ customerNumber: '10001',
100
+ },
101
+ lineItems: [],
102
+ price: (0, payloadBuilders_1.buildOrderPrice)({
103
+ netPrice: 30,
104
+ totalPrice: 35,
105
+ calculatedTaxes: [{ tax: 5, taxRate: 19, price: 35 }],
106
+ taxRules: [{ taxRate: 19, percentage: 100 }],
107
+ }),
108
+ shippingCosts: (0, pricing_1.buildGenericPrice)(5, 19),
109
+ transactions: [],
110
+ deliveries: [],
111
+ orderNumber: '10001',
112
+ dateAndTime: '2026-03-21T10:00:00.000Z',
113
+ stateId: 'state-id',
114
+ });
115
+ expect(orderPayload.currencyFactor).toBe(0.85);
116
+ expect(orderPayload.billingAddress).toEqual({
117
+ id: 'billing-id',
118
+ countryId: 'country-id',
119
+ countryStateId: 'state-id',
120
+ salutationId: 'salutation-id',
121
+ firstName: 'Jane',
122
+ lastName: 'Doe',
123
+ zipcode: '10115',
124
+ city: 'Berlin',
125
+ street: 'Example Street 1',
126
+ });
127
+ });
128
+ it('aggregates delivery shipping costs across mixed rates and existing shipping data', () => {
129
+ const deliveries = [
130
+ {
131
+ id: 'delivery-1',
132
+ shippingOrderAddress: { id: 'address-1', countryId: 'c1', countryStateId: null, salutationId: 'sal-1', firstName: 'A', lastName: 'B', zipcode: '10000', street: 'S', city: 'C' },
133
+ shippingMethodId: 'shipping-1',
134
+ stateId: 'state-1',
135
+ shippingDateEarliest: new Date('2026-03-21T10:00:00.000Z'),
136
+ shippingDateLatest: new Date('2026-03-22T10:00:00.000Z'),
137
+ shippingCosts: (0, pricing_1.buildGenericPrice)(10, 10),
138
+ positions: [],
139
+ },
140
+ {
141
+ id: 'delivery-2',
142
+ shippingOrderAddress: { id: 'address-2', countryId: 'c2', countryStateId: null, salutationId: 'sal-2', firstName: 'C', lastName: 'D', zipcode: '20000', street: 'S2', city: 'C2' },
143
+ shippingMethodId: 'shipping-2',
144
+ stateId: 'state-2',
145
+ shippingDateEarliest: new Date('2026-03-21T10:00:00.000Z'),
146
+ shippingDateLatest: new Date('2026-03-23T10:00:00.000Z'),
147
+ shippingCosts: (0, pricing_1.buildGenericPrice)(20, 20),
148
+ positions: [],
149
+ },
150
+ ];
151
+ expect((0, payloadBuilders_1.aggregateDeliveryShippingCosts)(deliveries)).toEqual({
152
+ unitPrice: 30,
153
+ totalPrice: 30,
154
+ quantity: 1,
155
+ calculatedTaxes: [
156
+ { tax: 1, taxRate: 10, price: 11 },
157
+ { tax: 4, taxRate: 20, price: 24 },
158
+ ],
159
+ taxRules: [
160
+ { taxRate: 10, percentage: 33.33 },
161
+ { taxRate: 20, percentage: 66.67 },
162
+ ],
163
+ });
164
+ expect((0, payloadBuilders_1.aggregateDeliveryShippingCostsWithExisting)(deliveries, (0, pricing_1.buildGenericPrice)(5, 19))).toEqual({
165
+ unitPrice: 35,
166
+ totalPrice: 35,
167
+ quantity: 1,
168
+ calculatedTaxes: [
169
+ { tax: 1, taxRate: 10, price: 11 },
170
+ { tax: 0.95, taxRate: 19, price: 5.95 },
171
+ { tax: 4, taxRate: 20, price: 24 },
172
+ ],
173
+ taxRules: [
174
+ { taxRate: 10, percentage: 28.57 },
175
+ { taxRate: 19, percentage: 14.29 },
176
+ { taxRate: 20, percentage: 57.14 },
177
+ ],
178
+ });
179
+ });
180
+ it('builds customer addresses with zipcode and country state', () => {
181
+ const result = (0, payloadBuilders_1.buildCustomerAddresses)([
182
+ {
183
+ country: 'country-1',
184
+ countryStateId: 'state-1',
185
+ firstName: 'Jane',
186
+ lastName: 'Doe',
187
+ zipcode: '10115',
188
+ city: 'Berlin',
189
+ street: 'Example Street 1',
190
+ defaultShippingAddress: true,
191
+ defaultBillingAddress: true,
192
+ },
193
+ ], 'salutation-id', () => 'address-id', {}, 0);
194
+ expect(result).toEqual({
195
+ addresses: [
196
+ {
197
+ id: 'address-id',
198
+ countryId: 'country-1',
199
+ countryStateId: 'state-1',
200
+ firstName: 'Jane',
201
+ lastName: 'Doe',
202
+ zipcode: '10115',
203
+ city: 'Berlin',
204
+ street: 'Example Street 1',
205
+ salutationId: 'salutation-id',
206
+ },
207
+ ],
208
+ defaultShippingAddressId: 'address-id',
209
+ defaultBillingAddressId: 'address-id',
210
+ });
211
+ });
212
+ });
213
+ //# sourceMappingURL=payloadBuilders.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payloadBuilders.test.js","sourceRoot":"","sources":["../../../../../../nodes/Shopware/test/v1/helpers/payloadBuilders.test.ts"],"names":[],"mappings":";;AAAA,yEAO6C;AAC7C,yDAAgE;AAEhE,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACtD,MAAM,CACL,IAAA,iCAAe,EAAC;YACf,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,EAA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,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QACnE,MAAM,MAAM,GAAG,IAAA,wCAAsB,EACpC;YACC;gBACC,OAAO,EAAE,WAAW;gBACpB,cAAc,EAAE,SAAS;gBACzB,SAAS,EAAE,MAAM;gBACjB,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO;gBAChB,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE,kBAAkB;gBAC1B,sBAAsB,EAAE,IAAI;gBAC5B,qBAAqB,EAAE,IAAI;aAC3B;SACD,EACD,eAAe,EACf,GAAG,EAAE,CAAC,YAAY,EAClB,EAAW,EACX,CAAC,CACD,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACtB,SAAS,EAAE;gBACV;oBACC,EAAE,EAAE,YAAY;oBAChB,SAAS,EAAE,WAAW;oBACtB,cAAc,EAAE,SAAS;oBACzB,SAAS,EAAE,MAAM;oBACjB,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,OAAO;oBAChB,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE,kBAAkB;oBAC1B,YAAY,EAAE,eAAe;iBAC7B;aACD;YACD,wBAAwB,EAAE,YAAY;YACtC,uBAAuB,EAAE,YAAY;SACrC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const payloadBuilders_1 = require("../../../v1/helpers/payloadBuilders");
4
+ const pricing_1 = require("../../../v1/helpers/pricing");
5
+ describe('pricing helpers', () => {
6
+ it('calculates net from gross with cent rounding', () => {
7
+ expect((0, pricing_1.calculateNetFromGross)(11.99, 19)).toBe(10.08);
8
+ });
9
+ it('rounds line item price components consistently', () => {
10
+ expect((0, pricing_1.calculateLineItemPrice)(19.99, 3, 19)).toEqual({
11
+ unitPrice: 19.99,
12
+ totalPrice: 59.97,
13
+ tax: 11.39,
14
+ taxPrice: 71.36,
15
+ });
16
+ });
17
+ it('aggregates mixed line-item tax rates into order totals', () => {
18
+ const lineItems = [
19
+ (0, payloadBuilders_1.buildLineItemPayload)({
20
+ identifier: 'line-1',
21
+ productId: 'product-1',
22
+ productNumber: 'SW10001',
23
+ label: 'Tax 10',
24
+ states: [],
25
+ unitPrice: 10,
26
+ taxRate: 10,
27
+ quantity: 1,
28
+ }),
29
+ (0, payloadBuilders_1.buildLineItemPayload)({
30
+ identifier: 'line-2',
31
+ productId: 'product-2',
32
+ productNumber: 'SW10002',
33
+ label: 'Tax 20',
34
+ states: [],
35
+ unitPrice: 20,
36
+ taxRate: 20,
37
+ quantity: 1,
38
+ }),
39
+ ];
40
+ expect((0, pricing_1.calculateOrderTotals)(lineItems)).toEqual({
41
+ netPrice: 30,
42
+ totalPrice: 35,
43
+ taxTotal: 5,
44
+ quantity: 2,
45
+ calculatedTaxes: [
46
+ { tax: 1, taxRate: 10, price: 11 },
47
+ { tax: 4, taxRate: 20, price: 24 },
48
+ ],
49
+ taxRules: [
50
+ { taxRate: 10, percentage: 33.33 },
51
+ { taxRate: 20, percentage: 66.67 },
52
+ ],
53
+ });
54
+ });
55
+ it('aggregates generic prices across mixed tax rates', () => {
56
+ const shippingCosts = (0, pricing_1.aggregateGenericPrices)([
57
+ (0, pricing_1.buildGenericPrice)(10, 10),
58
+ (0, pricing_1.buildGenericPrice)(20, 20),
59
+ ]);
60
+ expect(shippingCosts).toEqual({
61
+ unitPrice: 30,
62
+ totalPrice: 30,
63
+ quantity: 1,
64
+ calculatedTaxes: [
65
+ { tax: 1, taxRate: 10, price: 11 },
66
+ { tax: 4, taxRate: 20, price: 24 },
67
+ ],
68
+ taxRules: [
69
+ { taxRate: 10, percentage: 33.33 },
70
+ { taxRate: 20, percentage: 66.67 },
71
+ ],
72
+ });
73
+ });
74
+ });
75
+ //# sourceMappingURL=pricing.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pricing.test.js","sourceRoot":"","sources":["../../../../../../nodes/Shopware/test/v1/helpers/pricing.test.ts"],"names":[],"mappings":";;AAAA,yEAA2E;AAC3E,yDAMqC;AAErC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,IAAA,+BAAqB,EAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACzD,MAAM,CAAC,IAAA,gCAAsB,EAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;YACpD,SAAS,EAAE,KAAK;YAChB,UAAU,EAAE,KAAK;YACjB,GAAG,EAAE,KAAK;YACV,QAAQ,EAAE,KAAK;SACf,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QACjE,MAAM,SAAS,GAAG;YACjB,IAAA,sCAAoB,EAAC;gBACpB,UAAU,EAAE,QAAQ;gBACpB,SAAS,EAAE,WAAW;gBACtB,aAAa,EAAE,SAAS;gBACxB,KAAK,EAAE,QAAQ;gBACf,MAAM,EAAE,EAAE;gBACV,SAAS,EAAE,EAAE;gBACb,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,CAAC;aACX,CAAC;YACF,IAAA,sCAAoB,EAAC;gBACpB,UAAU,EAAE,QAAQ;gBACpB,SAAS,EAAE,WAAW;gBACtB,aAAa,EAAE,SAAS;gBACxB,KAAK,EAAE,QAAQ;gBACf,MAAM,EAAE,EAAE;gBACV,SAAS,EAAE,EAAE;gBACb,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,CAAC;aACX,CAAC;SACF,CAAC;QAEF,MAAM,CAAC,IAAA,8BAAoB,EAAC,SAAS,CAAC,C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AAC"}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const n8n_workflow_1 = require("n8n-workflow");
37
+ const transport = __importStar(require("../../../v1/transport"));
38
+ const utils_1 = require("../../../v1/helpers/utils");
39
+ jest.mock('../../../v1/transport', () => ({
40
+ apiRequest: jest.fn(),
41
+ }));
42
+ const apiRequestMock = jest.mocked(transport.apiRequest);
43
+ function createExecuteContext() {
44
+ return {
45
+ getNode: () => ({ name: 'Test Node', type: 'test' }),
46
+ };
47
+ }
48
+ describe('utils helper error paths', () => {
49
+ beforeEach(() => {
50
+ apiRequestMock.mockReset();
51
+ });
52
+ it('throws a descriptive error when the default currency lookup is empty', async () => {
53
+ apiRequestMock.mockResolvedValueOnce({ data: [] });
54
+ await expect(utils_1.getDefaultCurrencyId.call(createExecuteContext())).rejects.toThrow(n8n_workflow_1.NodeOperationError);
55
+ });
56
+ it('throws a descriptive error when a shipping method lacks a price for the selected currency', async () => {
57
+ apiRequestMock.mockResolvedValueOnce({
58
+ data: [
59
+ {
60
+ prices: [
61
+ {
62
+ currencyPrice: [{ currencyId: 'other-currency', net: 10 }],
63
+ },
64
+ ],
65
+ taxId: 'tax-id',
66
+ },
67
+ ],
68
+ });
69
+ await expect(utils_1.getShippingMethodData.call(createExecuteContext(), 'shipping-id', 'currency-id')).rejects.toThrow(n8n_workflow_1.NodeOperationError);
70
+ });
71
+ it('batches product and tax lookups for line item data', async () => {
72
+ apiRequestMock
73
+ .mockResolvedValueOnce({
74
+ data: [
75
+ {
76
+ id: 'product-1',
77
+ productNumber: 'P-1',
78
+ name: 'Product 1',
79
+ states: ['state-1'],
80
+ price: [{ currencyId: 'currency-id', net: 10 }],
81
+ taxId: 'tax-1',
82
+ },
83
+ {
84
+ id: 'product-2',
85
+ productNumber: 'P-2',
86
+ name: 'Product 2',
87
+ states: ['state-2'],
88
+ price: [{ currencyId: 'currency-id', net: 20 }],
89
+ taxId: 'tax-2',
90
+ },
91
+ ],
92
+ })
93
+ .mockResolvedValueOnce({
94
+ data: [
95
+ { id: 'tax-1', taxRate: 7 },
96
+ { id: 'tax-2', taxRate: 19 },
97
+ ],
98
+ });
99
+ const result = await utils_1.getLineItemDataBatch.call(createExecuteContext(), ['P-1', 'P-2', 'P-1'], 'currency-id', 0);
100
+ expect(apiRequestMock).toHaveBeenCalledTimes(2);
101
+ expect(result.get('P-1')).toEqual({
102
+ identifier: 'product-1',
103
+ productId: 'product-1',
104
+ label: 'Product 1',
105
+ states: ['state-1'],
106
+ unitPrice: 10,
107
+ taxRate: 7,
108
+ });
109
+ expect(result.get('P-2')).toEqual({
110
+ identifier: 'product-2',
111
+ productId: 'product-2',
112
+ label: 'Product 2',
113
+ states: ['state-2'],
114
+ unitPrice: 20,
115
+ taxRate: 19,
116
+ });
117
+ });
118
+ it('loads shipping price, delivery time, and tax data from a consolidated helper path', async () => {
119
+ apiRequestMock
120
+ .mockResolvedValueOnce({
121
+ data: [
122
+ {
123
+ prices: [
124
+ {
125
+ currencyPrice: [{ currencyId: 'currency-id', net: 12 }],
126
+ },
127
+ ],
128
+ taxId: 'tax-1',
129
+ deliveryTime: {
130
+ min: 1,
131
+ max: 3,
132
+ unit: 'day',
133
+ },
134
+ },
135
+ ],
136
+ })
137
+ .mockResolvedValueOnce({
138
+ data: [{ id: 'tax-1', taxRate: 19 }],
139
+ });
140
+ const result = await utils_1.getShippingMethodFullData.call(createExecuteContext(), 'shipping-id', 'currency-id');
141
+ expect(apiRequestMock).toHaveBeenCalledTimes(2);
142
+ expect(result).toEqual({
143
+ unitPrice: 12,
144
+ taxRate: 19,
145
+ deliveryTime: {
146
+ min: 1,
147
+ max: 3,
148
+ unit: 'day',
149
+ },
150
+ });
151
+ });
152
+ });
153
+ //# sourceMappingURL=utils.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../../../../nodes/Shopware/test/v1/helpers/utils.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAkD;AAClD,iEAAmD;AACnD,qDAKmC;AAEnC,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE,CAAC,CAAC;IACzC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;CACrB,CAAC,CAAC,CAAC;AAEJ,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAEzD,SAAS,oBAAoB;IAC5B,OAAO;QACN,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE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,EAAE,KAAK,IAAI,EAAE;QAClG,cAAc;aACZ,qBAAqB,CAAC;YACtB,IAAI,EAAE;gBACL;oBACC,MAAM,EAAE;wBACP;4BACC,aAAa,EAAE,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;yBACvD;qBACD;oBACD,KAAK,EAAE,OAAO;oBACd,YAAY,EAAE;wBACb,GAAG,EAAE,CAAC;wBACN,GAAG,EAAE,CAAC;wBACN,IAAI,EAAE,KAAK;qBACX;iBACD;aACD;SACQ,CAAC;aACV,qBAAqB,CAAC;YACtB,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;SAC3B,CAAC,CAAC;QAEb,MAAM,MAAM,GAAG,MAAM,iCAAyB,CAAC,IAAI,CAClD,oBAAoB,EAAE,EACtB,aAAa,EACb,aAAa,CACb,CAAC;QAEF,MAAM,CAAC,cAAc,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACtB,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,YAAY,EAAE;gBACb,GAAG,EAAE,CAAC;gBACN,GAAG,EAAE,CAAC;gBACN,IAAI,EAAE,KAAK;aACX;SACD,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const n8n_workflow_1 = require("n8n-workflow");
4
+ const validation_1 = require("../../../v1/helpers/validation");
5
+ describe('validation helpers', () => {
6
+ it('normalizes valid Shopware URLs', () => {
7
+ expect((0, validation_1.normalizeShopwareUrl)('https://shop.example.com/')).toBe('https://shop.example.com');
8
+ });
9
+ it('rejects non-http protocols', () => {
10
+ expect(() => (0, validation_1.normalizeShopwareUrl)('ftp://shop.example.com')).toThrow('Invalid Shopware URL: must start with http:// or https://');
11
+ });
12
+ it('rejects malformed Shopware IDs', () => {
13
+ expect(() => (0, validation_1.validateShopwareId)({ name: 'Test Node', type: 'test' }, '../../admin', 0, 'Order ID')).toThrow(n8n_workflow_1.NodeOperationError);
14
+ });
15
+ });
16
+ //# sourceMappingURL=validation.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.test.js","sourceRoot":"","sources":["../../../../../../nodes/Shopware/test/v1/helpers/validation.test.ts"],"names":[],"mappings":";;AAAA,+CAAkD;AAClD,+DAA0F;AAE1F,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,IAAA,iCAAoB,EAAC,2BAA2B,CAAC,CAAC,CAAC,IAAI,CAC7D,0BAA0B,CAC1B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,iCAAoB,EAAC,wBAAwB,CAAC,CAAC,CAAC,OAAO,CACnE,2DAA2D,CAC3D,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,GAAG,EAAE,CACX,IAAA,+BAAkB,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAW,EAAE,aAAa,EAAE,CAAC,EAAE,UAAU,CAAC,CAC9F,CAAC,OAAO,CAAC,iCAAkB,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -6,6 +6,8 @@ const n8n_workflow_1 = require("n8n-workflow");
6
6
  const transport_1 = require("../../transport");
7
7
  const fields_1 = require("./fields");
8
8
  const utils_1 = require("../../helpers/utils");
9
+ const params_1 = require("../../helpers/params");
10
+ const payloadBuilders_1 = require("../../helpers/payloadBuilders");
9
11
  const properties = [
10
12
  {
11
13
  displayName: 'Parent Category',
@@ -141,53 +143,29 @@ const displayOptions = {
141
143
  };
142
144
  exports.description = (0, n8n_workflow_1.updateDisplayOptions)(displayOptions, properties);
143
145
  async function execute(items) {
144
- var _a;
145
146
  const returnData = [];
146
147
  for (let i = 0; i < items.length; i++) {
147
148
  try {
148
149
  const id = (0, utils_1.uuidv7)();
149
- let parent = null;
150
- let parentId = null;
151
- let children = null;
152
- if (!this.getNodeParameter('parent', i)) {
153
- if (this.getNodeParameter('createParent', i)) {
154
- parent = {
155
- name: this.getNodeParameter('parentCategoryName', i),
156
- description: this.getNodeParameter('parentCategoryDescription', i),
157
- };
158
- }
159
- else {
160
- parentId = this.getNodeParameter('parentId', i).split('-')[0];
161
- }
162
- }
163
- const nodeChildCategories = (_a = this.getNodeParameter('children', i)) === null || _a === void 0 ? void 0 : _a.category;
164
- if (nodeChildCategories && nodeChildCategories.length > 0) {
165
- children = nodeChildCategories.map((category) => ({
166
- name: category.categoryName,
167
- description: category.categoryDescription,
168
- }));
169
- }
170
- const createBody = {
150
+ const params = params_1.extractCategoryCreateParams.call(this, i);
151
+ const createBody = (0, payloadBuilders_1.cleanNullPayload)((0, payloadBuilders_1.buildCategoryCreatePayload)({
171
152
  id,
172
- name: this.getNodeParameter('categoryName', i),
173
- description: this.getNodeParameter('categoryDescription', i),
174
- parentId,
175
- parent,
176
- children,
177
- };
153
+ categoryName: params.categoryName,
154
+ categoryDescription: params.categoryDescription,
155
+ parentId: params.parentId,
156
+ parentCategoryName: params.parentCategoryName,
157
+ parentCategoryDescription: params.parentCategoryDescription,
158
+ nodeChildCategories: params.nodeChildCategories,
159
+ }));
178
160
  const searchBody = {
179
161
  fields: fields_1.categoryFields,
180
- includes: {
181
- category: fields_1.categoryFields,
182
- },
162
+ includes: { category: fields_1.categoryFields },
183
163
  filter: [{ type: 'equals', field: 'id', value: id }],
164
+ associations: {
165
+ children: {},
166
+ media: {},
167
+ },
184
168
  };
185
- for (const key in createBody) {
186
- const typedKey = key;
187
- if (createBody[typedKey] === null) {
188
- delete createBody[typedKey];
189
- }
190
- }
191
169
  await transport_1.apiRequest.call(this, 'POST', `/category`, createBody);
192
170
  const response = await transport_1.apiRequest.call(this, 'POST', `/search/category`, searchBody);
193
171
  const executionData = this.helpers.constructExecutionMetaData((0, utils_1.wrapData)(response.data), {
@@ -200,7 +178,7 @@ async function execute(items) {
200
178
  returnData.push({ json: { error: error.message } });
201
179
  continue;
202
180
  }
203
- if (error instanceof n8n_workflow_1.NodeOperationError) {
181
+ if (error instanceof n8n_workflow_1.NodeOperationError || error instanceof n8n_workflow_1.NodeApiError) {
204
182
  throw error;
205
183
  }
206
184
  throw new n8n_workflow_1.NodeApiError(this.getNode(), error);