@hasna/files 0.2.15 → 0.2.16
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/dist/cli/index.js +21 -3
- package/dist/index.js +21 -3
- package/dist/mcp/index.js +21 -3
- package/dist/server/index.js +21 -3
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -167615,7 +167615,7 @@ async function syncGoogleDriveSource(source) {
|
|
|
167615
167615
|
const existing = getGoogleDriveImportedObject(source.id, item.drive_id, item.id);
|
|
167616
167616
|
if (existing && !shouldImport(config9, item, existing, destination.source.id, destination.storage_type))
|
|
167617
167617
|
continue;
|
|
167618
|
-
const downloaded =
|
|
167618
|
+
const downloaded = await downloadOrArchiveGoogleDriveItem(client2, item, config9);
|
|
167619
167619
|
const importedName = basename5(downloaded.filename);
|
|
167620
167620
|
const importedPath = buildImportedPath(config9, item, importedName);
|
|
167621
167621
|
const contentType = downloaded.mimeType || ($lookup(downloaded.filename) || item.mime || "application/octet-stream");
|
|
@@ -167898,10 +167898,28 @@ function canDownloadDriveItem(item) {
|
|
|
167898
167898
|
"application/vnd.google-apps.drawing"
|
|
167899
167899
|
].includes(item.mime);
|
|
167900
167900
|
}
|
|
167901
|
-
function
|
|
167901
|
+
async function downloadOrArchiveGoogleDriveItem(client2, item, config9) {
|
|
167902
|
+
if (!canDownloadDriveItem(item))
|
|
167903
|
+
return createGoogleDriveMetadataArchive(item);
|
|
167904
|
+
try {
|
|
167905
|
+
return await client2.downloadFile(toApiFile(item), config9.export_formats);
|
|
167906
|
+
} catch (error) {
|
|
167907
|
+
if (shouldArchiveGoogleDriveDownloadError(item, error)) {
|
|
167908
|
+
return createGoogleDriveMetadataArchive(item, `Google Drive export failed: ${error.message}`);
|
|
167909
|
+
}
|
|
167910
|
+
throw error;
|
|
167911
|
+
}
|
|
167912
|
+
}
|
|
167913
|
+
function shouldArchiveGoogleDriveDownloadError(item, error) {
|
|
167914
|
+
if (!item.mime.startsWith("application/vnd.google-apps."))
|
|
167915
|
+
return false;
|
|
167916
|
+
const message = error.message ?? String(error);
|
|
167917
|
+
return /cannot be exported/i.test(message);
|
|
167918
|
+
}
|
|
167919
|
+
function createGoogleDriveMetadataArchive(item, reason = "Google Drive item is not exportable as file content through Drive export.") {
|
|
167902
167920
|
const metadata = {
|
|
167903
167921
|
archived_as: "google-drive-metadata",
|
|
167904
|
-
reason
|
|
167922
|
+
reason,
|
|
167905
167923
|
id: item.id,
|
|
167906
167924
|
name: item.name,
|
|
167907
167925
|
mime: item.mime,
|
package/dist/index.js
CHANGED
|
@@ -164208,7 +164208,7 @@ async function syncGoogleDriveSource(source) {
|
|
|
164208
164208
|
const existing = getGoogleDriveImportedObject(source.id, item.drive_id, item.id);
|
|
164209
164209
|
if (existing && !shouldImport(config9, item, existing, destination.source.id, destination.storage_type))
|
|
164210
164210
|
continue;
|
|
164211
|
-
const downloaded =
|
|
164211
|
+
const downloaded = await downloadOrArchiveGoogleDriveItem(client2, item, config9);
|
|
164212
164212
|
const importedName = basename5(downloaded.filename);
|
|
164213
164213
|
const importedPath = buildImportedPath(config9, item, importedName);
|
|
164214
164214
|
const contentType = downloaded.mimeType || ($lookup(downloaded.filename) || item.mime || "application/octet-stream");
|
|
@@ -164491,10 +164491,28 @@ function canDownloadDriveItem(item) {
|
|
|
164491
164491
|
"application/vnd.google-apps.drawing"
|
|
164492
164492
|
].includes(item.mime);
|
|
164493
164493
|
}
|
|
164494
|
-
function
|
|
164494
|
+
async function downloadOrArchiveGoogleDriveItem(client2, item, config9) {
|
|
164495
|
+
if (!canDownloadDriveItem(item))
|
|
164496
|
+
return createGoogleDriveMetadataArchive(item);
|
|
164497
|
+
try {
|
|
164498
|
+
return await client2.downloadFile(toApiFile(item), config9.export_formats);
|
|
164499
|
+
} catch (error) {
|
|
164500
|
+
if (shouldArchiveGoogleDriveDownloadError(item, error)) {
|
|
164501
|
+
return createGoogleDriveMetadataArchive(item, `Google Drive export failed: ${error.message}`);
|
|
164502
|
+
}
|
|
164503
|
+
throw error;
|
|
164504
|
+
}
|
|
164505
|
+
}
|
|
164506
|
+
function shouldArchiveGoogleDriveDownloadError(item, error) {
|
|
164507
|
+
if (!item.mime.startsWith("application/vnd.google-apps."))
|
|
164508
|
+
return false;
|
|
164509
|
+
const message = error.message ?? String(error);
|
|
164510
|
+
return /cannot be exported/i.test(message);
|
|
164511
|
+
}
|
|
164512
|
+
function createGoogleDriveMetadataArchive(item, reason = "Google Drive item is not exportable as file content through Drive export.") {
|
|
164495
164513
|
const metadata = {
|
|
164496
164514
|
archived_as: "google-drive-metadata",
|
|
164497
|
-
reason
|
|
164515
|
+
reason,
|
|
164498
164516
|
id: item.id,
|
|
164499
164517
|
name: item.name,
|
|
164500
164518
|
mime: item.mime,
|
package/dist/mcp/index.js
CHANGED
|
@@ -183139,7 +183139,7 @@ async function syncGoogleDriveSource(source) {
|
|
|
183139
183139
|
const existing = getGoogleDriveImportedObject(source.id, item.drive_id, item.id);
|
|
183140
183140
|
if (existing && !shouldImport(config9, item, existing, destination.source.id, destination.storage_type))
|
|
183141
183141
|
continue;
|
|
183142
|
-
const downloaded =
|
|
183142
|
+
const downloaded = await downloadOrArchiveGoogleDriveItem(client2, item, config9);
|
|
183143
183143
|
const importedName = basename5(downloaded.filename);
|
|
183144
183144
|
const importedPath = buildImportedPath(config9, item, importedName);
|
|
183145
183145
|
const contentType = downloaded.mimeType || ($lookup(downloaded.filename) || item.mime || "application/octet-stream");
|
|
@@ -183422,10 +183422,28 @@ function canDownloadDriveItem(item) {
|
|
|
183422
183422
|
"application/vnd.google-apps.drawing"
|
|
183423
183423
|
].includes(item.mime);
|
|
183424
183424
|
}
|
|
183425
|
-
function
|
|
183425
|
+
async function downloadOrArchiveGoogleDriveItem(client2, item, config9) {
|
|
183426
|
+
if (!canDownloadDriveItem(item))
|
|
183427
|
+
return createGoogleDriveMetadataArchive(item);
|
|
183428
|
+
try {
|
|
183429
|
+
return await client2.downloadFile(toApiFile(item), config9.export_formats);
|
|
183430
|
+
} catch (error) {
|
|
183431
|
+
if (shouldArchiveGoogleDriveDownloadError(item, error)) {
|
|
183432
|
+
return createGoogleDriveMetadataArchive(item, `Google Drive export failed: ${error.message}`);
|
|
183433
|
+
}
|
|
183434
|
+
throw error;
|
|
183435
|
+
}
|
|
183436
|
+
}
|
|
183437
|
+
function shouldArchiveGoogleDriveDownloadError(item, error) {
|
|
183438
|
+
if (!item.mime.startsWith("application/vnd.google-apps."))
|
|
183439
|
+
return false;
|
|
183440
|
+
const message = error.message ?? String(error);
|
|
183441
|
+
return /cannot be exported/i.test(message);
|
|
183442
|
+
}
|
|
183443
|
+
function createGoogleDriveMetadataArchive(item, reason = "Google Drive item is not exportable as file content through Drive export.") {
|
|
183426
183444
|
const metadata = {
|
|
183427
183445
|
archived_as: "google-drive-metadata",
|
|
183428
|
-
reason
|
|
183446
|
+
reason,
|
|
183429
183447
|
id: item.id,
|
|
183430
183448
|
name: item.name,
|
|
183431
183449
|
mime: item.mime,
|
package/dist/server/index.js
CHANGED
|
@@ -163895,7 +163895,7 @@ async function syncGoogleDriveSource(source) {
|
|
|
163895
163895
|
const existing = getGoogleDriveImportedObject(source.id, item.drive_id, item.id);
|
|
163896
163896
|
if (existing && !shouldImport(config9, item, existing, destination.source.id, destination.storage_type))
|
|
163897
163897
|
continue;
|
|
163898
|
-
const downloaded =
|
|
163898
|
+
const downloaded = await downloadOrArchiveGoogleDriveItem(client2, item, config9);
|
|
163899
163899
|
const importedName = basename5(downloaded.filename);
|
|
163900
163900
|
const importedPath = buildImportedPath(config9, item, importedName);
|
|
163901
163901
|
const contentType = downloaded.mimeType || ($lookup(downloaded.filename) || item.mime || "application/octet-stream");
|
|
@@ -164161,10 +164161,28 @@ function canDownloadDriveItem(item) {
|
|
|
164161
164161
|
"application/vnd.google-apps.drawing"
|
|
164162
164162
|
].includes(item.mime);
|
|
164163
164163
|
}
|
|
164164
|
-
function
|
|
164164
|
+
async function downloadOrArchiveGoogleDriveItem(client2, item, config9) {
|
|
164165
|
+
if (!canDownloadDriveItem(item))
|
|
164166
|
+
return createGoogleDriveMetadataArchive(item);
|
|
164167
|
+
try {
|
|
164168
|
+
return await client2.downloadFile(toApiFile(item), config9.export_formats);
|
|
164169
|
+
} catch (error) {
|
|
164170
|
+
if (shouldArchiveGoogleDriveDownloadError(item, error)) {
|
|
164171
|
+
return createGoogleDriveMetadataArchive(item, `Google Drive export failed: ${error.message}`);
|
|
164172
|
+
}
|
|
164173
|
+
throw error;
|
|
164174
|
+
}
|
|
164175
|
+
}
|
|
164176
|
+
function shouldArchiveGoogleDriveDownloadError(item, error) {
|
|
164177
|
+
if (!item.mime.startsWith("application/vnd.google-apps."))
|
|
164178
|
+
return false;
|
|
164179
|
+
const message = error.message ?? String(error);
|
|
164180
|
+
return /cannot be exported/i.test(message);
|
|
164181
|
+
}
|
|
164182
|
+
function createGoogleDriveMetadataArchive(item, reason = "Google Drive item is not exportable as file content through Drive export.") {
|
|
164165
164183
|
const metadata = {
|
|
164166
164184
|
archived_as: "google-drive-metadata",
|
|
164167
|
-
reason
|
|
164185
|
+
reason,
|
|
164168
164186
|
id: item.id,
|
|
164169
164187
|
name: item.name,
|
|
164170
164188
|
mime: item.mime,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/files",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "Agent-first file management — index local folders and S3 buckets, sync Google Drive, tag, search, and retrieve files via CLI + MCP",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|