n8n-nodes-ldxhub 0.2.0 → 0.3.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.
- package/README.md +15 -3
- package/dist/credentials/LdxHubApi.credentials.js +8 -8
- package/dist/credentials/LdxHubApi.credentials.js.map +1 -1
- package/dist/nodes/LdxHub/LdxHub.node.d.ts +6 -0
- package/dist/nodes/LdxHub/LdxHub.node.js +16 -0
- package/dist/nodes/LdxHub/LdxHub.node.js.map +1 -1
- package/dist/nodes/LdxHub/methods/loadOptions/getRenderOcrEngines.d.ts +2 -0
- package/dist/nodes/LdxHub/methods/loadOptions/getRenderOcrEngines.js +18 -0
- package/dist/nodes/LdxHub/methods/loadOptions/getRenderOcrEngines.js.map +1 -0
- package/dist/nodes/LdxHub/methods/loadOptions/getRenderOcrLanguages.d.ts +2 -0
- package/dist/nodes/LdxHub/methods/loadOptions/getRenderOcrLanguages.js +22 -0
- package/dist/nodes/LdxHub/methods/loadOptions/getRenderOcrLanguages.js.map +1 -0
- package/dist/nodes/LdxHub/methods/loadOptions/getRenderOcrOutputFormats.d.ts +2 -0
- package/dist/nodes/LdxHub/methods/loadOptions/getRenderOcrOutputFormats.js +20 -0
- package/dist/nodes/LdxHub/methods/loadOptions/getRenderOcrOutputFormats.js.map +1 -0
- package/dist/nodes/LdxHub/resources/refineLoop/runJob.execute.js +5 -1
- package/dist/nodes/LdxHub/resources/refineLoop/runJob.execute.js.map +1 -1
- package/dist/nodes/LdxHub/resources/renderOcr/index.d.ts +2 -0
- package/dist/nodes/LdxHub/resources/renderOcr/index.js +29 -0
- package/dist/nodes/LdxHub/resources/renderOcr/index.js.map +1 -0
- package/dist/nodes/LdxHub/resources/renderOcr/runJob.d.ts +2 -0
- package/dist/nodes/LdxHub/resources/renderOcr/runJob.execute.d.ts +2 -0
- package/dist/nodes/LdxHub/resources/renderOcr/runJob.execute.js +82 -0
- package/dist/nodes/LdxHub/resources/renderOcr/runJob.execute.js.map +1 -0
- package/dist/nodes/LdxHub/resources/renderOcr/runJob.js +83 -0
- package/dist/nodes/LdxHub/resources/renderOcr/runJob.js.map +1 -0
- package/dist/nodes/LdxHub/shared/polling.d.ts +6 -1
- package/dist/nodes/LdxHub/shared/polling.js +6 -5
- package/dist/nodes/LdxHub/shared/polling.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/n8n-nodes-ldxhub)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
n8n community node for **LDX hub** — AI-powered XLIFF translation refinement
|
|
6
|
+
n8n community node for **LDX hub** — AI-powered document processing (XLIFF translation refinement, PDF/image OCR to Office formats).
|
|
7
7
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
10
10
|
- **RefineLoop**: Iteratively improve XLIFF translation quality using frontier AI models (Google Gemini, Anthropic Claude, OpenAI GPT, and more)
|
|
11
|
+
- **RenderOCR**: Convert PDFs and images to Word/Excel/PowerPoint with layout-preserving OCR (via industry-leading OCR engines)
|
|
11
12
|
- HTTP long-polling architecture — compatible with n8n Cloud execution model
|
|
12
13
|
- Proven at scale: tested with 1.19M-character academic papers
|
|
13
14
|
|
|
@@ -29,8 +30,19 @@ In your n8n instance:
|
|
|
29
30
|
|
|
30
31
|
1. Add **LDXhub API** credentials (API key from your LDX hub dashboard)
|
|
31
32
|
2. Add the **LDXhub** node to your workflow
|
|
32
|
-
3. Select
|
|
33
|
-
|
|
33
|
+
3. Select a resource and operation (see below)
|
|
34
|
+
|
|
35
|
+
### RefineLoop — XLIFF translation refinement
|
|
36
|
+
|
|
37
|
+
1. Resource: **RefineLoop** → Operation: **Run Refinement Job**
|
|
38
|
+
2. Provide an XLIFF file via binary input
|
|
39
|
+
3. Choose an AI model and set max revisions
|
|
40
|
+
|
|
41
|
+
### RenderOCR — PDF/image to Office
|
|
42
|
+
|
|
43
|
+
1. Resource: **RenderOCR** → Operation: **Run Conversion Job**
|
|
44
|
+
2. Provide a PDF or image file via binary input
|
|
45
|
+
3. Choose an OCR engine, target language, and output format (docx/xlsx/pptx)
|
|
34
46
|
|
|
35
47
|
Documentation: https://gw.portal.ldxhub.io/introduction
|
|
36
48
|
|
|
@@ -8,6 +8,14 @@ class LdxHubApi {
|
|
|
8
8
|
this.icon = 'file:ldxhub.svg';
|
|
9
9
|
this.documentationUrl = 'https://gw.portal.ldxhub.io/introduction';
|
|
10
10
|
this.properties = [
|
|
11
|
+
{
|
|
12
|
+
displayName: 'Base URL',
|
|
13
|
+
name: 'baseUrl',
|
|
14
|
+
type: 'string',
|
|
15
|
+
default: 'https://gw.ldxhub.io',
|
|
16
|
+
placeholder: 'https://gw.ldxhub.io',
|
|
17
|
+
description: 'LDX hub API base URL. Use the production URL for normal use. For development/testing, use the dev environment URL. Trailing slashes are trimmed automatically.',
|
|
18
|
+
},
|
|
11
19
|
{
|
|
12
20
|
displayName: 'API Key',
|
|
13
21
|
name: 'apiKey',
|
|
@@ -17,14 +25,6 @@ class LdxHubApi {
|
|
|
17
25
|
required: true,
|
|
18
26
|
description: 'Issued from the LDXhub console',
|
|
19
27
|
},
|
|
20
|
-
{
|
|
21
|
-
displayName: 'Base URL',
|
|
22
|
-
name: 'baseUrl',
|
|
23
|
-
type: 'string',
|
|
24
|
-
default: 'https://gw.ldxhub.io',
|
|
25
|
-
placeholder: 'https://gw.ldxhub.io',
|
|
26
|
-
description: 'LDX hub API base URL. Use the production URL for normal use. For development/testing, use the dev environment URL. Trailing slashes are trimmed automatically.',
|
|
27
|
-
},
|
|
28
28
|
];
|
|
29
29
|
this.authenticate = {
|
|
30
30
|
type: 'generic',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LdxHubApi.credentials.js","sourceRoot":"","sources":["../../credentials/LdxHubApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,SAAS;IAAtB;QACC,SAAI,GAAG,WAAW,CAAC;QAEnB,gBAAW,GAAG,YAAY,CAAC;QAE3B,SAAI,GAAS,iBAAiB,CAAC;QAE/B,qBAAgB,GAAG,0CAA0C,CAAC;QAE9D,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"LdxHubApi.credentials.js","sourceRoot":"","sources":["../../credentials/LdxHubApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,SAAS;IAAtB;QACC,SAAI,GAAG,WAAW,CAAC;QAEnB,gBAAW,GAAG,YAAY,CAAC;QAE3B,SAAI,GAAS,iBAAiB,CAAC;QAE/B,qBAAgB,GAAG,0CAA0C,CAAC;QAE9D,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,sBAAsB;gBAC/B,WAAW,EAAE,sBAAsB;gBACnC,WAAW,EACV,gKAAgK;aACjK;YACD;gBACC,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,gCAAgC;aAC7C;SACD,CAAC;QAEF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,aAAa,EAAE,kCAAkC;iBACjD;aACD;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,2BAA2B;gBACpC,GAAG,EAAE,oBAAoB;gBACzB,MAAM,EAAE,KAAK;aACb;SACD,CAAC;IACH,CAAC;CAAA;AA9CD,8BA8CC"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
2
|
import { getModels } from './methods/loadOptions/getModels';
|
|
3
|
+
import { getRenderOcrEngines } from './methods/loadOptions/getRenderOcrEngines';
|
|
4
|
+
import { getRenderOcrLanguages } from './methods/loadOptions/getRenderOcrLanguages';
|
|
5
|
+
import { getRenderOcrOutputFormats } from './methods/loadOptions/getRenderOcrOutputFormats';
|
|
3
6
|
export declare class LdxHub implements INodeType {
|
|
4
7
|
description: INodeTypeDescription;
|
|
5
8
|
methods: {
|
|
6
9
|
loadOptions: {
|
|
7
10
|
getModels: typeof getModels;
|
|
11
|
+
getRenderOcrEngines: typeof getRenderOcrEngines;
|
|
12
|
+
getRenderOcrLanguages: typeof getRenderOcrLanguages;
|
|
13
|
+
getRenderOcrOutputFormats: typeof getRenderOcrOutputFormats;
|
|
8
14
|
};
|
|
9
15
|
};
|
|
10
16
|
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
@@ -3,8 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LdxHub = void 0;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
5
|
const getModels_1 = require("./methods/loadOptions/getModels");
|
|
6
|
+
const getRenderOcrEngines_1 = require("./methods/loadOptions/getRenderOcrEngines");
|
|
7
|
+
const getRenderOcrLanguages_1 = require("./methods/loadOptions/getRenderOcrLanguages");
|
|
8
|
+
const getRenderOcrOutputFormats_1 = require("./methods/loadOptions/getRenderOcrOutputFormats");
|
|
6
9
|
const refineLoop_1 = require("./resources/refineLoop");
|
|
7
10
|
const runJob_execute_1 = require("./resources/refineLoop/runJob.execute");
|
|
11
|
+
const renderOcr_1 = require("./resources/renderOcr");
|
|
12
|
+
const runJob_execute_2 = require("./resources/renderOcr/runJob.execute");
|
|
8
13
|
class LdxHub {
|
|
9
14
|
constructor() {
|
|
10
15
|
this.description = {
|
|
@@ -45,15 +50,23 @@ class LdxHub {
|
|
|
45
50
|
name: 'RefineLoop',
|
|
46
51
|
value: 'refineLoop',
|
|
47
52
|
},
|
|
53
|
+
{
|
|
54
|
+
name: 'RenderOCR',
|
|
55
|
+
value: 'renderOcr',
|
|
56
|
+
},
|
|
48
57
|
],
|
|
49
58
|
default: 'refineLoop',
|
|
50
59
|
},
|
|
51
60
|
...refineLoop_1.refineLoopDescription,
|
|
61
|
+
...renderOcr_1.renderOcrDescription,
|
|
52
62
|
],
|
|
53
63
|
};
|
|
54
64
|
this.methods = {
|
|
55
65
|
loadOptions: {
|
|
56
66
|
getModels: getModels_1.getModels,
|
|
67
|
+
getRenderOcrEngines: getRenderOcrEngines_1.getRenderOcrEngines,
|
|
68
|
+
getRenderOcrLanguages: getRenderOcrLanguages_1.getRenderOcrLanguages,
|
|
69
|
+
getRenderOcrOutputFormats: getRenderOcrOutputFormats_1.getRenderOcrOutputFormats,
|
|
57
70
|
},
|
|
58
71
|
};
|
|
59
72
|
}
|
|
@@ -64,6 +77,9 @@ class LdxHub {
|
|
|
64
77
|
if (resource === 'refineLoop' && operation === 'runJob') {
|
|
65
78
|
return runJob_execute_1.runJobExecute.call(this, items);
|
|
66
79
|
}
|
|
80
|
+
if (resource === 'renderOcr' && operation === 'runJob') {
|
|
81
|
+
return runJob_execute_2.runJobExecute.call(this, items);
|
|
82
|
+
}
|
|
67
83
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${resource}.${operation}" is not supported`);
|
|
68
84
|
}
|
|
69
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LdxHub.node.js","sourceRoot":"","sources":["../../../nodes/LdxHub/LdxHub.node.ts"],"names":[],"mappings":";;;AAMA,+CAAuE;AAEvE,+DAA4D;AAC5D,uDAA+D;AAC/D,
|
|
1
|
+
{"version":3,"file":"LdxHub.node.js","sourceRoot":"","sources":["../../../nodes/LdxHub/LdxHub.node.ts"],"names":[],"mappings":";;;AAMA,+CAAuE;AAEvE,+DAA4D;AAC5D,mFAAgF;AAChF,uFAAoF;AACpF,+FAA4F;AAC5F,uDAA+D;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K,CAAC,OAAO;QACZ,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAW,CAAC;QAChE,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAW,CAAC;QAElE,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;QAED,MAAM,IAAI,iCAAkB,CAC3B,IAAI,CAAC,OAAO,EAAE,EACd,cAAc,QAAQ,IAAI,SAAS,oBAAoB,CACvD,CAAC;IACH,CAAC;CACD;AA7ED,wBA6EC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRenderOcrEngines = getRenderOcrEngines;
|
|
4
|
+
const transport_1 = require("../../shared/transport");
|
|
5
|
+
async function getRenderOcrEngines() {
|
|
6
|
+
var _a;
|
|
7
|
+
const response = (await transport_1.ldxHubApiRequest.call(this, 'GET', '/renderocr/engines'));
|
|
8
|
+
const engines = (_a = response.data) !== null && _a !== void 0 ? _a : [];
|
|
9
|
+
return engines.map((e) => {
|
|
10
|
+
var _a;
|
|
11
|
+
return ({
|
|
12
|
+
name: (_a = e.display_name) !== null && _a !== void 0 ? _a : e.id,
|
|
13
|
+
value: e.id,
|
|
14
|
+
description: e.description,
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=getRenderOcrEngines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRenderOcrEngines.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/methods/loadOptions/getRenderOcrEngines.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,CAAoB,CAAC;IAEtB,MAAM,OAAO,GAAG,MAAA,QAAQ,CAAC,IAAI,mCAAI,EAAE,CAAC;IAEpC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;;QAAC,OAAA,CAAC;YAC1B,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,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRenderOcrLanguages = getRenderOcrLanguages;
|
|
4
|
+
const transport_1 = require("../../shared/transport");
|
|
5
|
+
async function getRenderOcrLanguages() {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const engineId = this.getCurrentNodeParameter('engine');
|
|
8
|
+
if (!engineId) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const response = (await transport_1.ldxHubApiRequest.call(this, 'GET', '/renderocr/engines'));
|
|
12
|
+
const engine = (_a = response.data) === null || _a === void 0 ? void 0 : _a.find((e) => e.id === engineId);
|
|
13
|
+
const languages = (_b = engine === null || engine === void 0 ? void 0 : engine.supported_languages) !== null && _b !== void 0 ? _b : [];
|
|
14
|
+
return languages.map((lang) => {
|
|
15
|
+
var _a;
|
|
16
|
+
return ({
|
|
17
|
+
name: (_a = lang.display_name) !== null && _a !== void 0 ? _a : lang.code,
|
|
18
|
+
value: lang.code,
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=getRenderOcrLanguages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRenderOcrLanguages.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/methods/loadOptions/getRenderOcrLanguages.ts"],"names":[],"mappings":";;AAkBA,sDAqBC;AArCD,sDAA0D;AAgBnD,KAAK,UAAU,qBAAqB;;IAG1C,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAuB,CAAC;IAC9E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,MAAM,4BAAgB,CAAC,IAAI,CAC5C,IAAI,EACJ,KAAK,EACL,oBAAoB,CACpB,CAAoB,CAAC;IAEtB,MAAM,MAAM,GAAG,MAAA,QAAQ,CAAC,IAAI,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;IAC7D,MAAM,SAAS,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,mBAAmB,mCAAI,EAAE,CAAC;IAEpD,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;;QAAC,OAAA,CAAC;YAC/B,IAAI,EAAE,MAAA,IAAI,CAAC,YAAY,mCAAI,IAAI,CAAC,IAAI;YACpC,KAAK,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAA;KAAA,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRenderOcrOutputFormats = getRenderOcrOutputFormats;
|
|
4
|
+
const transport_1 = require("../../shared/transport");
|
|
5
|
+
async function getRenderOcrOutputFormats() {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const engineId = this.getCurrentNodeParameter('engine');
|
|
8
|
+
if (!engineId) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const response = (await transport_1.ldxHubApiRequest.call(this, 'GET', '/renderocr/engines'));
|
|
12
|
+
const engine = (_a = response.data) === null || _a === void 0 ? void 0 : _a.find((e) => e.id === engineId);
|
|
13
|
+
const conversions = (_b = engine === null || engine === void 0 ? void 0 : engine.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=getRenderOcrOutputFormats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRenderOcrOutputFormats.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/methods/loadOptions/getRenderOcrOutputFormats.ts"],"names":[],"mappings":";;AAkBA,8DAuBC;AAvCD,sDAA0D;AAgBnD,KAAK,UAAU,yBAAyB;;IAG9C,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAuB,CAAC;IAC9E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,MAAM,4BAAgB,CAAC,IAAI,CAC5C,IAAI,EACJ,KAAK,EACL,oBAAoB,CACpB,CAAoB,CAAC;IAEtB,MAAM,MAAM,GAAG,MAAA,QAAQ,CAAC,IAAI,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,qBAAqB,mCAAI,EAAE,CAAC;IAExD,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"}
|
|
@@ -49,7 +49,11 @@ async function runJobExecute(items) {
|
|
|
49
49
|
options,
|
|
50
50
|
});
|
|
51
51
|
const jobRes = (await transport_1.ldxHubApiRequest.call(this, 'POST', '/refineloop/jobs', jobBody));
|
|
52
|
-
const finalJob = await polling_1.pollJobUntilDone.call(this,
|
|
52
|
+
const finalJob = await polling_1.pollJobUntilDone.call(this, {
|
|
53
|
+
jobId: jobRes.job_id,
|
|
54
|
+
endpoint: `/refineloop/jobs/${encodeURIComponent(jobRes.job_id)}`,
|
|
55
|
+
serviceLabel: 'RefineLoop',
|
|
56
|
+
}, {
|
|
53
57
|
serverWaitSeconds: (_c = pollingSettings.serverWaitSeconds) !== null && _c !== void 0 ? _c : 10,
|
|
54
58
|
pollingMaxAttempts: (_d = pollingSettings.pollingMaxAttempts) !== null && _d !== void 0 ? _d : 180,
|
|
55
59
|
}, i);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runJob.execute.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/resources/refineLoop/runJob.execute.ts"],"names":[],"mappings":";;AAmDA,
|
|
1
|
+
{"version":3,"file":"runJob.execute.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/resources/refineLoop/runJob.execute.ts"],"names":[],"mappings":";;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AAS,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC7E,UAAU,CAAC,IAAI,CAAC;oBACf,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;oBACnB,KAAK,EAAE,OAAO;oBACd,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;iBACvB,CAAC,CAAC;gBACH,SAAS;YACV,CAAC;YACD,MAAM,GAAG,GAAI,KAA8C,CAAC,OAAO,CAAC;YACpE,IAAI,GAAG;gBAAE,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC;YAC3B,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IAED,OAAO,CAAC,UAAU,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderOcrDescription = void 0;
|
|
4
|
+
const runJob_1 = require("./runJob");
|
|
5
|
+
const showOnlyForRenderOcr = {
|
|
6
|
+
resource: ['renderOcr'],
|
|
7
|
+
};
|
|
8
|
+
exports.renderOcrDescription = [
|
|
9
|
+
{
|
|
10
|
+
displayName: 'Operation',
|
|
11
|
+
name: 'operation',
|
|
12
|
+
type: 'options',
|
|
13
|
+
noDataExpression: true,
|
|
14
|
+
displayOptions: {
|
|
15
|
+
show: showOnlyForRenderOcr,
|
|
16
|
+
},
|
|
17
|
+
options: [
|
|
18
|
+
{
|
|
19
|
+
name: 'Run Conversion Job',
|
|
20
|
+
value: 'runJob',
|
|
21
|
+
action: 'Run a conversion job',
|
|
22
|
+
description: 'Upload a PDF or image and convert it to Word/Excel/PowerPoint with OCR',
|
|
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/renderOcr/index.ts"],"names":[],"mappings":";;;AAEA,qCAAwC;AAExC,MAAM,oBAAoB,GAAG;IAC5B,QAAQ,EAAE,CAAC,WAAW,CAAC;CACvB,CAAC;AAEW,QAAA,oBAAoB,GAAsB;IACtD;QACC,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,cAAc,EAAE;YACf,IAAI,EAAE,oBAAoB;SAC1B;QACD,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,oBAAoB;gBAC1B,KAAK,EAAE,QAAQ;gBACf,MAAM,EAAE,sBAAsB;gBAC9B,WAAW,EACV,wEAAwE;aACzE;SACD;QACD,OAAO,EAAE,QAAQ;KACjB;IACD,GAAG,qBAAY;CACf,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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");
|
|
8
|
+
const OUTPUT_MIME_TYPES = {
|
|
9
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
10
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
11
|
+
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
12
|
+
};
|
|
13
|
+
async function runJobExecute(items) {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f;
|
|
15
|
+
const returnData = [];
|
|
16
|
+
for (let i = 0; i < items.length; i++) {
|
|
17
|
+
try {
|
|
18
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
19
|
+
const engine = this.getNodeParameter('engine', i);
|
|
20
|
+
const languages = this.getNodeParameter('languages', i);
|
|
21
|
+
const outputFormat = this.getNodeParameter('output_format', i);
|
|
22
|
+
const pollingSettings = this.getNodeParameter('pollingSettings', i, {});
|
|
23
|
+
const binaryMeta = this.helpers.assertBinaryData(i, binaryPropertyName);
|
|
24
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
25
|
+
const filename = (_a = binaryMeta.fileName) !== null && _a !== void 0 ? _a : 'input.pdf';
|
|
26
|
+
const mimeType = (_b = binaryMeta.mimeType) !== null && _b !== void 0 ? _b : 'application/octet-stream';
|
|
27
|
+
const uploadRes = await files_1.uploadFile.call(this, buffer, filename, mimeType);
|
|
28
|
+
const jobBody = {
|
|
29
|
+
file_id: uploadRes.file_id,
|
|
30
|
+
engine,
|
|
31
|
+
languages,
|
|
32
|
+
output_format: outputFormat,
|
|
33
|
+
};
|
|
34
|
+
const jobRes = (await transport_1.ldxHubApiRequest.call(this, 'POST', '/renderocr/jobs', jobBody));
|
|
35
|
+
const finalJob = await polling_1.pollJobUntilDone.call(this, {
|
|
36
|
+
jobId: jobRes.job_id,
|
|
37
|
+
endpoint: `/renderocr/jobs/${encodeURIComponent(jobRes.job_id)}`,
|
|
38
|
+
serviceLabel: 'RenderOCR',
|
|
39
|
+
}, {
|
|
40
|
+
serverWaitSeconds: (_c = pollingSettings.serverWaitSeconds) !== null && _c !== void 0 ? _c : 10,
|
|
41
|
+
pollingMaxAttempts: (_d = pollingSettings.pollingMaxAttempts) !== null && _d !== void 0 ? _d : 180,
|
|
42
|
+
}, i);
|
|
43
|
+
if (!finalJob.output_file_id) {
|
|
44
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `RenderOCR job ${jobRes.job_id} completed but returned no output_file_id`, { itemIndex: i });
|
|
45
|
+
}
|
|
46
|
+
const download = await files_1.downloadFile.call(this, finalJob.output_file_id);
|
|
47
|
+
const overrideMime = (_e = OUTPUT_MIME_TYPES[outputFormat]) !== null && _e !== void 0 ? _e : download.mimeType;
|
|
48
|
+
const defaultFilename = `output.${outputFormat}`;
|
|
49
|
+
const outputBinary = await this.helpers.prepareBinaryData(download.buffer, (_f = download.filename) !== null && _f !== void 0 ? _f : defaultFilename, overrideMime);
|
|
50
|
+
returnData.push({
|
|
51
|
+
json: {
|
|
52
|
+
job_id: jobRes.job_id,
|
|
53
|
+
status: finalJob.status,
|
|
54
|
+
output_file_id: finalJob.output_file_id,
|
|
55
|
+
},
|
|
56
|
+
binary: {
|
|
57
|
+
[binaryPropertyName]: outputBinary,
|
|
58
|
+
},
|
|
59
|
+
pairedItem: { item: i },
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (this.continueOnFail()) {
|
|
64
|
+
const wrapped = error instanceof n8n_workflow_1.NodeOperationError
|
|
65
|
+
? error
|
|
66
|
+
: new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
67
|
+
returnData.push({
|
|
68
|
+
json: items[i].json,
|
|
69
|
+
error: wrapped,
|
|
70
|
+
pairedItem: { item: i },
|
|
71
|
+
});
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const ctx = error.context;
|
|
75
|
+
if (ctx)
|
|
76
|
+
ctx.itemIndex = i;
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return [returnData];
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=runJob.execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runJob.execute.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/resources/renderOcr/runJob.execute.ts"],"names":[],"mappings":";;AAuBA,sCAqGC;AA3HD,+CAAkD;AAElD,8CAA8D;AAC9D,kDAAwD;AACxD,sDAA0D;AAY1D,MAAM,iBAAiB,GAA2B;IACjD,IAAI,EAAE,yEAAyE;IAC/E,IAAI,EAAE,mEAAmE;IACzE,IAAI,EAAE,2EAA2E;CACj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cAAc;iBACvC;gBACD,MAAM,EAAE;oBACP,CAAC,kBAAkB,CAAC,EAAE,YAAY;iBAClC;gBACD,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;aACvB,CAAC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;gBAC3B,MAAM,OAAO,GACZ,KAAK,YAAY,iCAAkB;oBAClC,CAAC,CAAC,KAAK;oBACP,CAAC,CAAC,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAc,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC7E,UAAU,CAAC,IAAI,CAAC;oBACf,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;oBACnB,KAAK,EAAE,OAAO;oBACd,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;iBACvB,CAAC,CAAC;gBACH,SAAS;YACV,CAAC;YACD,MAAM,GAAG,GAAI,KAA8C,CAAC,OAAO,CAAC;YACpE,IAAI,GAAG;gBAAE,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC;YAC3B,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IAED,OAAO,CAAC,UAAU,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runJobFields = void 0;
|
|
4
|
+
const showOnlyForRunJob = {
|
|
5
|
+
resource: ['renderOcr'],
|
|
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 file to convert',
|
|
16
|
+
displayOptions: { show: showOnlyForRunJob },
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Engine Name or ID',
|
|
20
|
+
name: 'engine',
|
|
21
|
+
type: 'options',
|
|
22
|
+
typeOptions: {
|
|
23
|
+
loadOptionsMethod: 'getRenderOcrEngines',
|
|
24
|
+
},
|
|
25
|
+
required: true,
|
|
26
|
+
default: '',
|
|
27
|
+
description: 'OCR engine to use. Click to load available engines 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: 'Languages Names or IDs',
|
|
32
|
+
name: 'languages',
|
|
33
|
+
type: 'multiOptions',
|
|
34
|
+
typeOptions: {
|
|
35
|
+
loadOptionsMethod: 'getRenderOcrLanguages',
|
|
36
|
+
loadOptionsDependsOn: ['engine'],
|
|
37
|
+
},
|
|
38
|
+
required: true,
|
|
39
|
+
default: [],
|
|
40
|
+
description: 'Target languages for OCR. Options depend on the selected engine. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
41
|
+
displayOptions: { show: showOnlyForRunJob },
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
displayName: 'Output Format Name or ID',
|
|
45
|
+
name: 'output_format',
|
|
46
|
+
type: 'options',
|
|
47
|
+
typeOptions: {
|
|
48
|
+
loadOptionsMethod: 'getRenderOcrOutputFormats',
|
|
49
|
+
loadOptionsDependsOn: ['engine'],
|
|
50
|
+
},
|
|
51
|
+
required: true,
|
|
52
|
+
default: '',
|
|
53
|
+
description: 'Output file format. Options depend on the selected engine. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
54
|
+
displayOptions: { show: showOnlyForRunJob },
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
displayName: 'Polling Settings',
|
|
58
|
+
name: 'pollingSettings',
|
|
59
|
+
type: 'collection',
|
|
60
|
+
placeholder: 'Add Setting',
|
|
61
|
+
default: {},
|
|
62
|
+
displayOptions: { show: showOnlyForRunJob },
|
|
63
|
+
options: [
|
|
64
|
+
{
|
|
65
|
+
displayName: 'Max Polling Attempts',
|
|
66
|
+
name: 'pollingMaxAttempts',
|
|
67
|
+
type: 'number',
|
|
68
|
+
typeOptions: { minValue: 1 },
|
|
69
|
+
default: 180,
|
|
70
|
+
description: 'Maximum number of polling attempts before giving up. With default serverWaitSeconds=10 and pollingMaxAttempts=180, maximum wait is about 30 minutes.',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
displayName: 'Server Wait Seconds',
|
|
74
|
+
name: 'serverWaitSeconds',
|
|
75
|
+
type: 'number',
|
|
76
|
+
typeOptions: { minValue: 1, maxValue: 10 },
|
|
77
|
+
default: 10,
|
|
78
|
+
description: 'Seconds the LDXhub server should wait before responding. Longer values reduce client-side polling frequency.',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
//# sourceMappingURL=runJob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runJob.js","sourceRoot":"","sources":["../../../../../nodes/LdxHub/resources/renderOcr/runJob.ts"],"names":[],"mappings":";;;AAEA,MAAM,iBAAiB,GAAG;IACzB,QAAQ,EAAE,CAAC,WAAW,CAAC;IACvB,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,sFAAsF;QACvF,cAAc,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;KAC3C;IACD;QACC,WAAW,EAAE,mBAAmB;QAChC,IA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AAW,EAAE,qBAAqB;gBAClC,IAAI,EAAE,mBAAmB;gBACzB,IAAI,EAAE,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"}
|
|
@@ -17,4 +17,9 @@ export type PollConfig = {
|
|
|
17
17
|
serverWaitSeconds: number;
|
|
18
18
|
pollingMaxAttempts: number;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type JobPollTarget = {
|
|
21
|
+
jobId: string;
|
|
22
|
+
endpoint: string;
|
|
23
|
+
serviceLabel: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function pollJobUntilDone(this: IExecuteFunctions, target: JobPollTarget, config: PollConfig, itemIndex: number): Promise<JobResponse>;
|
|
@@ -3,25 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.pollJobUntilDone = pollJobUntilDone;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
5
|
const transport_1 = require("./transport");
|
|
6
|
-
async function pollJobUntilDone(
|
|
6
|
+
async function pollJobUntilDone(target, config, itemIndex) {
|
|
7
7
|
var _a, _b, _c;
|
|
8
|
+
const { jobId, endpoint, serviceLabel } = target;
|
|
8
9
|
for (let attempt = 1; attempt <= config.pollingMaxAttempts; attempt++) {
|
|
9
|
-
const res = (await transport_1.ldxHubApiRequest.call(this, 'GET',
|
|
10
|
+
const res = (await transport_1.ldxHubApiRequest.call(this, 'GET', endpoint, undefined, { wait: config.serverWaitSeconds }));
|
|
10
11
|
switch (res.status) {
|
|
11
12
|
case 'completed':
|
|
12
13
|
return res;
|
|
13
14
|
case 'failed': {
|
|
14
15
|
const code = ((_a = res.error) === null || _a === void 0 ? void 0 : _a.code) ? ` [${res.error.code}]` : '';
|
|
15
16
|
const msg = (_c = (_b = res.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : 'no error details returned by API';
|
|
16
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(),
|
|
17
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${serviceLabel} job ${jobId} failed${code}: ${msg}`, { itemIndex });
|
|
17
18
|
}
|
|
18
19
|
case 'queued':
|
|
19
20
|
case 'processing':
|
|
20
21
|
break;
|
|
21
22
|
default:
|
|
22
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unexpected status '${res.status}' for
|
|
23
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unexpected status '${res.status}' for ${serviceLabel} job ${jobId}`, { itemIndex });
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(),
|
|
26
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${serviceLabel} job ${jobId} exceeded max poll attempts (${config.pollingMaxAttempts})`, { itemIndex });
|
|
26
27
|
}
|
|
27
28
|
//# sourceMappingURL=polling.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polling.js","sourceRoot":"","sources":["../../../../nodes/LdxHub/shared/polling.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"polling.js","sourceRoot":"","sources":["../../../../nodes/LdxHub/shared/polling.ts"],"names":[],"mappings":";;AAiCA,4CA8CC;AA9ED,+CAAkD;AAElD,2CAA+C;AA8BxC,KAAK,UAAU,gBAAgB,CAErC,MAAqB,EACrB,MAAkB,EAClB,SAAiB;;IAEjB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAEjD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,MAAM,CAAC,kBAAkB,EAAE,OAAO,EAAE,EAAE,CAAC;QACvE,MAAM,GAAG,GAAG,CAAC,MAAM,4BAAgB,CAAC,IAAI,CACvC,IAAI,EACJ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