@pdfgeneratorapi/n8n-nodes-pdf-generator-api 0.5.0 โ†’ 0.5.1

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.
package/README.md CHANGED
@@ -12,6 +12,7 @@ PDF Generator API is a powerful service that allows you to generate PDFs from te
12
12
  [Compatibility](#compatibility)
13
13
  [Usage](#usage)
14
14
  [Resources](#resources)
15
+ [Development](#development)
15
16
  [Version history](#version-history)
16
17
 
17
18
  ## Installation
@@ -100,8 +101,7 @@ The node automatically handles JWT token generation using your API credentials.
100
101
 
101
102
  ## Compatibility
102
103
 
103
- - **Minimum n8n version**: 0.199.0
104
- - **Tested with**: n8n versions 0.199.0+
104
+ - **Minimum n8n version**: 1.85.0
105
105
  - **Node API version**: 1
106
106
 
107
107
  ## Usage
@@ -187,8 +187,30 @@ For workflows that should continue on errors, enable "Continue on Fail" in node
187
187
  * [Template Editor Guide](https://support.pdfgeneratorapi.com/en/category/components-1ffseaj/)
188
188
  * [Expression Language Documentation](https://support.pdfgeneratorapi.com/en/category/expression-language-q203pa/)
189
189
 
190
+ ## Development
191
+
192
+ ```bash
193
+ npm ci
194
+ npm run hooks:install # once per clone, runs npm run check before every commit
195
+ npm run check # build, unit tests, lint and n8n's scanner lint
196
+ ```
197
+
198
+ - `npm test` builds the node and runs the unit tests in `test/`. They run the node against a fake n8n context, so no API credentials are needed.
199
+ - `npm run lint:n8n` runs the lint checks of n8n's community package scanner (`@n8n/scan-community-package`), which n8n runs on every published version of a verified node. The scanner is installed separately in `tools/n8n-scan`.
200
+ - Releases are published by the GitHub Actions workflow when a version tag is pushed: bump `version` in `package.json`, merge to `master`, then push a tag with the same version, for example `git tag 0.5.1 && git push origin 0.5.1`.
201
+
190
202
  ## Version history
191
203
 
204
+ ### 0.5.1
205
+ - ๐Ÿ”ง **Improved**: Passes n8n's community package scanner, required for verified nodes
206
+ - Requests use `httpRequestWithAuthentication` instead of the deprecated `requestWithAuthentication`
207
+ - Output items keep their link to the input item (`pairedItem`)
208
+ - The credentials have an icon
209
+ - ๐Ÿ› **Fixed**: Error messages from the API are shown for file outputs too, not only the HTTP status
210
+ - ๐Ÿ› **Fixed**: Workspace Delete returns a success item instead of failing on an empty response
211
+ - ๐Ÿ”ง **Breaking**: Requires n8n 1.85.0 or later
212
+ - ๐Ÿงช **New**: Unit tests and a pre-commit hook that runs the same checks as the publish workflow
213
+
192
214
  ### 0.5.0
193
215
  - **New**: Added E-Invoice resource
194
216
  - Create E-Invoice (EN 16931, UBL or CII), Create Factur-X E-Invoice, Create XRechnung E-Invoice, Get Schema
@@ -2,6 +2,10 @@ import { ICredentialDataDecryptedObject, ICredentialTestRequest, ICredentialType
2
2
  export declare class PdfGeneratorApi implements ICredentialType {
3
3
  name: string;
4
4
  displayName: string;
5
+ icon: {
6
+ readonly light: "file:pdfgeneratorapi.svg";
7
+ readonly dark: "file:pdfgeneratorapi.svg";
8
+ };
5
9
  documentationUrl: string;
6
10
  properties: INodeProperties[];
7
11
  private validateCredentials;
@@ -6,6 +6,7 @@ class PdfGeneratorApi {
6
6
  constructor() {
7
7
  this.name = 'pdfGeneratorApi';
8
8
  this.displayName = 'PDF Generator API';
9
+ this.icon = { light: 'file:pdfgeneratorapi.svg', dark: 'file:pdfgeneratorapi.svg' };
9
10
  this.documentationUrl = 'https://docs.pdfgeneratorapi.com/v4';
10
11
  this.properties = [
11
12
  {
@@ -1 +1 @@
1
- {"version":3,"file":"PdfGeneratorApi.credentials.js","sourceRoot":"","sources":["../../credentials/PdfGeneratorApi.credentials.ts"],"names":[],"mappings":";;;AAAA,+CAOsB;AAEtB,MAAa,eAAe;IAA5B;QACC,SAAI,GAAG,iBAAiB,CAAC;QACzB,gBAAW,GAAG,mBAAmB,CAAC;QAClC,qBAAgB,GAAG,qCAAqC,CAAC;QACzD,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;g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,CAAC;QAC9D,MAAM,aAAa,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAGnD,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC;QAG/C,MAAM,KAAK,GAAG,GAAG,aAAa,IAAI,WAAW,EAAE,CAAC;QAGhD,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC,SAAmB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QACtG,MAAM,gBAAgB,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;QAC9C,MAAM,WAAW,GAAG,GAAG,KAAK,IAAI,gBAAgB,EAAE,CAAC;QAEnD,OAAO,WAAW,CAAC;IACpB,CAAC;CAoBD;AA1JD,0CA0JC"}
@@ -0,0 +1 @@
1
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 53 49" class="w-10" width="53" height="49" ><path fill="#02D1AE" d="M25.5 1.38A6.89 6.89 0 0 0 19.35.3L4.957 4.616A6.914 6.914 0 0 0 0 11.28v30.76a6.89 6.89 0 0 0 2.804 5.578 6.9 6.9 0 0 0 6.15 1.082l10.743-3.224a11.8 11.8 0 0 1-.506-3.437V28.07a11.7 11.7 0 0 1 3.017-7.883 11.8 11.8 0 0 1 5.357-3.375l.738-.211V6.962A6.9 6.9 0 0 0 25.5 1.381"></path><path fill="#02D1AE" d="M52.289 23.752v13.97a6.91 6.91 0 0 1-4.958 6.66L32.939 48.7a6.89 6.89 0 0 1-6.15-1.082 7 7 0 0 1-1.441-1.439 6.8 6.8 0 0 1-1.075-2.144q-.003 0-.007.002l.005-.005a7.1 7.1 0 0 1-.286-1.993V28.07c0-1.433.427-2.779 1.18-3.897a6.9 6.9 0 0 1 3.779-2.765l1.76-.528 12.631-3.79a6.89 6.89 0 0 1 6.15 1.082 6.9 6.9 0 0 1 2.804 5.581"></path></svg>
@@ -15,8 +15,8 @@ class PdfGeneratorApi {
15
15
  defaults: {
16
16
  name: 'PDF Generator API',
17
17
  },
18
- inputs: ["main"],
19
- outputs: ["main"],
18
+ inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
19
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
20
20
  usableAsTool: true,
21
21
  credentials: [
22
22
  {
@@ -2014,7 +2014,7 @@ class PdfGeneratorApi {
2014
2014
  },
2015
2015
  json: true,
2016
2016
  };
2017
- const response = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2017
+ const response = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2018
2018
  if (response && response.response) {
2019
2019
  for (const template of response.response) {
2020
2020
  const displayName = `${template.name} (ID: ${template.id})`;
@@ -2055,28 +2055,42 @@ class PdfGeneratorApi {
2055
2055
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${field} must be valid JSON`);
2056
2056
  }
2057
2057
  };
2058
- const validationDetails = (messages, message) => {
2059
- if (!Array.isArray(messages))
2058
+ const validationDetails = (errors, message) => {
2059
+ if (!errors || typeof errors !== 'object')
2060
2060
  return '';
2061
- for (const entry of messages) {
2062
- if (typeof entry !== 'string' || entry.indexOf('{') === -1)
2063
- continue;
2064
- try {
2065
- const body = JSON.parse(entry.slice(entry.indexOf('{')));
2066
- const errors = body && body.errors;
2067
- if (!errors || typeof errors !== 'object')
2068
- continue;
2069
- const parts = (Array.isArray(errors) ? errors.map((e) => ['', e]) : Object.entries(errors))
2070
- .map(([field, e]) => [field, [].concat(e).map(String).filter((t) => !message.includes(t)).join(' ')])
2071
- .filter(([, text]) => text)
2072
- .map(([field, text]) => (field ? `${field}: ${text}` : text));
2073
- if (parts.length)
2074
- return ` (${parts.join('; ')})`;
2075
- }
2076
- catch (error) {
2077
- }
2061
+ const parts = (Array.isArray(errors) ? errors.map((e) => ['', e]) : Object.entries(errors))
2062
+ .map(([field, e]) => [field, [].concat(e).map(String).filter((t) => !message.includes(t)).join(' ')])
2063
+ .filter(([, text]) => text)
2064
+ .map(([field, text]) => (field ? `${field}: ${text}` : text));
2065
+ return parts.length ? ` (${parts.join('; ')})` : '';
2066
+ };
2067
+ const parseErrorBody = (body) => {
2068
+ const text = Buffer.isBuffer(body) ? body.toString('utf8') : body;
2069
+ if (typeof text !== 'string')
2070
+ return (text !== null && text !== void 0 ? text : {});
2071
+ try {
2072
+ return JSON.parse(text);
2073
+ }
2074
+ catch (error) {
2075
+ return text.trimStart().startsWith('<') ? {} : { message: text.trim() };
2076
+ }
2077
+ };
2078
+ const apiRequest = async (options, itemIndex, errorPrefix) => {
2079
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfGeneratorApi', {
2080
+ ...options,
2081
+ returnFullResponse: true,
2082
+ ignoreHttpStatusErrors: true,
2083
+ }));
2084
+ if (response.statusCode >= 400) {
2085
+ const body = parseErrorBody(response.body);
2086
+ const apiMessage = typeof body.message === 'string' ? body.message : '';
2087
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), body, {
2088
+ httpCode: String(response.statusCode),
2089
+ itemIndex,
2090
+ message: errorPrefix && apiMessage ? `${errorPrefix}: ${apiMessage}${validationDetails(body.errors, apiMessage)}` : undefined,
2091
+ });
2078
2092
  }
2079
- return '';
2093
+ return options.returnFullResponse ? response : response.body;
2080
2094
  };
2081
2095
  const getMimeType = (format) => {
2082
2096
  switch (format) {
@@ -2122,9 +2136,9 @@ class PdfGeneratorApi {
2122
2136
  url: '/assets/qrcode',
2123
2137
  body,
2124
2138
  json: qrOutputFormat !== 'file',
2125
- encoding: qrOutputFormat === 'file' ? null : 'utf8',
2139
+ encoding: qrOutputFormat === 'file' ? 'arraybuffer' : 'json',
2126
2140
  };
2127
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2141
+ responseData = await apiRequest(options, i);
2128
2142
  if (responseData) {
2129
2143
  if (qrOutputFormat === 'file') {
2130
2144
  const binaryData = {};
@@ -2138,6 +2152,7 @@ class PdfGeneratorApi {
2138
2152
  fileSize: responseData.length,
2139
2153
  },
2140
2154
  binary: binaryData,
2155
+ pairedItem: { item: i },
2141
2156
  });
2142
2157
  }
2143
2158
  else {
@@ -2147,6 +2162,7 @@ class PdfGeneratorApi {
2147
2162
  format: qrOutputFormat,
2148
2163
  ...responseData,
2149
2164
  },
2165
+ pairedItem: { item: i },
2150
2166
  });
2151
2167
  }
2152
2168
  continue;
@@ -2154,21 +2170,7 @@ class PdfGeneratorApi {
2154
2170
  }
2155
2171
  }
2156
2172
  else if (resource === 'einvoice') {
2157
- const callEInvoice = async (requestOptions) => {
2158
- try {
2159
- return await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', requestOptions);
2160
- }
2161
- catch (error) {
2162
- if (error.httpCode !== undefined) {
2163
- const description = typeof error.description === 'string' ? error.description : '';
2164
- if (description && !description.trimStart().startsWith('<')) {
2165
- error.message = `PDF Generator API e-invoice request failed: ${description}${validationDetails(error.messages, description)}`;
2166
- }
2167
- error.context = { ...(error.context || {}), itemIndex: i };
2168
- }
2169
- throw error;
2170
- }
2171
- };
2173
+ const callEInvoice = async (requestOptions) => await apiRequest(requestOptions, i, 'PDF Generator API e-invoice request failed');
2172
2174
  const pushDocument = async (payload, output, fallbackName, fallbackMimeType) => {
2173
2175
  if (output === 'file') {
2174
2176
  const binary = {};
@@ -2181,6 +2183,7 @@ class PdfGeneratorApi {
2181
2183
  fileSize: payload.length,
2182
2184
  },
2183
2185
  binary,
2186
+ pairedItem: { item: i },
2184
2187
  });
2185
2188
  return;
2186
2189
  }
@@ -2198,6 +2201,7 @@ class PdfGeneratorApi {
2198
2201
  ...rest,
2199
2202
  },
2200
2203
  binary,
2204
+ pairedItem: { item: i },
2201
2205
  });
2202
2206
  };
2203
2207
  if (operation === 'createEInvoice' || operation === 'createXRechnung') {
@@ -2221,7 +2225,7 @@ class PdfGeneratorApi {
2221
2225
  url: operation === 'createXRechnung' ? '/einvoice/xrechnung' : '/einvoice',
2222
2226
  body,
2223
2227
  json: output !== 'file',
2224
- encoding: output === 'file' ? null : 'utf8',
2228
+ encoding: output === 'file' ? 'arraybuffer' : 'json',
2225
2229
  };
2226
2230
  responseData = await callEInvoice(options);
2227
2231
  if (responseData) {
@@ -2268,7 +2272,7 @@ class PdfGeneratorApi {
2268
2272
  url: '/einvoice/facturx',
2269
2273
  body,
2270
2274
  json: output !== 'file',
2271
- encoding: output === 'file' ? null : 'utf8',
2275
+ encoding: output === 'file' ? 'arraybuffer' : 'json',
2272
2276
  };
2273
2277
  responseData = await callEInvoice(options);
2274
2278
  if (responseData && (output === 'base64' || output === 'file')) {
@@ -2326,9 +2330,9 @@ class PdfGeneratorApi {
2326
2330
  url: '/conversion/html2pdf',
2327
2331
  body,
2328
2332
  json: body.output !== 'file',
2329
- encoding: body.output === 'file' ? null : 'utf8',
2333
+ encoding: body.output === 'file' ? 'arraybuffer' : 'json',
2330
2334
  };
2331
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2335
+ responseData = await apiRequest(options, i);
2332
2336
  }
2333
2337
  else if (operation === 'urlToPdf') {
2334
2338
  const url = this.getNodeParameter('url', i);
@@ -2339,9 +2343,9 @@ class PdfGeneratorApi {
2339
2343
  url: '/conversion/url2pdf',
2340
2344
  body,
2341
2345
  json: body.output !== 'file',
2342
- encoding: body.output === 'file' ? null : 'utf8',
2346
+ encoding: body.output === 'file' ? 'arraybuffer' : 'json',
2343
2347
  };
2344
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2348
+ responseData = await apiRequest(options, i);
2345
2349
  }
2346
2350
  if (responseData) {
2347
2351
  const outputFormat = body.output || 'base64';
@@ -2357,6 +2361,7 @@ class PdfGeneratorApi {
2357
2361
  fileSize: responseData.length,
2358
2362
  },
2359
2363
  binary: binaryData,
2364
+ pairedItem: { item: i },
2360
2365
  });
2361
2366
  }
2362
2367
  else {
@@ -2367,6 +2372,7 @@ class PdfGeneratorApi {
2367
2372
  format: outputFormat,
2368
2373
  ...responseData,
2369
2374
  },
2375
+ pairedItem: { item: i },
2370
2376
  });
2371
2377
  }
2372
2378
  continue;
@@ -2393,7 +2399,7 @@ class PdfGeneratorApi {
2393
2399
  qs,
2394
2400
  json: true,
2395
2401
  };
2396
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2402
+ responseData = await apiRequest(options, i);
2397
2403
  }
2398
2404
  else if (operation === 'get') {
2399
2405
  const publicId = this.getNodeParameter('publicId', i);
@@ -2403,7 +2409,7 @@ class PdfGeneratorApi {
2403
2409
  url: `/documents/${publicId}`,
2404
2410
  json: true,
2405
2411
  };
2406
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2412
+ responseData = await apiRequest(options, i);
2407
2413
  }
2408
2414
  else if (operation === 'delete') {
2409
2415
  const publicId = this.getNodeParameter('publicId', i);
@@ -2413,7 +2419,7 @@ class PdfGeneratorApi {
2413
2419
  url: `/documents/${publicId}`,
2414
2420
  json: true,
2415
2421
  };
2416
- await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2422
+ await apiRequest(options, i);
2417
2423
  responseData = {
2418
2424
  success: true,
2419
2425
  message: 'Document deleted successfully',
@@ -2445,9 +2451,9 @@ class PdfGeneratorApi {
2445
2451
  url: '/documents/generate',
2446
2452
  body,
2447
2453
  json: output !== 'file',
2448
- encoding: output === 'file' ? null : 'utf8',
2454
+ encoding: output === 'file' ? 'arraybuffer' : 'json',
2449
2455
  };
2450
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2456
+ responseData = await apiRequest(options, i);
2451
2457
  if (responseData && output !== 'url' && output !== 'viewer') {
2452
2458
  if (output === 'file') {
2453
2459
  const binaryData = {};
@@ -2461,6 +2467,7 @@ class PdfGeneratorApi {
2461
2467
  fileSize: responseData.length,
2462
2468
  },
2463
2469
  binary: binaryData,
2470
+ pairedItem: { item: i },
2464
2471
  });
2465
2472
  continue;
2466
2473
  }
@@ -2472,6 +2479,7 @@ class PdfGeneratorApi {
2472
2479
  format: output,
2473
2480
  ...responseData,
2474
2481
  },
2482
+ pairedItem: { item: i },
2475
2483
  });
2476
2484
  continue;
2477
2485
  }
@@ -2512,7 +2520,7 @@ class PdfGeneratorApi {
2512
2520
  body,
2513
2521
  json: true,
2514
2522
  };
2515
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2523
+ responseData = await apiRequest(options, i);
2516
2524
  }
2517
2525
  else if (operation === 'generateBatch') {
2518
2526
  const templates = this.getNodeParameter('templates', i);
@@ -2541,9 +2549,9 @@ class PdfGeneratorApi {
2541
2549
  url: '/documents/generate/batch',
2542
2550
  body,
2543
2551
  json: output !== 'file',
2544
- encoding: output === 'file' ? null : 'utf8',
2552
+ encoding: output === 'file' ? 'arraybuffer' : 'json',
2545
2553
  };
2546
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2554
+ responseData = await apiRequest(options, i);
2547
2555
  if (responseData && output !== 'url' && output !== 'viewer') {
2548
2556
  if (output === 'file') {
2549
2557
  const binaryData = {};
@@ -2557,6 +2565,7 @@ class PdfGeneratorApi {
2557
2565
  fileSize: responseData.length,
2558
2566
  },
2559
2567
  binary: binaryData,
2568
+ pairedItem: { item: i },
2560
2569
  });
2561
2570
  continue;
2562
2571
  }
@@ -2568,6 +2577,7 @@ class PdfGeneratorApi {
2568
2577
  format: output,
2569
2578
  ...responseData,
2570
2579
  },
2580
+ pairedItem: { item: i },
2571
2581
  });
2572
2582
  continue;
2573
2583
  }
@@ -2610,7 +2620,7 @@ class PdfGeneratorApi {
2610
2620
  body,
2611
2621
  json: true,
2612
2622
  };
2613
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2623
+ responseData = await apiRequest(options, i);
2614
2624
  }
2615
2625
  }
2616
2626
  else if (resource === 'template') {
@@ -2634,7 +2644,7 @@ class PdfGeneratorApi {
2634
2644
  qs,
2635
2645
  json: true,
2636
2646
  };
2637
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2647
+ responseData = await apiRequest(options, i);
2638
2648
  }
2639
2649
  else if (operation === 'get') {
2640
2650
  const templateIdParam = this.getNodeParameter('templateId', i);
@@ -2645,7 +2655,7 @@ class PdfGeneratorApi {
2645
2655
  url: `/templates/${templateId}`,
2646
2656
  json: true,
2647
2657
  };
2648
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2658
+ responseData = await apiRequest(options, i);
2649
2659
  }
2650
2660
  else if (operation === 'create') {
2651
2661
  const templateConfiguration = this.getNodeParameter('templateConfiguration', i);
@@ -2657,7 +2667,7 @@ class PdfGeneratorApi {
2657
2667
  body,
2658
2668
  json: true,
2659
2669
  };
2660
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2670
+ responseData = await apiRequest(options, i);
2661
2671
  }
2662
2672
  else if (operation === 'update') {
2663
2673
  const templateIdParam = this.getNodeParameter('templateId', i);
@@ -2671,7 +2681,7 @@ class PdfGeneratorApi {
2671
2681
  body,
2672
2682
  json: true,
2673
2683
  };
2674
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2684
+ responseData = await apiRequest(options, i);
2675
2685
  }
2676
2686
  else if (operation === 'delete') {
2677
2687
  const templateIdParam = this.getNodeParameter('templateId', i);
@@ -2682,7 +2692,7 @@ class PdfGeneratorApi {
2682
2692
  url: `/templates/${templateId}`,
2683
2693
  json: true,
2684
2694
  };
2685
- await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2695
+ await apiRequest(options, i);
2686
2696
  responseData = {
2687
2697
  success: true,
2688
2698
  message: 'Template deleted successfully',
@@ -2702,7 +2712,7 @@ class PdfGeneratorApi {
2702
2712
  body,
2703
2713
  json: true,
2704
2714
  };
2705
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2715
+ responseData = await apiRequest(options, i);
2706
2716
  }
2707
2717
  else if (operation === 'getDataFields') {
2708
2718
  const templateIdParam = this.getNodeParameter('templateId', i);
@@ -2713,7 +2723,7 @@ class PdfGeneratorApi {
2713
2723
  url: `/templates/${templateId}/data`,
2714
2724
  json: true,
2715
2725
  };
2716
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2726
+ responseData = await apiRequest(options, i);
2717
2727
  }
2718
2728
  else if (operation === 'getTemplateSchema') {
2719
2729
  const options = {
@@ -2722,7 +2732,7 @@ class PdfGeneratorApi {
2722
2732
  url: '/templates/schema',
2723
2733
  json: true,
2724
2734
  };
2725
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2735
+ responseData = await apiRequest(options, i);
2726
2736
  }
2727
2737
  else if (operation === 'copy') {
2728
2738
  const templateIdParam = this.getNodeParameter('templateId', i);
@@ -2738,7 +2748,7 @@ class PdfGeneratorApi {
2738
2748
  body,
2739
2749
  json: true,
2740
2750
  };
2741
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2751
+ responseData = await apiRequest(options, i);
2742
2752
  }
2743
2753
  else if (operation === 'openEditor') {
2744
2754
  const templateIdParam = this.getNodeParameter('templateId', i);
@@ -2756,7 +2766,7 @@ class PdfGeneratorApi {
2756
2766
  body,
2757
2767
  json: true,
2758
2768
  };
2759
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2769
+ responseData = await apiRequest(options, i);
2760
2770
  }
2761
2771
  }
2762
2772
  else if (resource === 'pdfServices') {
@@ -2820,9 +2830,9 @@ class PdfGeneratorApi {
2820
2830
  url: '/pdfservices/watermark',
2821
2831
  body,
2822
2832
  json: outputFormat !== 'file',
2823
- encoding: outputFormat === 'file' ? null : 'utf8',
2833
+ encoding: outputFormat === 'file' ? 'arraybuffer' : 'json',
2824
2834
  };
2825
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2835
+ responseData = await apiRequest(options, i);
2826
2836
  }
2827
2837
  else if (operation === 'encrypt') {
2828
2838
  const ownerPassword = this.getNodeParameter('ownerPassword', i);
@@ -2837,9 +2847,9 @@ class PdfGeneratorApi {
2837
2847
  url: '/pdfservices/encrypt',
2838
2848
  body,
2839
2849
  json: outputFormat !== 'file',
2840
- encoding: outputFormat === 'file' ? null : 'utf8',
2850
+ encoding: outputFormat === 'file' ? 'arraybuffer' : 'json',
2841
2851
  };
2842
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2852
+ responseData = await apiRequest(options, i);
2843
2853
  }
2844
2854
  else if (operation === 'decrypt') {
2845
2855
  const decryptionPassword = this.getNodeParameter('decryptionPassword', i);
@@ -2851,9 +2861,9 @@ class PdfGeneratorApi {
2851
2861
  url: '/pdfservices/decrypt',
2852
2862
  body,
2853
2863
  json: outputFormat !== 'file',
2854
- encoding: outputFormat === 'file' ? null : 'utf8',
2864
+ encoding: outputFormat === 'file' ? 'arraybuffer' : 'json',
2855
2865
  };
2856
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2866
+ responseData = await apiRequest(options, i);
2857
2867
  }
2858
2868
  else if (operation === 'extractFormFields') {
2859
2869
  const options = {
@@ -2863,7 +2873,7 @@ class PdfGeneratorApi {
2863
2873
  body,
2864
2874
  json: true,
2865
2875
  };
2866
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2876
+ responseData = await apiRequest(options, i);
2867
2877
  }
2868
2878
  else if (operation === 'fillFormFields') {
2869
2879
  const formFieldsData = this.getNodeParameter('formFieldsData', i);
@@ -2875,9 +2885,9 @@ class PdfGeneratorApi {
2875
2885
  url: '/pdfservices/form/fill',
2876
2886
  body,
2877
2887
  json: outputFormat !== 'file',
2878
- encoding: outputFormat === 'file' ? null : 'utf8',
2888
+ encoding: outputFormat === 'file' ? 'arraybuffer' : 'json',
2879
2889
  };
2880
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2890
+ responseData = await apiRequest(options, i);
2881
2891
  }
2882
2892
  else if (operation === 'optimize') {
2883
2893
  const options = {
@@ -2886,10 +2896,10 @@ class PdfGeneratorApi {
2886
2896
  url: '/pdfservices/optimize',
2887
2897
  body,
2888
2898
  json: outputFormat !== 'file',
2889
- encoding: outputFormat === 'file' ? null : 'utf8',
2890
- resolveWithFullResponse: true,
2899
+ encoding: outputFormat === 'file' ? 'arraybuffer' : 'json',
2900
+ returnFullResponse: true,
2891
2901
  };
2892
- const fullResponse = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2902
+ const fullResponse = await apiRequest(options, i);
2893
2903
  responseData = fullResponse.body;
2894
2904
  const headers = fullResponse.headers || {};
2895
2905
  const originalSize = headers['x-original-size'] ? parseInt(headers['x-original-size'], 10) : null;
@@ -2908,6 +2918,7 @@ class PdfGeneratorApi {
2908
2918
  operation,
2909
2919
  ...responseData,
2910
2920
  },
2921
+ pairedItem: { item: i },
2911
2922
  });
2912
2923
  }
2913
2924
  else if (outputFormat === 'file') {
@@ -2932,6 +2943,7 @@ class PdfGeneratorApi {
2932
2943
  returnData.push({
2933
2944
  json: jsonResponse,
2934
2945
  binary: binaryData,
2946
+ pairedItem: { item: i },
2935
2947
  });
2936
2948
  }
2937
2949
  else {
@@ -2951,6 +2963,7 @@ class PdfGeneratorApi {
2951
2963
  }
2952
2964
  returnData.push({
2953
2965
  json: jsonResponse,
2966
+ pairedItem: { item: i },
2954
2967
  });
2955
2968
  }
2956
2969
  continue;
@@ -2971,7 +2984,7 @@ class PdfGeneratorApi {
2971
2984
  qs,
2972
2985
  json: true,
2973
2986
  };
2974
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
2987
+ responseData = await apiRequest(options, i);
2975
2988
  }
2976
2989
  else if (operation === 'create') {
2977
2990
  const identifier = this.getNodeParameter('identifier', i);
@@ -2985,7 +2998,7 @@ class PdfGeneratorApi {
2985
2998
  body,
2986
2999
  json: true,
2987
3000
  };
2988
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
3001
+ responseData = await apiRequest(options, i);
2989
3002
  }
2990
3003
  else if (operation === 'get') {
2991
3004
  const workspaceIdentifier = this.getNodeParameter('workspaceIdentifier', i);
@@ -2995,7 +3008,7 @@ class PdfGeneratorApi {
2995
3008
  url: `/workspaces/${encodeURIComponent(workspaceIdentifier)}`,
2996
3009
  json: true,
2997
3010
  };
2998
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
3011
+ responseData = await apiRequest(options, i);
2999
3012
  }
3000
3013
  else if (operation === 'delete') {
3001
3014
  const workspaceIdentifier = this.getNodeParameter('workspaceIdentifier', i);
@@ -3005,7 +3018,11 @@ class PdfGeneratorApi {
3005
3018
  url: `/workspaces/${encodeURIComponent(workspaceIdentifier)}`,
3006
3019
  json: true,
3007
3020
  };
3008
- responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
3021
+ responseData = (await apiRequest(options, i)) || {
3022
+ success: true,
3023
+ message: 'Workspace deleted successfully',
3024
+ workspaceIdentifier,
3025
+ };
3009
3026
  }
3010
3027
  }
3011
3028
  if (responseData === undefined) {
@@ -3020,7 +3037,10 @@ class PdfGeneratorApi {
3020
3037
  returnData.push(...executionErrorData);
3021
3038
  continue;
3022
3039
  }
3023
- throw error;
3040
+ if (error instanceof n8n_workflow_1.NodeOperationError) {
3041
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
3042
+ }
3043
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error, { itemIndex: i });
3024
3044
  }
3025
3045
  }
3026
3046
  return [returnData];