@credal/actions 0.2.45 → 0.2.46
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.
@@ -151,6 +151,8 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
151
151
|
if (limit && content.length > limit) {
|
152
152
|
content = content.substring(0, limit);
|
153
153
|
}
|
154
|
+
// Replace all newline characters with spaces, then collapse multiple spaces
|
155
|
+
content = content.replace(/\r?\n+/g, " ").replace(/ +/g, " ");
|
154
156
|
return {
|
155
157
|
success: true,
|
156
158
|
content,
|
@@ -25,33 +25,33 @@ const searchDriveByQueryAndGetFileContent = (_a) => __awaiter(void 0, [_a], void
|
|
25
25
|
if (!searchResult.success) {
|
26
26
|
return { success: false, error: searchResult.error, files: [] };
|
27
27
|
}
|
28
|
-
// For each file, fetch its content
|
29
|
-
const filesWithContent = [];
|
28
|
+
// For each file, fetch its content in parallel
|
30
29
|
const files = (_b = searchResult.files) !== null && _b !== void 0 ? _b : [];
|
31
|
-
|
30
|
+
const contentPromises = files.map((file) => __awaiter(void 0, void 0, void 0, function* () {
|
32
31
|
try {
|
33
32
|
const contentResult = yield getDriveFileContentById({
|
34
33
|
params: { fileId: file.id, limit: fileSizeLimit !== null && fileSizeLimit !== void 0 ? fileSizeLimit : 1000 },
|
35
34
|
authParams,
|
36
35
|
});
|
37
|
-
|
36
|
+
return {
|
38
37
|
id: file.id,
|
39
38
|
name: file.name,
|
40
39
|
mimeType: file.mimeType,
|
41
40
|
url: file.url,
|
42
41
|
content: contentResult.success ? contentResult.content : undefined,
|
43
|
-
}
|
42
|
+
};
|
44
43
|
}
|
45
44
|
catch (error) {
|
46
45
|
console.error(`Error fetching content for file ${file.id}:`, error);
|
47
|
-
|
46
|
+
return {
|
48
47
|
id: file.id,
|
49
48
|
name: file.name,
|
50
49
|
mimeType: file.mimeType,
|
51
50
|
url: file.url,
|
52
|
-
}
|
51
|
+
};
|
53
52
|
}
|
54
|
-
}
|
53
|
+
}));
|
54
|
+
const filesWithContent = yield Promise.all(contentPromises);
|
55
55
|
// Return combined results
|
56
56
|
return { success: true, files: filesWithContent };
|
57
57
|
});
|