@skillful-ai/piece-latex-to-pdf 0.0.1 → 0.0.3
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/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -5,15 +5,16 @@ const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
|
5
5
|
const shared_1 = require("@activepieces/shared");
|
|
6
6
|
const auth_1 = require("./lib/auth");
|
|
7
7
|
const compile_latex_1 = require("./lib/actions/compile-latex");
|
|
8
|
+
const compile_zip_1 = require("./lib/actions/compile-zip");
|
|
8
9
|
exports.latexToPdf = (0, pieces_framework_1.createPiece)({
|
|
9
10
|
displayName: "LaTeX to PDF",
|
|
10
|
-
description: "Compile LaTeX documents to PDF using a cloud compilation service. Supports pdflatex and xelatex compilers with multiple output formats.",
|
|
11
|
+
description: "Compile LaTeX documents to PDF using a cloud compilation service. Supports pdflatex and xelatex compilers with multiple output formats. Can compile single .tex files or ZIP projects with images.",
|
|
11
12
|
auth: auth_1.latexToPdfAuth,
|
|
12
13
|
minimumSupportedRelease: "0.36.1",
|
|
13
14
|
logoUrl: "https://cdn.activepieces.com/pieces/latex.png",
|
|
14
15
|
authors: ["skillful-ai"],
|
|
15
16
|
categories: [shared_1.PieceCategory.CORE],
|
|
16
|
-
actions: [compile_latex_1.compileLatex],
|
|
17
|
+
actions: [compile_latex_1.compileLatex, compile_zip_1.compileZip],
|
|
17
18
|
triggers: [],
|
|
18
19
|
});
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/custom/latex-to-pdf/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAA6D;AAC7D,iDAAqD;AACrD,qCAA4C;AAC5C,+DAA2D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/custom/latex-to-pdf/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAA6D;AAC7D,iDAAqD;AACrD,qCAA4C;AAC5C,+DAA2D;AAC3D,2DAAuD;AAE1C,QAAA,UAAU,GAAG,IAAA,8BAAW,EAAC;IACpC,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,oMAAoM;IACjN,IAAI,EAAE,qBAAc;IACpB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,+CAA+C;IACxD,OAAO,EAAE,CAAC,aAAa,CAAC;IACxB,UAAU,EAAE,CAAC,sBAAa,CAAC,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,4BAAY,EAAE,wBAAU,CAAC;IACnC,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const compileZip: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
serviceUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
3
|
+
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
4
|
+
}>, {
|
|
5
|
+
zipFile: import("@activepieces/pieces-framework").FileProperty<true>;
|
|
6
|
+
mainFile: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
compiler: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
8
|
+
outputFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compileZip = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
exports.compileZip = (0, pieces_framework_1.createAction)({
|
|
9
|
+
name: "compile_zip",
|
|
10
|
+
displayName: "Compile LaTeX Project (ZIP)",
|
|
11
|
+
description: "Compile a ZIP file containing LaTeX source and images to PDF. The ZIP must contain a main.tex file (or specify the main file path).",
|
|
12
|
+
auth: auth_1.latexToPdfAuth,
|
|
13
|
+
props: {
|
|
14
|
+
zipFile: pieces_framework_1.Property.File({
|
|
15
|
+
displayName: "ZIP File",
|
|
16
|
+
description: "A ZIP archive containing main.tex and any images/assets. Can be created using 'Files Helper → Zip Files' action.",
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
mainFile: pieces_framework_1.Property.ShortText({
|
|
20
|
+
displayName: "Main File",
|
|
21
|
+
description: "Path to the main .tex file inside the ZIP (relative to ZIP root)",
|
|
22
|
+
required: true,
|
|
23
|
+
defaultValue: "main.tex",
|
|
24
|
+
}),
|
|
25
|
+
compiler: pieces_framework_1.Property.StaticDropdown({
|
|
26
|
+
displayName: "Compiler",
|
|
27
|
+
description: "LaTeX compiler to use for compilation",
|
|
28
|
+
required: true,
|
|
29
|
+
defaultValue: "xelatex",
|
|
30
|
+
options: {
|
|
31
|
+
options: [
|
|
32
|
+
{ label: "XeLaTeX (recommended for Unicode/fonts)", value: "xelatex" },
|
|
33
|
+
{ label: "pdfLaTeX (traditional)", value: "pdflatex" },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
outputFormat: pieces_framework_1.Property.StaticDropdown({
|
|
38
|
+
displayName: "Output Format",
|
|
39
|
+
description: "How to return the compiled PDF",
|
|
40
|
+
required: true,
|
|
41
|
+
defaultValue: "url",
|
|
42
|
+
options: {
|
|
43
|
+
options: [
|
|
44
|
+
{ label: "URL (presigned download link)", value: "url" },
|
|
45
|
+
{ label: "Base64 (embedded in response)", value: "base64" },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
run(context) {
|
|
51
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
53
|
+
const { zipFile, mainFile, compiler, outputFormat } = context.propsValue;
|
|
54
|
+
const auth = context.auth;
|
|
55
|
+
// Validate inputs
|
|
56
|
+
if (!zipFile) {
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
error: "ZIP file is required",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// Debug: Check what we received
|
|
63
|
+
const zipFileType = typeof zipFile;
|
|
64
|
+
const hasData = zipFile && 'data' in zipFile;
|
|
65
|
+
const hasBase64Getter = zipFile && typeof zipFile.base64 === 'string';
|
|
66
|
+
if (!hasData && !hasBase64Getter) {
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
error: `Invalid ZIP file format. Received type: ${zipFileType}, has data: ${hasData}, has base64: ${hasBase64Getter}`,
|
|
70
|
+
debug: {
|
|
71
|
+
receivedKeys: zipFile ? Object.keys(zipFile) : [],
|
|
72
|
+
zipFileType,
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (!(mainFile === null || mainFile === void 0 ? void 0 : mainFile.trim())) {
|
|
77
|
+
return {
|
|
78
|
+
success: false,
|
|
79
|
+
error: "Main file path is required",
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const serviceUrl = (0, common_1.getServiceUrl)(auth);
|
|
84
|
+
const headers = (0, common_1.buildHeaders)(auth);
|
|
85
|
+
// Get base64 content - ApFile has a getter that converts Buffer to base64
|
|
86
|
+
const fileContent = zipFile.base64;
|
|
87
|
+
if (!fileContent || fileContent.length === 0) {
|
|
88
|
+
return {
|
|
89
|
+
success: false,
|
|
90
|
+
error: "ZIP file content is empty",
|
|
91
|
+
debug: {
|
|
92
|
+
filename: zipFile.filename,
|
|
93
|
+
dataLength: (_b = (_a = zipFile.data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const filename = ((_c = zipFile.filename) === null || _c === void 0 ? void 0 : _c.endsWith(".zip"))
|
|
98
|
+
? zipFile.filename
|
|
99
|
+
: "project.zip";
|
|
100
|
+
// 1. Submit for compilation
|
|
101
|
+
const submitResponse = yield (0, common_1.submitCompilation)(serviceUrl, {
|
|
102
|
+
file_content: fileContent,
|
|
103
|
+
filename: filename,
|
|
104
|
+
main_file: mainFile.trim(),
|
|
105
|
+
compiler: compiler,
|
|
106
|
+
output_format: outputFormat,
|
|
107
|
+
}, headers);
|
|
108
|
+
// 2. Poll until completion
|
|
109
|
+
const result = yield (0, common_1.pollForCompletion)(serviceUrl, submitResponse.job_id, headers);
|
|
110
|
+
// 3. Process result
|
|
111
|
+
if (result.status === "failed") {
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
error: result.error_message || result.message || "Compilation failed",
|
|
115
|
+
jobId: result.job_id,
|
|
116
|
+
logUrl: (_d = result.result) === null || _d === void 0 ? void 0 : _d.log_url,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
// Success
|
|
120
|
+
return {
|
|
121
|
+
success: true,
|
|
122
|
+
jobId: result.job_id,
|
|
123
|
+
pdfUrl: (_e = result.result) === null || _e === void 0 ? void 0 : _e.pdf_url,
|
|
124
|
+
pdfBase64: (_f = result.result) === null || _f === void 0 ? void 0 : _f.pdf_base64,
|
|
125
|
+
logUrl: (_g = result.result) === null || _g === void 0 ? void 0 : _g.log_url,
|
|
126
|
+
durationMs: (_h = result.result) === null || _h === void 0 ? void 0 : _h.duration_ms,
|
|
127
|
+
pdfSizeBytes: (_j = result.result) === null || _j === void 0 ? void 0 : _j.pdf_size_bytes,
|
|
128
|
+
compiler,
|
|
129
|
+
mainFile: mainFile.trim(),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
134
|
+
return {
|
|
135
|
+
success: false,
|
|
136
|
+
error: errorMessage,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
//# sourceMappingURL=compile-zip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-zip.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/latex-to-pdf/src/lib/actions/compile-zip.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,kCAAyD;AACzD,sCAOmB;AAEN,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACrC,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,6BAA6B;IAC1C,WAAW,EAAE,qIAAqI;IAClJ,IAAI,EAAE,qBAAc;IACpB,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACrB,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,kHAAkH;YAC/H,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,kEAAkE;YAC/E,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,UAAU;SACzB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAChC,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,uCAAuC;YACpD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,SAAS;YACvB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,yCAAyC,EAAE,KAAK,EAAE,SAAS,EAAE;oBACtE,EAAE,KAAK,EAAE,wBAAwB,EAAE,KAAK,EAAE,UAAU,EAAE;iBACvD;aACF;SACF,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACpC,WAAW,EAAE,eAAe;YAC5B,WAAW,EAAE,gCAAgC;YAC7C,QAAQ,EAAE,IAAI;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