n8n-nodes-ldxhub 0.9.2 → 0.11.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.
Files changed (39) hide show
  1. package/README.md +13 -3
  2. package/dist/nodes/LdxHub/LdxHub.node.d.ts +4 -0
  3. package/dist/nodes/LdxHub/LdxHub.node.js +24 -10
  4. package/dist/nodes/LdxHub/LdxHub.node.js.map +1 -1
  5. package/dist/nodes/LdxHub/methods/loadOptions/getAnalyzeDocModels.d.ts +2 -0
  6. package/dist/nodes/LdxHub/methods/loadOptions/getAnalyzeDocModels.js +18 -0
  7. package/dist/nodes/LdxHub/methods/loadOptions/getAnalyzeDocModels.js.map +1 -0
  8. package/dist/nodes/LdxHub/methods/loadOptions/getAnalyzeDocOutputFormats.d.ts +2 -0
  9. package/dist/nodes/LdxHub/methods/loadOptions/getAnalyzeDocOutputFormats.js +20 -0
  10. package/dist/nodes/LdxHub/methods/loadOptions/getAnalyzeDocOutputFormats.js.map +1 -0
  11. package/dist/nodes/LdxHub/resources/analyzeDoc/index.d.ts +2 -0
  12. package/dist/nodes/LdxHub/resources/analyzeDoc/index.js +29 -0
  13. package/dist/nodes/LdxHub/resources/analyzeDoc/index.js.map +1 -0
  14. package/dist/nodes/LdxHub/resources/analyzeDoc/runJob.d.ts +2 -0
  15. package/dist/nodes/LdxHub/resources/analyzeDoc/runJob.execute.d.ts +2 -0
  16. package/dist/nodes/LdxHub/resources/analyzeDoc/runJob.execute.js +58 -0
  17. package/dist/nodes/LdxHub/resources/analyzeDoc/runJob.execute.js.map +1 -0
  18. package/dist/nodes/LdxHub/resources/analyzeDoc/runJob.js +89 -0
  19. package/dist/nodes/LdxHub/resources/analyzeDoc/runJob.js.map +1 -0
  20. package/dist/nodes/LdxHub/resources/castDoc/runJob.execute.js +16 -46
  21. package/dist/nodes/LdxHub/resources/castDoc/runJob.execute.js.map +1 -1
  22. package/dist/nodes/LdxHub/resources/extractDoc/runJob.execute.js +17 -47
  23. package/dist/nodes/LdxHub/resources/extractDoc/runJob.execute.js.map +1 -1
  24. package/dist/nodes/LdxHub/resources/refineLoop/runJob.execute.js +23 -46
  25. package/dist/nodes/LdxHub/resources/refineLoop/runJob.execute.js.map +1 -1
  26. package/dist/nodes/LdxHub/resources/renderOcr/runJob.execute.js +16 -46
  27. package/dist/nodes/LdxHub/resources/renderOcr/runJob.execute.js.map +1 -1
  28. package/dist/nodes/LdxHub/resources/structFlow/runJob.execute.js +36 -81
  29. package/dist/nodes/LdxHub/resources/structFlow/runJob.execute.js.map +1 -1
  30. package/dist/nodes/LdxHub/shared/files.js +2 -2
  31. package/dist/nodes/LdxHub/shared/files.js.map +1 -1
  32. package/dist/nodes/LdxHub/shared/job.d.ts +24 -0
  33. package/dist/nodes/LdxHub/shared/job.js +90 -0
  34. package/dist/nodes/LdxHub/shared/job.js.map +1 -0
  35. package/dist/nodes/LdxHub/shared/transport.d.ts +3 -1
  36. package/dist/nodes/LdxHub/shared/transport.js +22 -4
  37. package/dist/nodes/LdxHub/shared/transport.js.map +1 -1
  38. package/dist/package.json +8 -2
  39. package/package.json +8 -2
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  > ✅ **One key for everything** — OpenAI, Anthropic, Google, AWS, Azure, xAI
10
10
  > ✅ **30-second sign-up** — GitHub, Google, or email; your API key is shown immediately
11
11
 
12
- n8n community node for **LDX hub** — AI-powered document processing platform: structured data extraction (StructFlow), XLIFF translation refinement (RefineLoop), layout-preserving OCR (RenderOCR), text-based PDF conversion (CastDoc), and plain-text/JSONL extraction (ExtractDoc).
12
+ n8n community node for **LDX hub** — AI-powered document processing platform: structured data extraction (StructFlow), vision document analysis (AnalyzeDoc), XLIFF translation refinement (RefineLoop), layout-preserving OCR (RenderOCR), text-based PDF conversion (CastDoc), and plain-text/JSONL extraction (ExtractDoc).
13
13
 
