@skillful-ai/piece-latex-to-pdf 0.0.5 → 0.0.7
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,79 @@ 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
|
+
// Debug: log what we received
|
|
78
|
+
const bodyType = typeof response.body;
|
|
79
|
+
const isBuffer = response.body instanceof Buffer;
|
|
80
|
+
const isArrayBuffer = response.body instanceof ArrayBuffer;
|
|
81
|
+
console.log(`[compile-zip] Response body type: ${bodyType}, isBuffer: ${isBuffer}, isArrayBuffer: ${isArrayBuffer}`);
|
|
82
|
+
// Handle different response types
|
|
83
|
+
if (response.body instanceof Buffer) {
|
|
84
|
+
fileBuffer = response.body;
|
|
85
|
+
console.log(`[compile-zip] Body is Buffer, length: ${fileBuffer.length}`);
|
|
86
|
+
}
|
|
87
|
+
else if (response.body instanceof ArrayBuffer) {
|
|
88
|
+
fileBuffer = Buffer.from(response.body);
|
|
89
|
+
console.log(`[compile-zip] Body is ArrayBuffer, length: ${fileBuffer.length}`);
|
|
90
|
+
}
|
|
91
|
+
else if (typeof response.body === 'string') {
|
|
92
|
+
// Log first 100 chars to understand the content
|
|
93
|
+
console.log(`[compile-zip] Body is string, length: ${response.body.length}, first 100 chars: ${response.body.substring(0, 100)}`);
|
|
94
|
+
// If it's base64 encoded
|
|
95
|
+
fileBuffer = Buffer.from(response.body, 'base64');
|
|
96
|
+
console.log(`[compile-zip] Decoded as base64, buffer length: ${fileBuffer.length}`);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
console.log(`[compile-zip] Body is unknown type, trying to convert`);
|
|
100
|
+
// Try to convert whatever we got
|
|
101
|
+
fileBuffer = Buffer.from(response.body);
|
|
102
|
+
}
|
|
103
|
+
// Log first bytes to verify ZIP magic number (PK = 0x50 0x4B)
|
|
104
|
+
if (fileBuffer.length >= 4) {
|
|
105
|
+
const header = fileBuffer.slice(0, 4);
|
|
106
|
+
console.log(`[compile-zip] First 4 bytes (hex): ${header.toString('hex')}, as string: ${header.toString('utf8')}`);
|
|
107
|
+
}
|
|
108
|
+
// Extract filename from URL if possible
|
|
109
|
+
const urlParts = cleanUrl.split('/');
|
|
110
|
+
const lastPart = (_a = urlParts[urlParts.length - 1]) === null || _a === void 0 ? void 0 : _a.split('?')[0];
|
|
111
|
+
if (lastPart && lastPart.endsWith('.zip')) {
|
|
112
|
+
filename = lastPart;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (downloadError) {
|
|
116
|
+
const errorMsg = downloadError instanceof Error ? downloadError.message : String(downloadError);
|
|
117
|
+
throw new Error(`Failed to download ZIP file: ${errorMsg}`);
|
|
118
|
+
}
|
|
119
|
+
if (!fileBuffer || fileBuffer.length === 0) {
|
|
120
|
+
throw new Error("Downloaded ZIP file is empty");
|
|
121
|
+
}
|
|
78
122
|
const serviceUrl = (0, common_1.getServiceUrl)(auth);
|
|
79
123
|
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";
|
|
124
|
+
// Convert to base64
|
|
125
|
+
const fileContent = fileBuffer.toString('base64');
|
|
88
126
|
// 1. Submit for compilation
|
|
89
127
|
const submitResponse = yield (0, common_1.submitCompilation)(serviceUrl, {
|
|
90
128
|
file_content: fileContent,
|
|
@@ -103,11 +141,11 @@ exports.compileZip = (0, pieces_framework_1.createAction)({
|
|
|
103
141
|
return {
|
|
104
142
|
success: true,
|
|
105
143
|
jobId: result.job_id,
|
|
106
|
-
pdfUrl: (
|
|
107
|
-
pdfBase64: (
|
|
108
|
-
logUrl: (
|
|
109
|
-
durationMs: (
|
|
110
|
-
pdfSizeBytes: (
|
|
144
|
+
pdfUrl: (_b = result.result) === null || _b === void 0 ? void 0 : _b.pdf_url,
|
|
145
|
+
pdfBase64: (_c = result.result) === null || _c === void 0 ? void 0 : _c.pdf_base64,
|
|
146
|
+
logUrl: (_d = result.result) === null || _d === void 0 ? void 0 : _d.log_url,
|
|
147
|
+
durationMs: (_e = result.result) === null || _e === void 0 ? void 0 : _e.duration_ms,
|
|
148
|
+
pdfSizeBytes: (_f = result.result) === null || _f === void 0 ? void 0 : _f.pdf_size_bytes,
|
|
111
149
|
compiler,
|
|
112
150
|
mainFile: mainFile.trim(),
|
|
113
151
|
};
|
|
@@ -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;AAC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