@custom-js/n8n-nodes-pdf-toolkit 1.33.0 → 1.34.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.
@@ -126,6 +126,22 @@ class InvoiceGenerator {
126
126
  }
127
127
  ],
128
128
  },
129
+ {
130
+ displayName: 'Items Input Mode',
131
+ name: 'itemsMode',
132
+ type: 'options',
133
+ options: [
134
+ {
135
+ name: 'Define Manually',
136
+ value: 'define',
137
+ },
138
+ {
139
+ name: 'Use JSON Input',
140
+ value: 'json',
141
+ },
142
+ ],
143
+ default: 'define',
144
+ },
129
145
  {
130
146
  displayName: 'Items',
131
147
  name: 'items',
@@ -133,6 +149,11 @@ class InvoiceGenerator {
133
149
  typeOptions: {
134
150
  multipleValues: true,
135
151
  },
152
+ displayOptions: {
153
+ show: {
154
+ itemsMode: ['define'],
155
+ },
156
+ },
136
157
  default: {},
137
158
  placeholder: 'Add Item',
138
159
  options: [
@@ -147,6 +168,18 @@ class InvoiceGenerator {
147
168
  }
148
169
  ],
149
170
  },
171
+ {
172
+ displayName: 'Items JSON',
173
+ name: 'itemsJson',
174
+ type: 'json',
175
+ default: '[]',
176
+ displayOptions: {
177
+ show: {
178
+ itemsMode: ['json'],
179
+ },
180
+ },
181
+ description: 'A JSON array of invoice items. E.g., [{"description":"Item 1","quantity":2,"unitPrice":50}]',
182
+ },
150
183
  ],
151
184
  };
152
185
  }
@@ -160,7 +193,24 @@ class InvoiceGenerator {
160
193
  const payment = this.getNodeParameter('payment.paymentValues', i);
161
194
  const recipient = this.getNodeParameter('recipient.recipientValues', i);
162
195
  const billing = this.getNodeParameter('billing.billingValues', i);
163
- const invoiceItems = this.getNodeParameter('items.itemsValues', i);
196
+ const itemsMode = this.getNodeParameter('itemsMode', i);
197
+ let invoiceItems;
198
+ if (itemsMode === 'json') {
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}`);
206
+ }
207
+ throw new Error(`Invalid JSON in 'Items JSON' field: ${String(error)}`);
208
+ }
209
+ }
210
+ else {
211
+ const itemsData = this.getNodeParameter('items', i);
212
+ invoiceItems = itemsData.itemsValues;
213
+ }
164
214
  const invoiceData = {
165
215
  issuer,
166
216
  payment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@custom-js/n8n-nodes-pdf-toolkit",
3
- "version": "1.33.0",
3
+ "version": "1.34.0",
4
4
  "description": "This is official node for interacting with APIs from customjs.space",
5
5
  "keywords": [
6
6
  "customjs",