n8n-nodes-iterationlayer 1.0.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.
Files changed (26) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -0
  3. package/dist/credentials/IterationLayerApi.credentials.d.ts +8 -0
  4. package/dist/credentials/IterationLayerApi.credentials.js +35 -0
  5. package/dist/nodes/IterationLayer/IterationLayer.node.d.ts +5 -0
  6. package/dist/nodes/IterationLayer/IterationLayer.node.js +407 -0
  7. package/dist/nodes/IterationLayer/descriptions/documentExtraction.d.ts +2 -0
  8. package/dist/nodes/IterationLayer/descriptions/documentExtraction.js +187 -0
  9. package/dist/nodes/IterationLayer/descriptions/documentGeneration.d.ts +2 -0
  10. package/dist/nodes/IterationLayer/descriptions/documentGeneration.js +62 -0
  11. package/dist/nodes/IterationLayer/descriptions/documentToMarkdown.d.ts +2 -0
  12. package/dist/nodes/IterationLayer/descriptions/documentToMarkdown.js +22 -0
  13. package/dist/nodes/IterationLayer/descriptions/imageGeneration.d.ts +2 -0
  14. package/dist/nodes/IterationLayer/descriptions/imageGeneration.js +99 -0
  15. package/dist/nodes/IterationLayer/descriptions/imageTransformation.d.ts +2 -0
  16. package/dist/nodes/IterationLayer/descriptions/imageTransformation.js +364 -0
  17. package/dist/nodes/IterationLayer/descriptions/shared.d.ts +7 -0
  18. package/dist/nodes/IterationLayer/descriptions/shared.js +73 -0
  19. package/dist/nodes/IterationLayer/descriptions/sheetGeneration.d.ts +2 -0
  20. package/dist/nodes/IterationLayer/descriptions/sheetGeneration.js +73 -0
  21. package/dist/nodes/IterationLayer/helpers/binaryData.d.ts +2 -0
  22. package/dist/nodes/IterationLayer/helpers/binaryData.js +23 -0
  23. package/dist/nodes/IterationLayer/helpers/fileInput.d.ts +15 -0
  24. package/dist/nodes/IterationLayer/helpers/fileInput.js +43 -0
  25. package/dist/nodes/IterationLayer/iterationlayer.svg +7 -0
  26. package/package.json +50 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Iteration Layer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # n8n-nodes-iterationlayer
