@custom-js/n8n-nodes-pdf-toolkit 1.34.0 → 1.35.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.
@@ -197,14 +197,23 @@ class InvoiceGenerator {
197
197
  let invoiceItems;
198
198
  if (itemsMode === 'json') {
199
199
  const itemsJson = this.getNodeParameter('itemsJson', i);
200
- try {
201
- invoiceItems = JSON.parse(itemsJson);
202
- }
203
- catch (error) {
204
- if (error instanceof Error) {
205
- throw new Error(`Invalid JSON in 'Items JSON' field: ${error.message}`);
200
+ if (typeof itemsJson === 'string') {
201
+ try {
202
+ invoiceItems = JSON.parse(itemsJson);
203
+ }
204
+ catch (error) {
205
+ if (error instanceof Error) {
206
+ throw new Error(`Invalid JSON in 'Items JSON' field: ${error.message}`);
207
+ }
208
+ throw new Error(`Invalid JSON in 'Items JSON' field: ${String(error)}`);
206
209
  }
207
- throw new Error(`Invalid JSON in 'Items JSON' field: ${String(error)}`);
210
+ }
211
+ else if (Array.isArray(itemsJson)) {
212
+ invoiceItems = itemsJson;
213
+ }
214
+ else {
215
+ // Handle cases where the field might be empty or have other non-array/non-string values
216
+ invoiceItems = [];
208
217
  }
209
218
  }
210
219
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@custom-js/n8n-nodes-pdf-toolkit",
3
- "version": "1.34.0",
3
+ "version": "1.35.0",
4
4
  "description": "This is official node for interacting with APIs from customjs.space",
5
5
  "keywords": [
6
6
  "customjs",