@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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
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 {
|