2
+
3
+ n8n community node for the [Iteration Layer](https://iterationlayer.com) API.
4
+
5
+ Extract data from documents, transform images, generate images, and create documents — all from your n8n workflows.
6
+
7
+ ## Installation
8
+
9
+ ### Via n8n UI (recommended)
10
+
11
+ 1. Open **Settings** > **Community Nodes**
12
+ 2. Select **Install a community node**
13
+ 3. Enter `n8n-nodes-iterationlayer`
14
+ 4. Accept the risks and install
15
+
16
+ ### Via npm (self-hosted)
17
+
18
+ ```bash
19
+ cd ~/.n8n
20
+ npm install n8n-nodes-iterationlayer
21
+ ```
22
+
23
+ Restart n8n after installation.
24
+
25
+ ## Credentials
26
+
27
+ 1. Go to **Credentials** > **New Credential**
28
+ 2. Search for **Iteration Layer API**
29
+ 3. Enter your API key (starts with `il_`)
30
+ 4. Get an API key at [platform.iterationlayer.com](https://platform.iterationlayer.com)
31
+
32
+ ## Resources
33
+
34
+ The node provides four resources, one for each Iteration Layer API:
35
+
36
+ ### Document Extraction
37
+
38
+ Extract structured data from PDFs, images, DOCX, and more. Define a schema with field names, types, and descriptions — the API returns typed values with confidence scores.
39
+
40
+ - **File input**: Binary data from a previous node or a public URL
41
+ - **Schema**: Build via the UI (17 field types) or provide raw JSON for advanced schemas (arrays, calculated fields)
42
+
43
+ ### Image Transformation
44
+
45
+ Apply image operations sequentially: resize, crop, rotate, blur, sharpen, convert format, upscale, remove background, and more (24 operations total).
46
+
47
+ - **File input**: Binary data or URL
48
+ - **Operations**: Add multiple operations via the UI — each type shows its specific parameters
49
+
50
+ ### Image Generation
51
+
52
+ Generate images from layer compositions defined as JSON. Supports solid-color, text, image, QR code, barcode, and gradient layers.
53
+
54
+ - **Dimensions**: Width and height in pixels
55
+ - **Layers**: JSON array defining the composition (see [API docs](https://iterationlayer.com/docs/image-generation))
56
+ - **Output format**: PNG, JPEG, WebP, TIFF, GIF, or AVIF
57
+
58
+ ### Document Generation
59
+
60
+ Generate PDF, DOCX, EPUB, or PPTX documents from structured JSON definitions including metadata, page layout, styles, and content blocks.
61
+
62
+ - **Format**: PDF, DOCX, EPUB, or PPTX
63
+ - **Document**: JSON object with the full document definition (see [API docs](https://iterationlayer.com/docs/document-generation))
64
+
65
+ ## Binary Data
66
+
67
+ Image Transformation, Image Generation, and Document Generation return binary data. The output is available as n8n binary data that you can pass to downstream nodes (e.g., write to disk, send via email, upload to S3).
68
+
69
+ Document Extraction returns JSON data with extracted field values and confidence scores.
70
+
71
+ ## Async Mode
72
+
73
+ All resources support async mode. Enable it and provide a webhook URL — the API returns immediately and delivers results to your webhook when processing is complete.
74
+
75
+ ## Links
76
+
77
+ - [Iteration Layer Docs](https://iterationlayer.com/docs)
78
+ - [n8n Integration Guide](https://iterationlayer.com/docs/n8n)
79
+ - [API Reference](https://iterationlayer.com/docs/document-extraction)
80
+ - [Get an API Key](https://platform.iterationlayer.com)
81
+
82
+ ## License
83
+
84
+ MIT
@@ -0,0 +1,8 @@
1
+ import type { IAuthenticateGeneric, ICredentialType, INodeProperties } from "n8n-workflow";
2
+ export declare class IterationLayerApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ authenticate: IAuthenticateGeneric;
8
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IterationLayerApi = void 0;
4
+ class IterationLayerApi {
5
+ name = "iterationLayerApi";
6
+ displayName = "Iteration Layer API";
7
+ documentationUrl = "https://iterationlayer.com/docs/n8n";
8
+ properties = [
9
+ {
10
+ displayName: "API Key",
11
+ name: "apiKey",
12
+ type: "string",
13
+ typeOptions: { password: true },
14
+ default: "",
15
+ placeholder: "il_xxxx",
16
+ description: "Your Iteration Layer API key. Get one at https://platform.iterationlayer.com.",
17
+ },
18
+ {
19
+ displayName: "Base URL",
20
+ name: "baseUrl",
21
+ type: "string",
22
+ default: "https://api.iterationlayer.com",
23
+ description: "Override the API base URL for development or self-hosted instances.",
24
+ },
25
+ ];
26
+ authenticate = {
27
+ type: "generic",
28
+ properties: {
29
+ headers: {
30
+ Authorization: "=Bearer {{$credentials.apiKey}}",
31
+ },
32
+ },
33
+ };
34
+ }
35
+ exports.IterationLayerApi = IterationLayerApi;
@@ -0,0 +1,5 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from "n8n-workflow";
2
+ export declare class IterationLayer implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,407 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IterationLayer = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const documentExtraction_js_1 = require("./descriptions/documentExtraction.js");
6
+ const documentGeneration_js_1 = require("./descriptions/documentGeneration.js");
7
+ const documentToMarkdown_js_1 = require("./descriptions/documentToMarkdown.js");
8
+ const imageGeneration_js_1 = require("./descriptions/imageGeneration.js");
9
+ const imageTransformation_js_1 = require("./descriptions/imageTransformation.js");
10
+ const sheetGeneration_js_1 = require("./descriptions/sheetGeneration.js");
11
+ const binaryData_js_1 = require("./helpers/binaryData.js");
12
+ const fileInput_js_1 = require("./helpers/fileInput.js");
13
+ function buildTransformOperation(entry) {
14
+ const operationType = entry.operationType;
15
+ switch (operationType) {
16
+ case "resize":
17
+ return {
18
+ type: "resize",
19
+ width_in_px: entry.widthInPx,
20
+ height_in_px: entry.heightInPx,
21
+ fit: entry.fit,
22
+ };
23
+ case "crop":
24
+ return {
25
+ type: "crop",
26
+ left_in_px: entry.leftInPx,
27
+ top_in_px: entry.topInPx,
28
+ width_in_px: entry.widthInPx,
29
+ height_in_px: entry.heightInPx,
30
+ };
31
+ case "smart_crop":
32
+ return {
33
+ type: "smart_crop",
34
+ width_in_px: entry.widthInPx,
35
+ height_in_px: entry.heightInPx,
36
+ };
37
+ case "extend":
38
+ return {
39
+ type: "extend",
40
+ top_in_px: entry.extendTopInPx,
41
+ bottom_in_px: entry.extendBottomInPx,
42
+ left_in_px: entry.extendLeftInPx,
43
+ right_in_px: entry.extendRightInPx,
44
+ hex_color: entry.hexColor,
45
+ };
46
+ case "trim":
47
+ return { type: "trim", threshold: entry.thresholdValue };
48
+ case "rotate":
49
+ return {
50
+ type: "rotate",
51
+ angle_in_degrees: entry.angleInDegrees,
52
+ hex_color: entry.hexColor,
53
+ };
54
+ case "flip":
55
+ return { type: "flip" };
56
+ case "flop":
57
+ return { type: "flop" };
58
+ case "blur":
59
+ return { type: "blur", sigma: entry.sigma };
60
+ case "sharpen":
61
+ return { type: "sharpen", sigma: entry.sigma };
62
+ case "modulate":
63
+ return {
64
+ type: "modulate",
65
+ brightness: entry.brightness,
66
+ saturation: entry.saturation,
67
+ hue: entry.hue,
68
+ };
69
+ case "tint":
70
+ return { type: "tint", hex_color: entry.tintHexColor };
71
+ case "grayscale":
72
+ return { type: "grayscale" };
73
+ case "invert_colors":
74
+ return { type: "invert_colors" };
75
+ case "auto_contrast":
76
+ return { type: "auto_contrast" };
77
+ case "gamma":
78
+ return { type: "gamma", gamma: entry.gamma };
79
+ case "opacity":
80
+ return { type: "opacity", opacity_in_percent: entry.opacityInPercent };
81
+ case "remove_transparency":
82
+ return { type: "remove_transparency", hex_color: entry.hexColor };
83
+ case "threshold":
84
+ return {
85
+ type: "threshold",
86
+ value: entry.thresholdValue,
87
+ is_grayscale: entry.isGrayscale,
88
+ };
89
+ case "denoise":
90
+ return { type: "denoise", size: entry.denoiseSize };
91
+ case "convert":
92
+ return {
93
+ type: "convert",
94
+ format: entry.convertFormat,
95
+ quality: entry.quality,
96
+ };
97
+ case "upscale":
98
+ return { type: "upscale", factor: entry.upscaleFactor };
99
+ case "compress_to_size":
100
+ return {
101
+ type: "compress_to_size",
102
+ max_file_size_in_bytes: entry.maxFileSizeInBytes,
103
+ };
104
+ case "remove_background":
105
+ return {
106
+ type: "remove_background",
107
+ background_hex_color: entry.hexColor || undefined,
108
+ };
109
+ default:
110
+ return { type: operationType };
111
+ }
112
+ }
113
+ class IterationLayer {
114
+ description = {
115
+ displayName: "Iteration Layer",
116
+ name: "iterationLayer",
117
+ icon: "file:iterationlayer.svg",
118
+ group: ["transform"],
119
+ version: 1,
120
+ subtitle: '={{ $parameter["resource"] }}',
121
+ description: "Extract data from documents, transform images, generate images, and create documents",
122
+ defaults: {
123
+ name: "Iteration Layer",
124
+ },
125
+ inputs: ["main" /* NodeConnectionType.Main */],
126
+ outputs: ["main" /* NodeConnectionType.Main */],
127
+ credentials: [
128
+ {
129
+ name: "iterationLayerApi",
130
+ required: true,
131
+ },
132
+ ],
133
+ properties: [
134
+ {
135
+ displayName: "Resource",
136
+ name: "resource",
137
+ type: "options",
138
+ noDataExpression: true,
139
+ options: [
140
+ {
141
+ name: "Document Extraction",
142
+ value: "documentExtraction",
143
+ description: "Extract structured data from documents and images using AI",
144
+ },
145
+ {
146
+ name: "Image Transformation",
147
+ value: "imageTransformation",
148
+ description: "Resize, crop, convert, and apply effects to images",
149
+ },
150
+ {
151
+ name: "Image Generation",
152
+ value: "imageGeneration",
153
+ description: "Generate images from layer compositions",
154
+ },
155
+ {
156
+ name: "Document Generation",
157
+ value: "documentGeneration",
158
+ description: "Generate PDF, DOCX, EPUB, or PPTX documents",
159
+ },
160
+ {
161
+ name: "Document to Markdown",
162
+ value: "documentToMarkdown",
163
+ description: "Convert documents to clean, structured Markdown",
164
+ },
165
+ {
166
+ name: "Sheet Generation",
167
+ value: "sheetGeneration",
168
+ description: "Generate XLSX, CSV, or Markdown spreadsheets",
169
+ },
170
+ ],
171
+ default: "documentExtraction",
172
+ },
173
+ ...documentExtraction_js_1.documentExtractionProperties,
174
+ ...documentToMarkdown_js_1.documentToMarkdownProperties,
175
+ ...imageTransformation_js_1.imageTransformationProperties,
176
+ ...imageGeneration_js_1.imageGenerationProperties,
177
+ ...documentGeneration_js_1.documentGenerationProperties,
178
+ ...sheetGeneration_js_1.sheetGenerationProperties,
179
+ ],
180
+ };
181
+ async execute() {
182
+ const items = this.getInputData();
183
+ const returnData = [];
184
+ const resource = this.getNodeParameter("resource", 0);
185
+ const credentials = (await this.getCredentials("iterationLayerApi"));
186
+ const baseUrl = credentials.baseUrl || "https://api.iterationlayer.com";
187
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
188
+ try {
189
+ const isAsync = this.getNodeParameter("isAsync", itemIndex, false);
190
+ const maybeWebhookUrl = isAsync
191
+ ? this.getNodeParameter("webhookUrl", itemIndex)
192
+ : undefined;
193
+ if (resource === "documentExtraction") {
194
+ const result = await executeDocumentExtraction(this, itemIndex, baseUrl, maybeWebhookUrl);
195
+ returnData.push(result);
196
+ }
197
+ else if (resource === "imageTransformation") {
198
+ const result = await executeImageTransformation(this, itemIndex, baseUrl, maybeWebhookUrl);
199
+ returnData.push(result);
200
+ }
201
+ else if (resource === "imageGeneration") {
202
+ const result = await executeImageGeneration(this, itemIndex, baseUrl, maybeWebhookUrl);
203
+ returnData.push(result);
204
+ }
205
+ else if (resource === "documentGeneration") {
206
+ const result = await executeDocumentGeneration(this, itemIndex, baseUrl, maybeWebhookUrl);
207
+ returnData.push(result);
208
+ }
209
+ else if (resource === "documentToMarkdown") {
210
+ const result = await executeDocumentToMarkdown(this, itemIndex, baseUrl);
211
+ returnData.push(result);
212
+ }
213
+ else if (resource === "sheetGeneration") {
214
+ const result = await executeSheetGeneration(this, itemIndex, baseUrl, maybeWebhookUrl);
215
+ returnData.push(result);
216
+ }
217
+ }
218
+ catch (error) {
219
+ if (this.continueOnFail()) {
220
+ returnData.push({
221
+ json: { error: error.message },
222
+ pairedItem: { item: itemIndex },
223
+ });
224
+ continue;
225
+ }
226
+ throw error;
227
+ }
228
+ }
229
+ return [returnData];
230
+ }
231
+ }
232
+ exports.IterationLayer = IterationLayer;
233
+ async function makeApiRequest(executeFunctions, method, endpoint, baseUrl, body) {
234
+ return (await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, "iterationLayerApi", {
235
+ method: method,
236
+ url: `${baseUrl}${endpoint}`,
237
+ body: body,
238
+ json: true,
239
+ }));
240
+ }
241
+ function handleApiResponse(executeFunctions, response, itemIndex) {
242
+ if (!response.success) {
243
+ throw new n8n_workflow_1.NodeOperationError(executeFunctions.getNode(), `API error: ${response.error}`, {
244
+ itemIndex,
245
+ });
246
+ }
247
+ }
248
+ async function executeDocumentExtraction(executeFunctions, itemIndex, baseUrl, maybeWebhookUrl) {
249
+ const files = await (0, fileInput_js_1.getMultipleFileInputs)(executeFunctions, itemIndex);
250
+ const schemaInputMode = executeFunctions.getNodeParameter("schemaInputMode", itemIndex);
251
+ let schema;
252
+ if (schemaInputMode === "rawJson") {
253
+ const schemaJson = executeFunctions.getNodeParameter("schemaJson", itemIndex);
254
+ schema = (typeof schemaJson === "string" ? JSON.parse(schemaJson) : schemaJson);
255
+ }
256
+ else {
257
+ const schemaFieldsCollection = executeFunctions.getNodeParameter("schemaFields", itemIndex, {});
258
+ const fields = (schemaFieldsCollection.fieldValues ?? []).map((field) => ({
259
+ name: field.name,
260
+ description: field.description,
261
+ type: field.type,
262
+ is_required: field.isRequired,
263
+ }));
264
+ schema = { fields };
265
+ }
266
+ const requestBody = { files, schema };
267
+ if (maybeWebhookUrl) {
268
+ requestBody.webhook_url = maybeWebhookUrl;
269
+ }
270
+ const response = await makeApiRequest(executeFunctions, "POST", "/document-extraction/v1/extract", baseUrl, requestBody);
271
+ handleApiResponse(executeFunctions, response, itemIndex);
272
+ if ("async" in response && response.async) {
273
+ return {
274
+ json: { async: true, message: response.message },
275
+ pairedItem: { item: itemIndex },
276
+ };
277
+ }
278
+ return {
279
+ json: response.data,
280
+ pairedItem: { item: itemIndex },
281
+ };
282
+ }
283
+ async function executeImageTransformation(executeFunctions, itemIndex, baseUrl, maybeWebhookUrl) {
284
+ const file = await (0, fileInput_js_1.getFileInput)(executeFunctions, itemIndex);
285
+ const operationsCollection = executeFunctions.getNodeParameter("operations", itemIndex, {});
286
+ const operations = (operationsCollection.operationValues ?? []).map((entry) => buildTransformOperation(entry));
287
+ const requestBody = { file, operations };
288
+ if (maybeWebhookUrl) {
289
+ requestBody.webhook_url = maybeWebhookUrl;
290
+ }
291
+ const response = await makeApiRequest(executeFunctions, "POST", "/image-transformation/v1/transform", baseUrl, requestBody);
292
+ handleApiResponse(executeFunctions, response, itemIndex);
293
+ if ("async" in response && response.async) {
294
+ return {
295
+ json: { async: true, message: response.message },
296
+ pairedItem: { item: itemIndex },
297
+ };
298
+ }
299
+ const responseData = response.data;
300
+ const binary = await (0, binaryData_js_1.toBinaryOutput)(executeFunctions, responseData.buffer, responseData.mime_type, "transformed");
301
+ return {
302
+ json: { mimeType: responseData.mime_type },
303
+ binary,
304
+ pairedItem: { item: itemIndex },
305
+ };
306
+ }
307
+ async function executeImageGeneration(executeFunctions, itemIndex, baseUrl, maybeWebhookUrl) {
308
+ const widthInPx = executeFunctions.getNodeParameter("widthInPx", itemIndex);
309
+ const heightInPx = executeFunctions.getNodeParameter("heightInPx", itemIndex);
310
+ const outputFormat = executeFunctions.getNodeParameter("outputFormat", itemIndex);
311
+ const layersJsonRaw = executeFunctions.getNodeParameter("layersJson", itemIndex);
312
+ const fontsJsonRaw = executeFunctions.getNodeParameter("fontsJson", itemIndex);
313
+ const layers = typeof layersJsonRaw === "string" ? JSON.parse(layersJsonRaw) : layersJsonRaw;
314
+ const fonts = typeof fontsJsonRaw === "string" ? JSON.parse(fontsJsonRaw) : fontsJsonRaw;
315
+ const requestBody = {
316
+ dimensions: { width_in_px: widthInPx, height_in_px: heightInPx },
317
+ layers,
318
+ output_format: outputFormat,
319
+ };
320
+ if (Array.isArray(fonts) && fonts.length > 0) {
321
+ requestBody.fonts = fonts;
322
+ }
323
+ if (maybeWebhookUrl) {
324
+ requestBody.webhook_url = maybeWebhookUrl;
325
+ }
326
+ const response = await makeApiRequest(executeFunctions, "POST", "/image-generation/v1/generate", baseUrl, requestBody);
327
+ handleApiResponse(executeFunctions, response, itemIndex);
328
+ if ("async" in response && response.async) {
329
+ return {
330
+ json: { async: true, message: response.message },
331
+ pairedItem: { item: itemIndex },
332
+ };
333
+ }
334
+ const responseData = response.data;
335
+ const binary = await (0, binaryData_js_1.toBinaryOutput)(executeFunctions, responseData.buffer, responseData.mime_type, "generated");
336
+ return {
337
+ json: { mimeType: responseData.mime_type },
338
+ binary,
339
+ pairedItem: { item: itemIndex },
340
+ };
341
+ }
342
+ async function executeDocumentGeneration(executeFunctions, itemIndex, baseUrl, maybeWebhookUrl) {
343
+ const format = executeFunctions.getNodeParameter("format", itemIndex);
344
+ const documentJsonRaw = executeFunctions.getNodeParameter("documentJson", itemIndex);
345
+ const document = typeof documentJsonRaw === "string" ? JSON.parse(documentJsonRaw) : documentJsonRaw;
346
+ const requestBody = { format, document };
347
+ if (maybeWebhookUrl) {
348
+ requestBody.webhook_url = maybeWebhookUrl;
349
+ }
350
+ const response = await makeApiRequest(executeFunctions, "POST", "/document-generation/v1/generate", baseUrl, requestBody);
351
+ handleApiResponse(executeFunctions, response, itemIndex);
352
+ if ("async" in response && response.async) {
353
+ return {
354
+ json: { async: true, message: response.message },
355
+ pairedItem: { item: itemIndex },
356
+ };
357
+ }
358
+ const responseData = response.data;
359
+ const binary = await (0, binaryData_js_1.toBinaryOutput)(executeFunctions, responseData.buffer, responseData.mime_type, "document");
360
+ return {
361
+ json: { mimeType: responseData.mime_type },
362
+ binary,
363
+ pairedItem: { item: itemIndex },
364
+ };
365
+ }
366
+ async function executeDocumentToMarkdown(executeFunctions, itemIndex, baseUrl) {
367
+ const file = await (0, fileInput_js_1.getFileInput)(executeFunctions, itemIndex);
368
+ const requestBody = { file };
369
+ const response = await makeApiRequest(executeFunctions, "POST", "/document-to-markdown/v1/convert", baseUrl, requestBody);
370
+ handleApiResponse(executeFunctions, response, itemIndex);
371
+ return {
372
+ json: response.data,
373
+ pairedItem: { item: itemIndex },
374
+ };
375
+ }
376
+ async function executeSheetGeneration(executeFunctions, itemIndex, baseUrl, maybeWebhookUrl) {
377
+ const sheetFormat = executeFunctions.getNodeParameter("sheetFormat", itemIndex);
378
+ const sheetsJsonRaw = executeFunctions.getNodeParameter("sheetsJson", itemIndex);
379
+ const stylesJsonRaw = executeFunctions.getNodeParameter("sheetStylesJson", itemIndex);
380
+ const sheets = typeof sheetsJsonRaw === "string" ? JSON.parse(sheetsJsonRaw) : sheetsJsonRaw;
381
+ const styles = typeof stylesJsonRaw === "string" ? JSON.parse(stylesJsonRaw) : stylesJsonRaw;
382
+ const requestBody = {
383
+ format: sheetFormat,
384
+ sheets,
385
+ };
386
+ if (styles && Object.keys(styles).length > 0) {
387
+ requestBody.styles = styles;
388
+ }
389
+ if (maybeWebhookUrl) {
390
+ requestBody.webhook_url = maybeWebhookUrl;
391
+ }
392
+ const response = await makeApiRequest(executeFunctions, "POST", "/sheet-generation/v1/generate", baseUrl, requestBody);
393
+ handleApiResponse(executeFunctions, response, itemIndex);
394
+ if ("async" in response && response.async) {
395
+ return {
396
+ json: { async: true, message: response.message },
397
+ pairedItem: { item: itemIndex },
398
+ };
399
+ }
400
+ const responseData = response.data;
401
+ const binary = await (0, binaryData_js_1.toBinaryOutput)(executeFunctions, responseData.buffer, responseData.mime_type, "spreadsheet");
402
+ return {
403
+ json: { mimeType: responseData.mime_type },
404
+ binary,
405
+ pairedItem: { item: itemIndex },
406
+ };
407
+ }
@@ -0,0 +1,2 @@
1
+ import type { INodeProperties } from "n8n-workflow";
2
+ export declare const documentExtractionProperties: INodeProperties[];