14
14
  ## Table of Contents
15
15
 
@@ -20,6 +20,7 @@ n8n community node for **LDX hub** — AI-powered document processing platform:
20
20
  - [Credentials Setup](#credentials-setup)
21
21
  - [Usage](#usage)
22
22
  - [StructFlow](#structflow--extract-structured-data-from-text)
23
+ - [AnalyzeDoc](#analyzedoc--extract-structured-json-from-documents-vision-ai)
23
24
  - [RefineLoop](#refineloop--xliff-translation-refinement)
24
25
  - [RenderOCR](#renderocr--pdfimage-to-office)
25
26
  - [CastDoc](#castdoc--text-based-pdf-to-office-no-ocr)
@@ -43,13 +44,14 @@ After [installation](#installation):
43
44
  4. Select this credential in each LDXhub node
44
45
  5. Run the workflow — enter your API key (and optionally a custom host) in the form
45
46
 
46
- All 5 services (StructFlow / RefineLoop / RenderOCR / CastDoc / ExtractDoc) accessible from a single Form Trigger. **The API key is consumed per execution, never stored in n8n.**
47
+ All 6 services (StructFlow / AnalyzeDoc / RefineLoop / RenderOCR / CastDoc / ExtractDoc) accessible from a single Form Trigger. **The API key is consumed per execution, never stored in n8n.**
47
48
 
48
49
  For traditional single-service usage with a static credential, see [Usage](#usage) below.
49
50
 
50
51
  ## Features
51
52
 
52
53
  - **StructFlow**: Extract structured JSON from unstructured text using AI models (medical records, customer feedback, legal documents, and more)
54
+ - **AnalyzeDoc**: Extract structured JSON from PDF/JPEG/PNG documents using vision AI models, following your prompt and example output (the image counterpart to StructFlow)
53
55
  - **RefineLoop**: Iteratively improve XLIFF translation quality using frontier AI models (Google Gemini, Anthropic Claude, OpenAI GPT, and more)
54
56
  - **RenderOCR**: Convert PDFs and images to Word/Excel/PowerPoint with layout-preserving OCR (via industry-leading OCR engines)
55
57
  - **CastDoc**: Convert text-based PDFs to Word/Excel/PowerPoint without OCR (high-fidelity layout preservation for digital-born documents)
@@ -103,7 +105,7 @@ The Model and Engine dropdowns load from LDX hub's public metadata endpoints wit
103
105
 
104
106
  ## Usage
105
107
 
106
- > 💡 **Examples**: All ready-to-use workflows are in [`examples/`](examples/). Each individual demo requires a **LDXhub API** credential and a placeholder input file path to be updated.
108
+ > 💡 **Examples**: All ready-to-use workflows are in [`examples/`](examples/). Each individual demo requires a **LDXhub API** credential and a placeholder input file path to be updated. Ready-to-use form-to-Google-Sheets templates (invoice, business card, accordion pipeline) are listed in [`examples/README.md`](examples/README.md#ready-to-use-templates) and on the [n8n.io template gallery](https://n8n.io/creators/hidekimori/).
107
109
 
108
110
  1. Add **LDXhub API** credentials (see [Credentials Setup](#credentials-setup))
109
111
  2. Add the **LDXhub** node to your workflow
@@ -119,6 +121,14 @@ The Model and Engine dropdowns load from LDX hub's public metadata endpoints wit
119
121
 
120
122
  **Examples**: [Inline mode](examples/structflow-inline-demo.json) · [Binary mode](examples/structflow-binary-demo.json) · [Dynamic API key](examples/structflow-dynamic-inline-demo.json)
121
123
 
124
+ ### AnalyzeDoc — extract structured JSON from documents (vision AI)
125
+
126
+ 1. Resource: **AnalyzeDoc** → Operation: **Run Analysis Job**
127
+ 2. Provide a PDF, JPEG, or PNG file via binary input
128
+ 3. Choose a vision model, write a System Prompt, provide an Example Output (JSON), and pick the output format
129
+
130
+ **Example**: [AnalyzeDoc workflow](examples/analyzedoc-demo.json)
131
+
122
132
  ### RefineLoop — XLIFF translation refinement
123
133
 
124
134
  1. Resource: **RefineLoop** → Operation: **Run Refinement Job**
@@ -1,4 +1,6 @@
1
1
  import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ import { getAnalyzeDocModels } from './methods/loadOptions/getAnalyzeDocModels';
3
+ import { getAnalyzeDocOutputFormats } from './methods/loadOptions/getAnalyzeDocOutputFormats';
2
4
  import { getCastDocEngines } from './methods/loadOptions/getCastDocEngines';
3
5
  import { getCastDocOutputFormats } from './methods/loadOptions/getCastDocOutputFormats';
4
6
  import { getExtractDocEngines } from './methods/loadOptions/getExtractDocEngines';
@@ -12,6 +14,8 @@ export declare class LdxHub implements INodeType {
12
14
  description: INodeTypeDescription;
13
15
  methods: {
14
16
  loadOptions: {
17
+ getAnalyzeDocModels: typeof getAnalyzeDocModels;
18
+ getAnalyzeDocOutputFormats: typeof getAnalyzeDocOutputFormats;
15
19
  getCastDocEngines: typeof getCastDocEngines;
16
20
  getCastDocOutputFormats: typeof getCastDocOutputFormats;
17
21
  getExtractDocEngines: typeof getExtractDocEngines;
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LdxHub = void 0;
4
4
  const n8n_workflow_1 = require("n8n-workflow");
5
+ const getAnalyzeDocModels_1 = require("./methods/loadOptions/getAnalyzeDocModels");
6
+ const getAnalyzeDocOutputFormats_1 = require("./methods/loadOptions/getAnalyzeDocOutputFormats");
5
7
  const getCastDocEngines_1 = require("./methods/loadOptions/getCastDocEngines");
6
8
  const getCastDocOutputFormats_1 = require("./methods/loadOptions/getCastDocOutputFormats");
7
9
  const getExtractDocEngines_1 = require("./methods/loadOptions/getExtractDocEngines");
@@ -11,16 +13,18 @@ const getRenderOcrEngines_1 = require("./methods/loadOptions/getRenderOcrEngines
11
13
  const getRenderOcrLanguages_1 = require("./methods/loadOptions/getRenderOcrLanguages");
12
14
  const getRenderOcrOutputFormats_1 = require("./methods/loadOptions/getRenderOcrOutputFormats");
13
15
  const getStructFlowModels_1 = require("./methods/loadOptions/getStructFlowModels");
16
+ const analyzeDoc_1 = require("./resources/analyzeDoc");
17
+ const runJob_execute_1 = require("./resources/analyzeDoc/runJob.execute");
14
18
  const castDoc_1 = require("./resources/castDoc");
15
- const runJob_execute_1 = require("./resources/castDoc/runJob.execute");
19
+ const runJob_execute_2 = require("./resources/castDoc/runJob.execute");
16
20
  const extractDoc_1 = require("./resources/extractDoc");
17
- const runJob_execute_2 = require("./resources/extractDoc/runJob.execute");
21
+ const runJob_execute_3 = require("./resources/extractDoc/runJob.execute");
18
22
  const refineLoop_1 = require("./resources/refineLoop");
19
- const runJob_execute_3 = require("./resources/refineLoop/runJob.execute");
23
+ const runJob_execute_4 = require("./resources/refineLoop/runJob.execute");
20
24
  const renderOcr_1 = require("./resources/renderOcr");
21
- const runJob_execute_4 = require("./resources/renderOcr/runJob.execute");
25
+ const runJob_execute_5 = require("./resources/renderOcr/runJob.execute");
22
26
  const structFlow_1 = require("./resources/structFlow");
23
- const runJob_execute_5 = require("./resources/structFlow/runJob.execute");
27
+ const runJob_execute_6 = require("./resources/structFlow/runJob.execute");
24
28
  class LdxHub {
25
29
  constructor() {
26
30
  this.description = {
@@ -50,6 +54,10 @@ class LdxHub {
50
54
  type: 'options',
51
55
  noDataExpression: true,
52
56
  options: [
57
+ {
58
+ name: 'AnalyzeDoc',
59
+ value: 'analyzeDoc',
60
+ },
53
61
  {
54
62
  name: 'CastDoc',
55
63
  value: 'castDoc',
@@ -73,6 +81,7 @@ class LdxHub {
73
81
  ],
74
82
  default: 'refineLoop',
75
83
  },
84
+ ...analyzeDoc_1.analyzeDocDescription,
76
85
  ...castDoc_1.castDocDescription,
77
86
  ...extractDoc_1.extractDocDescription,
78
87
  ...refineLoop_1.refineLoopDescription,
@@ -82,6 +91,8 @@ class LdxHub {
82
91
  };
83
92
  this.methods = {
84
93
  loadOptions: {
94
+ getAnalyzeDocModels: getAnalyzeDocModels_1.getAnalyzeDocModels,
95
+ getAnalyzeDocOutputFormats: getAnalyzeDocOutputFormats_1.getAnalyzeDocOutputFormats,
85
96
  getCastDocEngines: getCastDocEngines_1.getCastDocEngines,
86
97
  getCastDocOutputFormats: getCastDocOutputFormats_1.getCastDocOutputFormats,
87
98
  getExtractDocEngines: getExtractDocEngines_1.getExtractDocEngines,
@@ -98,21 +109,24 @@ class LdxHub {
98
109
  const items = this.getInputData();
99
110
  const resource = this.getNodeParameter('resource', 0);
100
111
  const operation = this.getNodeParameter('operation', 0);
101
- if (resource === 'castDoc' && operation === 'runJob') {
112
+ if (resource === 'analyzeDoc' && operation === 'runJob') {
102
113
  return runJob_execute_1.runJobExecute.call(this, items);
103
114
  }
104
- if (resource === 'extractDoc' && operation === 'runJob') {
115
+ if (resource === 'castDoc' && operation === 'runJob') {
105
116
  return runJob_execute_2.runJobExecute.call(this, items);
106
117
  }
107
- if (resource === 'refineLoop' && operation === 'runJob') {
118
+ if (resource === 'extractDoc' && operation === 'runJob') {
108
119
  return runJob_execute_3.runJobExecute.call(this, items);
109
120
  }
110
- if (resource === 'renderOcr' && operation === 'runJob') {
121
+ if (resource === 'refineLoop' && operation === 'runJob') {
111
122
  return runJob_execute_4.runJobExecute.call(this, items);
112
123
  }
113
- if (resource === 'structFlow' && operation === 'runJob') {
124
+ if (resource === 'renderOcr' && operation === 'runJob') {
114
125
  return runJob_execute_5.runJobExecute.call(this, items);
115
126
  }
127
+ if (resource === 'structFlow' && operation === 'runJob') {
128
+ return runJob_execute_6.runJobExecute.call(this, items);
129
+ }
116
130
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${resource}.${operation}" is not supported`);
117
131
  }
118
132
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LdxHub.node.js","sourceRoot":"","sources":["../../../nodes/LdxHub/LdxHub.node.ts"],"names":[],"mappings":";;;AAMA,+CAAuE;AAEvE,+EAA4E;AAC5E,2FAAwF;AACxF,qFAAkF;AAClF,iGAA8F;AAC9F,+DAA4D;AAC5D,mFAAgF;AAChF,uFAAoF;AACpF,+FAA4F;AAC5F,mFAAgF;AAChF,iDAAyD;AACzD,uEAA2F;AAC3F,uDAA+D;AAC/D,0EAAiG;AACjG,uDAA+D;AAC/D,0EAAiG;AACjG,qDAA6D;AAC7D,yEAA+F;AAC/F,uDAA+D;AAC/D,0EAAiG;AAEjG,MAAa,MAAM;IAAnB;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,QAAQ;YACrB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,iBAAiB;YACvB,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,8DAA8D;YAC3E,QAAQ,EAAE;gBACT,IAAI,EAAE,QAAQ;aACd;YACD,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;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AAK,CAAC,CAAC;QAClD,CAAC;QACD,IAAI,QAAQ,KAAK,YAAY,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;YACzD,OAAO,8BAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAClD,CAAC;QACD,IAAI,QAAQ,KAAK,WAAW,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;YACxD,OAAO,8BAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,QAAQ,KAAK,YAAY,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;YACzD,OAAO,8BAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,IAAI,iCAAkB,CAC3B,IAAI,CAAC,OAAO,EAAE,EACd,cAAc,QAAQ,IAAI,SAAS,oBAAoB,CACvD,CAAC;IACH,CAAC;CACD;AA7GD,wBA6GC"}
@@ -0,0 +1,2 @@
1
+ import type { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
2
+ export declare function getAnalyzeDocModels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAnalyzeDocModels = getAnalyzeDocModels;
4
+ const transport_1 = require("../../shared/transport");
5
+ async function getAnalyzeDocModels() {
6
+ var _a;
7
+ const response = (await transport_1.ldxHubApiRequest.call(this, 'GET', '/analyzedoc/models'));
8
+ const models = (_a = response.data) !== null && _a !== void 0 ? _a : [];
9
+ return models.map((m) => {
10
+ var _a;
11
+ return ({
12
+ name: (_a = m.display_name) !== null && _a !== void 0 ? _a : m.id,
13
+ value: m.id,
14
+ description: m.description,
15
+ });
16
+ });
17
+ }
18
+ //# sourceMappingURL=getAnalyzeDocModels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAnalyzeDocModels.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/methods/loadOptions/getAnalyzeDocModels.ts"],"names":[],"mappings":";;AAiBA,kDAgBC;AA/BD,sDAA0D;AAenD,KAAK,UAAU,mBAAmB;;IAGxC,MAAM,QAAQ,GAAG,CAAC,MAAM,4BAAgB,CAAC,IAAI,CAC5C,IAAI,EACJ,KAAK,EACL,oBAAoB,CACpB,CAAmB,CAAC;IAErB,MAAM,MAAM,GAAG,MAAA,QAAQ,CAAC,IAAI,mCAAI,EAAE,CAAC;IAEnC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;;QAAC,OAAA,CAAC;YACzB,IAAI,EAAE,MAAA,CAAC,CAAC,YAAY,mCAAI,CAAC,CAAC,EAAE;YAC5B,KAAK,EAAE,CAAC,CAAC,EAAE;YACX,WAAW,EAAE,CAAC,CAAC,WAAW;SAC1B,CAAC,CAAA;KAAA,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
2
+ export declare function getAnalyzeDocOutputFormats(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAnalyzeDocOutputFormats = getAnalyzeDocOutputFormats;
4
+ const transport_1 = require("../../shared/transport");
5
+ async function getAnalyzeDocOutputFormats() {
6
+ var _a, _b;
7
+ const modelId = this.getCurrentNodeParameter('model');
8
+ if (!modelId) {
9
+ return [];
10
+ }
11
+ const response = (await transport_1.ldxHubApiRequest.call(this, 'GET', '/analyzedoc/models'));
12
+ const model = (_a = response.data) === null || _a === void 0 ? void 0 : _a.find((m) => m.id === modelId);
13
+ const conversions = (_b = model === null || model === void 0 ? void 0 : model.supported_conversions) !== null && _b !== void 0 ? _b : [];
14
+ const formats = Array.from(new Set(conversions.map((c) => c.to))).sort();
15
+ return formats.map((f) => ({
16
+ name: f.toUpperCase(),
17
+ value: f,
18
+ }));
19
+ }
20
+ //# sourceMappingURL=getAnalyzeDocOutputFormats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAnalyzeDocOutputFormats.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/methods/loadOptions/getAnalyzeDocOutputFormats.ts"],"names":[],"mappings":";;AAkBA,gEAuBC;AAvCD,sDAA0D;AAgBnD,KAAK,UAAU,0BAA0B;;IAG/C,MAAM,OAAO,GAAG,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAuB,CAAC;IAC5E,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,MAAM,4BAAgB,CAAC,IAAI,CAC5C,IAAI,EACJ,KAAK,EACL,oBAAoB,CACpB,CAAmB,CAAC;IAErB,MAAM,KAAK,GAAG,MAAA,QAAQ,CAAC,IAAI,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,qBAAqB,mCAAI,EAAE,CAAC;IAEvD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAEzE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE;QACrB,KAAK,EAAE,CAAC;KACR,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { INodeProperties } from 'n8n-workflow';
2
+ export declare const analyzeDocDescription: INodeProperties[];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.analyzeDocDescription = void 0;
4
+ const runJob_1 = require("./runJob");
5
+ const showOnlyForAnalyzeDoc = {
6
+ resource: ['analyzeDoc'],
7
+ };
8
+ exports.analyzeDocDescription = [
9
+ {
10
+ displayName: 'Operation',
11
+ name: 'operation',
12
+ type: 'options',
13
+ noDataExpression: true,
14
+ displayOptions: {
15
+ show: showOnlyForAnalyzeDoc,
16
+ },
17
+ options: [
18
+ {
19
+ name: 'Run Analysis Job',
20
+ value: 'runJob',
21
+ action: 'Run an analysis job',
22
+ description: 'Upload a PDF or image and extract structured JSON with a vision AI model',
23
+ },
24
+ ],
25
+ default: 'runJob',
26
+ },
27
+ ...runJob_1.runJobFields,
28
+ ];
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/resources/analyzeDoc/index.ts"],"names":[],"mappings":";;;AAEA,qCAAwC;AAExC,MAAM,qBAAqB,GAAG;IAC7B,QAAQ,EAAE,CAAC,YAAY,CAAC;CACxB,CAAC;AAEW,QAAA,qBAAqB,GAAsB;IACvD;QACC,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,cAAc,EAAE;YACf,IAAI,EAAE,qBAAqB;SAC3B;QACD,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,QAAQ;gBACf,MAAM,EAAE,qBAAqB;gBAC7B,WAAW,EACV,0EAA0E;aAC3E;SACD;QACD,OAAO,EAAE,QAAQ;KACjB;IACD,GAAG,qBAAY;CACf,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { INodeProperties } from 'n8n-workflow';
2
+ export declare const runJobFields: INodeProperties[];
@@ -0,0 +1,2 @@
1
+ import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
2
+ export declare function runJobExecute(this: IExecuteFunctions, items: INodeExecutionData[]): Promise<INodeExecutionData[][]>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runJobExecute = runJobExecute;
4
+ const job_1 = require("../../shared/job");
5
+ const SERVICE = { basePath: '/analyzedoc', label: 'AnalyzeDoc' };
6
+ const OUTPUT_MIME_TYPES = {
7
+ json: 'application/json',
8
+ };
9
+ const OUTPUT_FILE_EXTENSIONS = {
10
+ json: 'json',
11
+ };
12
+ async function runJobExecute(items) {
13
+ var _a;
14
+ const returnData = [];
15
+ for (let i = 0; i < items.length; i++) {
16
+ try {
17
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
18
+ const model = this.getNodeParameter('model', i);
19
+ const systemPrompt = this.getNodeParameter('system_prompt', i);
20
+ const exampleOutput = (0, job_1.parseJsonIfString)(this.getNodeParameter('example_output', i));
21
+ const outputFormat = this.getNodeParameter('output_format', i);
22
+ const fileId = await job_1.uploadInputBinary.call(this, i, binaryPropertyName, {
23
+ filename: 'input',
24
+ mimeType: 'application/octet-stream',
25
+ });
26
+ const jobBody = {
27
+ model,
28
+ file_id: fileId,
29
+ system_prompt: systemPrompt,
30
+ example_output: exampleOutput,
31
+ output_format: outputFormat,
32
+ };
33
+ const completed = await job_1.createAndPollJob.call(this, i, SERVICE, jobBody);
34
+ const outputBinary = await job_1.downloadOutputBinary.call(this, i, SERVICE, completed, {
35
+ defaultFilename: `output.${(_a = OUTPUT_FILE_EXTENSIONS[outputFormat]) !== null && _a !== void 0 ? _a : outputFormat}`,
36
+ overrideMimeType: OUTPUT_MIME_TYPES[outputFormat],
37
+ });
38
+ returnData.push({
39
+ json: {
40
+ job_id: completed.jobId,
41
+ model,
42
+ status: completed.job.status,
43
+ output_file_id: completed.job.output_file_id,
44
+ usage: completed.job.usage,
45
+ },
46
+ binary: {
47
+ [binaryPropertyName]: outputBinary,
48
+ },
49
+ pairedItem: { item: i },
50
+ });
51
+ }
52
+ catch (error) {
53
+ job_1.handleItemError.call(this, error, i, items, returnData);
54
+ }
55
+ }
56
+ return [returnData];
57
+ }
58
+ //# sourceMappingURL=runJob.execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runJob.execute.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/resources/analyzeDoc/runJob.execute.ts"],"names":[],"mappings":";;AAoBA,sCAoDC;AAtED,0CAM0B;AAE1B,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;AAEjE,MAAM,iBAAiB,GAA2B;IACjD,IAAI,EAAE,kBAAkB;CACxB,CAAC;AAEF,MAAM,sBAAsB,GAA2B;IACtD,IAAI,EAAE,MAAM;CACZ,CAAC;AAEK,KAAK,UAAU,aAAa,CAElC,KAA2B;;IAE3B,MAAM,UAAU,GAAyB,EAAE,CAAC;IAE5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,IAAI,CAAC;YACJ,MAAM,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,CAAC,CAAW,CAAC;YACpF,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAW,CAAC;YAC1D,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,eAAe,EAAE,CAAC,CAAW,CAAC;YACzE,MAAM,aAAa,GAAG,IAAA,uBAAiB,EAAC,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAAC;YACpF,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,eAAe,EAAE,CAAC,CAAW,CAAC;YAEzE,MAAM,MAAM,GAAG,MAAM,uBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,kBAAkB,EAAE;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ports, "__esModule", { value: true });
3
+ exports.runJobFields = void 0;
4
+ const showOnlyForRunJob = {
5
+ resource: ['analyzeDoc'],
6
+ operation: ['runJob'],
7
+ };
8
+ exports.runJobFields = [
9
+ {
10
+ displayName: 'Input Binary Field',
11
+ name: 'binaryPropertyName',
12
+ type: 'string',
13
+ default: 'data',
14
+ required: true,
15
+ description: 'Name of the binary property from the previous node that contains the PDF or image to analyze',
16
+ displayOptions: { show: showOnlyForRunJob },
17
+ },
18
+ {
19
+ displayName: 'Model Name or ID',
20
+ name: 'model',
21
+ type: 'options',
22
+ typeOptions: {
23
+ loadOptionsMethod: 'getAnalyzeDocModels',
24
+ },
25
+ required: true,
26
+ default: '',
27
+ description: 'Vision AI model for analysis. Click to load available models from LDXhub. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
28
+ displayOptions: { show: showOnlyForRunJob },
29
+ },
30
+ {
31
+ displayName: 'System Prompt',
32
+ name: 'system_prompt',
33
+ type: 'string',
34
+ typeOptions: { rows: 6 },
35
+ required: true,
36
+ default: '',
37
+ description: 'Instruction describing what structured data to extract from the document and how',
38
+ displayOptions: { show: showOnlyForRunJob },
39
+ },
40
+ {
41
+ displayName: 'Example Output',
42
+ name: 'example_output',
43
+ type: 'json',
44
+ required: true,
45
+ default: '{}',
46
+ description: 'A JSON object showing the desired output structure with example values',
47
+ displayOptions: { show: showOnlyForRunJob },
48
+ },
49
+ {
50
+ displayName: 'Output Format Name or ID',
51
+ name: 'output_format',
52
+ type: 'options',
53
+ typeOptions: {
54
+ loadOptionsMethod: 'getAnalyzeDocOutputFormats',
55
+ loadOptionsDependsOn: ['model'],
56
+ },
57
+ required: true,
58
+ default: '',
59
+ description: 'Output file format. Options depend on the selected model. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
60
+ displayOptions: { show: showOnlyForRunJob },
61
+ },
62
+ {
63
+ displayName: 'Polling Settings',
64
+ name: 'pollingSettings',
65
+ type: 'collection',
66
+ placeholder: 'Add Setting',
67
+ default: {},
68
+ displayOptions: { show: showOnlyForRunJob },
69
+ options: [
70
+ {
71
+ displayName: 'Max Polling Attempts',
72
+ name: 'pollingMaxAttempts',
73
+ type: 'number',
74
+ typeOptions: { minValue: 1 },
75
+ default: 180,
76
+ description: 'Maximum number of polling attempts before giving up. With default serverWaitSeconds=10 and pollingMaxAttempts=180, maximum wait is about 30 minutes.',
77
+ },
78
+ {
79
+ displayName: 'Server Wait Seconds',
80
+ name: 'serverWaitSeconds',
81
+ type: 'number',
82
+ typeOptions: { minValue: 1, maxValue: 10 },
83
+ default: 10,
84
+ description: 'Seconds the LDXhub server should wait before responding. Longer values reduce client-side polling frequency.',
85
+ },
86
+ ],
87
+ },
88
+ ];
89
+ //# sourceMappingURL=runJob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runJob.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/resources/analyzeDoc/runJob.ts"],"names":[],"mappings":";;;AAEA,MAAM,iBAAiB,GAAG;IACzB,QAAQ,EAAE,CAAC,YAAY,CAAC;IACxB,SAAS,EAAE,CAAC,QAAQ,CAAC;CACrB,CAAC;AAEW,QAAA,YAAY,GAAsB;IAE9C;QACC,WAAW,EAAE,oBAAoB;QACjC,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE,IAAI;QACd,WAAW,EACV,8FAA8F;QAC/F,cAAc,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;KAC3C;IACD;QACC,WAAW,EAAE,kBAAkB;QAC/B,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,SAAS;QACf,WAAW,EAAE;YACZ,iBAAiB,EAAE,qBAAqB;SACxC;QACD,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EACV,2LAA2L;QAC5L,cAAc,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;KAC3C;IACD;QACC,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E,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBAC1C,OAAO,EAAE,EAAE;gBACX,WAAW,EACV,8GAA8G;aAC/G;SACD;KACD;CACD,CAAC"}
@@ -1,55 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runJobExecute = runJobExecute;
4
- const n8n_workflow_1 = require("n8n-workflow");
5
- const files_1 = require("../../shared/files");
6
- const polling_1 = require("../../shared/polling");
7
- const transport_1 = require("../../shared/transport");
4
+ const job_1 = require("../../shared/job");
5
+ const SERVICE = { basePath: '/castdoc', label: 'CastDoc' };
8
6
  const OUTPUT_MIME_TYPES = {
9
7
  docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
10
8
  xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
11
9
  pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
12
10
  };
13
11
  async function runJobExecute(items) {
14
- var _a, _b, _c, _d, _e, _f;
15
12
  const returnData = [];
16
13
  for (let i = 0; i < items.length; i++) {
17
14
  try {
18
15
  const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
19
16
  const engine = this.getNodeParameter('engine', i);
20
17
  const outputFormat = this.getNodeParameter('output_format', i);
21
- const pollingSettings = this.getNodeParameter('pollingSettings', i, {});
22
- const binaryMeta = this.helpers.assertBinaryData(i, binaryPropertyName);
23
- const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
24
- const filename = (_a = binaryMeta.fileName) !== null && _a !== void 0 ? _a : 'input.pdf';
25
- const mimeType = (_b = binaryMeta.mimeType) !== null && _b !== void 0 ? _b : 'application/octet-stream';
26
- const uploadRes = await files_1.uploadFile.call(this, buffer, filename, mimeType);
18
+ const fileId = await job_1.uploadInputBinary.call(this, i, binaryPropertyName, {
19
+ filename: 'input.pdf',
20
+ mimeType: 'application/octet-stream',
21
+ });
27
22
  const jobBody = {
28
23
  engine,
29
- file_id: uploadRes.file_id,
24
+ file_id: fileId,
30
25
  output_format: outputFormat,
31
26
  };
32
- const jobRes = (await transport_1.ldxHubApiRequest.call(this, 'POST', '/castdoc/jobs', jobBody));
33
- const finalJob = await polling_1.pollJobUntilDone.call(this, {
34
- jobId: jobRes.job_id,
35
- endpoint: `/castdoc/jobs/${encodeURIComponent(jobRes.job_id)}`,
36
- serviceLabel: 'CastDoc',
37
- }, {
38
- serverWaitSeconds: (_c = pollingSettings.serverWaitSeconds) !== null && _c !== void 0 ? _c : 10,
39
- pollingMaxAttempts: (_d = pollingSettings.pollingMaxAttempts) !== null && _d !== void 0 ? _d : 180,
40
- }, i);
41
- if (!finalJob.output_file_id) {
42
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `CastDoc job ${jobRes.job_id} completed but returned no output_file_id`, { itemIndex: i });
43
- }
44
- const download = await files_1.downloadFile.call(this, finalJob.output_file_id);
45
- const overrideMime = (_e = OUTPUT_MIME_TYPES[outputFormat]) !== null && _e !== void 0 ? _e : download.mimeType;
46
- const defaultFilename = `output.${outputFormat}`;
47
- const outputBinary = await this.helpers.prepareBinaryData(download.buffer, (_f = download.filename) !== null && _f !== void 0 ? _f : defaultFilename, overrideMime);
27
+ const completed = await job_1.createAndPollJob.call(this, i, SERVICE, jobBody);
28
+ const outputBinary = await job_1.downloadOutputBinary.call(this, i, SERVICE, completed, {
29
+ defaultFilename: `output.${outputFormat}`,
30
+ overrideMimeType: OUTPUT_MIME_TYPES[outputFormat],
31
+ });
48
32
  returnData.push({
49
33
  json: {
50
- job_id: jobRes.job_id,
51
- status: finalJob.status,
52
- output_file_id: finalJob.output_file_id,
34
+ job_id: completed.jobId,
35
+ status: completed.job.status,
36
+ output_file_id: completed.job.output_file_id,
53
37
  },
54
38
  binary: {
55
39
  [binaryPropertyName]: outputBinary,
@@ -58,21 +42,7 @@ async function runJobExecute(items) {
58
42
  });
59
43
  }
60
44
  catch (error) {
61
- if (this.continueOnFail()) {
62
- const wrapped = error instanceof n8n_workflow_1.NodeOperationError
63
- ? error
64
- : new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
65
- returnData.push({
66
- json: items[i].json,
67
- error: wrapped,
68
- pairedItem: { item: i },
69
- });
70
- continue;
71
- }
72
- const ctx = error.context;
73
- if (ctx)
74
- ctx.itemIndex = i;
75
- throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
45
+ job_1.handleItemError.call(this, error, i, items, returnData);
76
46
  }
77
47
  }
78
48
  return [returnData];
@@ -1 +1 @@
1
- {"version":3,"file":"runJob.execute.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/resources/castDoc/runJob.execute.ts"],"names":[],"mappings":";;AA4BA,sCAmGC;AAzHD,+CAAgE;AAEhE,8CAA8D;AAC9D,kDAAwD;AACxD,sDAA0D;AAY1D,MAAM,iBAAiB,GAA2B;IACjD,IAAI,EAAE,yEAAyE;IAC/E,IAAI,EAAE,mEAAmE;IACzE,IAAI,EAAE,2EAA2E;CACjF,CAAC;AAEK,KAAK,UAAU,aAAa,CAElC,KAA2B;;IAE3B,MAAM,UAAU,GAAyB,EAAE,CAAC;IAE5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,IAAI,CAAC;YACJ,MAAM,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,CAAC,CAAW,CAAC;YACpF,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAW,CAAC;YAC5D,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,eAAe,EAAE,CAAC,CAAW,CAAC;YACzE,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAC5C,iBAAiB,EACjB,CAAC,EACD,EAAE,CACiB,CAAC;YAErB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CA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