@skillful-ai/piece-latex-to-pdf 0.0.5 → 0.0.6
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
|
@@ -2,7 +2,7 @@ export declare const compileZip: import("@activepieces/pieces-framework").IActio
|
|
|
2
2
|
serviceUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
3
3
|
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
4
4
|
}>, {
|
|
5
|
-
|
|
5
|
+
zipFileUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
6
|
mainFile: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
7
|
compiler: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
8
8
|
outputFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.compileZip = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
7
|
const auth_1 = require("../auth");
|
|
7
8
|
const common_1 = require("../common");
|
|
8
9
|
exports.compileZip = (0, pieces_framework_1.createAction)({
|
|
@@ -11,10 +12,10 @@ exports.compileZip = (0, pieces_framework_1.createAction)({
|
|
|
11
12
|
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
13
|
auth: auth_1.latexToPdfAuth,
|
|
13
14
|
props: {
|
|
14
|
-
|
|
15
|
+
zipFileUrl: pieces_framework_1.Property.ShortText({
|
|
15
16
|
displayName: "ZIP File",
|
|
16
|
-
description: "
|
|
17
|
-
required:
|
|
17
|
+
description: "File reference from a previous step (e.g., output from 'Files Helper → Zip Files' action)",
|
|
18
|
+
required: true,
|
|
18
19
|
}),
|
|
19
20
|
mainFile: pieces_framework_1.Property.ShortText({
|
|
20
21
|
displayName: "Main File",
|
|
@@ -49,42 +50,63 @@ exports.compileZip = (0, pieces_framework_1.createAction)({
|
|
|
49
50
|
},
|
|
50
51
|
run(context) {
|
|
51
52
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f
|
|
53
|
-
const {
|
|
53
|
+
var _a, _b, _c, _d, _e, _f;
|
|
54
|
+
const { zipFileUrl, mainFile, compiler, outputFormat } = context.propsValue;
|
|
54
55
|
const auth = context.auth;
|
|
55
|
-
// Log what we received for debugging
|
|
56
|
-
console.log('[compile-zip] Received zipFile:', {
|
|
57
|
-
type: typeof zipFile,
|
|
58
|
-
isNull: zipFile === null,
|
|
59
|
-
isUndefined: zipFile === undefined,
|
|
60
|
-
keys: zipFile ? Object.keys(zipFile) : 'N/A',
|
|
61
|
-
hasData: zipFile && 'data' in zipFile,
|
|
62
|
-
hasBase64: zipFile && 'base64' in zipFile,
|
|
63
|
-
});
|
|
64
56
|
// Validate inputs
|
|
65
|
-
if (!
|
|
66
|
-
throw new Error(
|
|
67
|
-
}
|
|
68
|
-
// Debug: Check what we received
|
|
69
|
-
const zipFileType = typeof zipFile;
|
|
70
|
-
const hasData = zipFile && 'data' in zipFile;
|
|
71
|
-
const hasBase64Getter = zipFile && typeof zipFile.base64 === 'string';
|
|
72
|
-
if (!hasData && !hasBase64Getter) {
|
|
73
|
-
throw new Error(`Invalid ZIP file format. Received type: ${zipFileType}, keys: ${zipFile ? Object.keys(zipFile).join(', ') : 'none'}`);
|
|
57
|
+
if (!zipFileUrl || typeof zipFileUrl !== 'string' || zipFileUrl.trim() === '') {
|
|
58
|
+
throw new Error("ZIP file URL is required");
|
|
74
59
|
}
|
|
75
60
|
if (!(mainFile === null || mainFile === void 0 ? void 0 : mainFile.trim())) {
|
|
76
61
|
throw new Error("Main file path is required");
|
|
77
62
|
}
|
|
63
|
+
// Clean the URL - remove surrounding quotes if present
|
|
64
|
+
let cleanUrl = zipFileUrl.trim();
|
|
65
|
+
if ((cleanUrl.startsWith('"') && cleanUrl.endsWith('"')) ||
|
|
66
|
+
(cleanUrl.startsWith("'") && cleanUrl.endsWith("'"))) {
|
|
67
|
+
cleanUrl = cleanUrl.slice(1, -1);
|
|
68
|
+
}
|
|
69
|
+
// Download the ZIP file
|
|
70
|
+
let fileBuffer;
|
|
71
|
+
let filename = "project.zip";
|
|
72
|
+
try {
|
|
73
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
74
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
75
|
+
url: cleanUrl,
|
|
76
|
+
});
|
|
77
|
+
// Handle different response types
|
|
78
|
+
if (response.body instanceof Buffer) {
|
|
79
|
+
fileBuffer = response.body;
|
|
80
|
+
}
|
|
81
|
+
else if (response.body instanceof ArrayBuffer) {
|
|
82
|
+
fileBuffer = Buffer.from(response.body);
|
|
83
|
+
}
|
|
84
|
+
else if (typeof response.body === 'string') {
|
|
85
|
+
// If it's base64 encoded
|
|
86
|
+
fileBuffer = Buffer.from(response.body, 'base64');
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Try to convert whatever we got
|
|
90
|
+
fileBuffer = Buffer.from(response.body);
|
|
91
|
+
}
|
|
92
|
+
// Extract filename from URL if possible
|
|
93
|
+
const urlParts = cleanUrl.split('/');
|
|
94
|
+
const lastPart = (_a = urlParts[urlParts.length - 1]) === null || _a === void 0 ? void 0 : _a.split('?')[0];
|
|
95
|
+
if (lastPart && lastPart.endsWith('.zip')) {
|
|
96
|
+
filename = lastPart;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (downloadError) {
|
|
100
|
+
const errorMsg = downloadError instanceof Error ? downloadError.message : String(downloadError);
|
|
101
|
+
throw new Error(`Failed to download ZIP file: ${errorMsg}`);
|
|
102
|
+
}
|
|
103
|
+
if (!fileBuffer || fileBuffer.length === 0) {
|
|
104
|
+
throw new Error("Downloaded ZIP file is empty");
|
|
105
|
+
}
|
|
78
106
|
const serviceUrl = (0, common_1.getServiceUrl)(auth);
|
|
79
107
|
const headers = (0, common_1.buildHeaders)(auth);
|
|
80
|
-
//
|
|
81
|
-
const fileContent =
|
|
82
|
-
if (!fileContent || fileContent.length === 0) {
|
|
83
|
-
throw new Error(`ZIP file content is empty. Filename: ${zipFile.filename}, data length: ${(_b = (_a = zipFile.data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0}`);
|
|
84
|
-
}
|
|
85
|
-
const filename = ((_c = zipFile.filename) === null || _c === void 0 ? void 0 : _c.endsWith(".zip"))
|
|
86
|
-
? zipFile.filename
|
|
87
|
-
: "project.zip";
|
|
108
|
+
// Convert to base64
|
|
109
|
+
const fileContent = fileBuffer.toString('base64');
|
|
88
110
|
// 1. Submit for compilation
|
|
89
111
|
const submitResponse = yield (0, common_1.submitCompilation)(serviceUrl, {
|
|
90
112
|
file_content: fileContent,
|
|
@@ -103,11 +125,11 @@ exports.compileZip = (0, pieces_framework_1.createAction)({
|
|
|
103
125
|
return {
|
|
104
126
|
success: true,
|
|
105
127
|
jobId: result.job_id,
|
|
106
|
-
pdfUrl: (
|
|
107
|
-
pdfBase64: (
|
|
108
|
-
logUrl: (
|
|
109
|
-
durationMs: (
|
|
110
|
-
pdfSizeBytes: (
|
|
128
|
+
pdfUrl: (_b = result.result) === null || _b === void 0 ? void 0 : _b.pdf_url,
|
|
129
|
+
pdfBase64: (_c = result.result) === null || _c === void 0 ? void 0 : _c.pdf_base64,
|
|
130
|
+
logUrl: (_d = result.result) === null || _d === void 0 ? void 0 : _d.log_url,
|
|
131
|
+
durationMs: (_e = result.result) === null || _e === void 0 ? void 0 : _e.duration_ms,
|
|
132
|
+
pdfSizeBytes: (_f = result.result) === null || _f === void 0 ? void 0 : _f.pdf_size_bytes,
|
|
111
133
|
compiler,
|
|
112
134
|
mainFile: mainFile.trim(),
|
|
113
135
|
};
|
|
@@ -1 +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,
|
|
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,+DAAqE;AACrE,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,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,2FAA2F;YACxG,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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