@hasna/files 0.2.14 → 0.2.15

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 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 = await client2.downloadFile(toApiFile(item), config9.export_formats);
167618
+ const downloaded = canDownloadDriveItem(item) ? await client2.downloadFile(toApiFile(item), config9.export_formats) : createGoogleDriveMetadataArchive(item);
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");
@@ -167888,6 +167888,41 @@ function appendDriveFileId(filename, fileId) {
167888
167888
  const base = ext ? filename.slice(0, -ext.length) : filename;
167889
167889
  return `${base} (${safePathSegment(fileId)})${ext}`;
167890
167890
  }
167891
+ function canDownloadDriveItem(item) {
167892
+ if (!item.mime.startsWith("application/vnd.google-apps."))
167893
+ return true;
167894
+ return [
167895
+ "application/vnd.google-apps.document",
167896
+ "application/vnd.google-apps.spreadsheet",
167897
+ "application/vnd.google-apps.presentation",
167898
+ "application/vnd.google-apps.drawing"
167899
+ ].includes(item.mime);
167900
+ }
167901
+ function createGoogleDriveMetadataArchive(item) {
167902
+ const metadata = {
167903
+ archived_as: "google-drive-metadata",
167904
+ reason: "Google Drive item is not exportable as file content through Drive export.",
167905
+ id: item.id,
167906
+ name: item.name,
167907
+ mime: item.mime,
167908
+ drive_id: item.drive_id,
167909
+ drive_name: item.drive_name,
167910
+ is_shared_drive: item.is_shared_drive,
167911
+ parent_id: item.parent_id,
167912
+ path: item.path,
167913
+ size: item.size,
167914
+ modified_at: item.modified_at,
167915
+ version: item.version,
167916
+ hash: item.hash
167917
+ };
167918
+ const data = Buffer.from(JSON.stringify(metadata, null, 2) + `
167919
+ `);
167920
+ return {
167921
+ data: data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength),
167922
+ filename: `${item.name}.gdrive-metadata.json`,
167923
+ mimeType: "application/json"
167924
+ };
167925
+ }
167891
167926
  function toApiFile(item) {
167892
167927
  return {
167893
167928
  id: item.id,
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 = await client2.downloadFile(toApiFile(item), config9.export_formats);
164211
+ const downloaded = canDownloadDriveItem(item) ? await client2.downloadFile(toApiFile(item), config9.export_formats) : createGoogleDriveMetadataArchive(item);
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");
@@ -164481,6 +164481,41 @@ function appendDriveFileId(filename, fileId) {
164481
164481
  const base = ext ? filename.slice(0, -ext.length) : filename;
164482
164482
  return `${base} (${safePathSegment(fileId)})${ext}`;
164483
164483
  }
164484
+ function canDownloadDriveItem(item) {
164485
+ if (!item.mime.startsWith("application/vnd.google-apps."))
164486
+ return true;
164487
+ return [
164488
+ "application/vnd.google-apps.document",
164489
+ "application/vnd.google-apps.spreadsheet",
164490
+ "application/vnd.google-apps.presentation",
164491
+ "application/vnd.google-apps.drawing"
164492
+ ].includes(item.mime);
164493
+ }
164494
+ function createGoogleDriveMetadataArchive(item) {
164495
+ const metadata = {
164496
+ archived_as: "google-drive-metadata",
164497
+ reason: "Google Drive item is not exportable as file content through Drive export.",
164498
+ id: item.id,
164499
+ name: item.name,
164500
+ mime: item.mime,
164501
+ drive_id: item.drive_id,
164502
+ drive_name: item.drive_name,
164503
+ is_shared_drive: item.is_shared_drive,
164504
+ parent_id: item.parent_id,
164505
+ path: item.path,
164506
+ size: item.size,
164507
+ modified_at: item.modified_at,
164508
+ version: item.version,
164509
+ hash: item.hash
164510
+ };
164511
+ const data = Buffer.from(JSON.stringify(metadata, null, 2) + `
164512
+ `);
164513
+ return {
164514
+ data: data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength),
164515
+ filename: `${item.name}.gdrive-metadata.json`,
164516
+ mimeType: "application/json"
164517
+ };
164518
+ }
164484
164519
  function toApiFile(item) {
164485
164520
  return {
164486
164521
  id: item.id,
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 = await client2.downloadFile(toApiFile(item), config9.export_formats);
183142
+ const downloaded = canDownloadDriveItem(item) ? await client2.downloadFile(toApiFile(item), config9.export_formats) : createGoogleDriveMetadataArchive(item);
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");
@@ -183412,6 +183412,41 @@ function appendDriveFileId(filename, fileId) {
183412
183412
  const base = ext ? filename.slice(0, -ext.length) : filename;
183413
183413
  return `${base} (${safePathSegment(fileId)})${ext}`;
183414
183414
  }
183415
+ function canDownloadDriveItem(item) {
183416
+ if (!item.mime.startsWith("application/vnd.google-apps."))
183417
+ return true;
183418
+ return [
183419
+ "application/vnd.google-apps.document",
183420
+ "application/vnd.google-apps.spreadsheet",
183421
+ "application/vnd.google-apps.presentation",
183422
+ "application/vnd.google-apps.drawing"
183423
+ ].includes(item.mime);
183424
+ }
183425
+ function createGoogleDriveMetadataArchive(item) {
183426
+ const metadata = {
183427
+ archived_as: "google-drive-metadata",
183428
+ reason: "Google Drive item is not exportable as file content through Drive export.",
183429
+ id: item.id,
183430
+ name: item.name,
183431
+ mime: item.mime,
183432
+ drive_id: item.drive_id,
183433
+ drive_name: item.drive_name,
183434
+ is_shared_drive: item.is_shared_drive,
183435
+ parent_id: item.parent_id,
183436
+ path: item.path,
183437
+ size: item.size,
183438
+ modified_at: item.modified_at,
183439
+ version: item.version,
183440
+ hash: item.hash
183441
+ };
183442
+ const data = Buffer.from(JSON.stringify(metadata, null, 2) + `
183443
+ `);
183444
+ return {
183445
+ data: data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength),
183446
+ filename: `${item.name}.gdrive-metadata.json`,
183447
+ mimeType: "application/json"
183448
+ };
183449
+ }
183415
183450
  function toApiFile(item) {
183416
183451
  return {
183417
183452
  id: item.id,
@@ -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 = await client2.downloadFile(toApiFile(item), config9.export_formats);
163898
+ const downloaded = canDownloadDriveItem(item) ? await client2.downloadFile(toApiFile(item), config9.export_formats) : createGoogleDriveMetadataArchive(item);
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");
@@ -164151,6 +164151,41 @@ function appendDriveFileId(filename, fileId) {
164151
164151
  const base = ext ? filename.slice(0, -ext.length) : filename;
164152
164152
  return `${base} (${safePathSegment(fileId)})${ext}`;
164153
164153
  }
164154
+ function canDownloadDriveItem(item) {
164155
+ if (!item.mime.startsWith("application/vnd.google-apps."))
164156
+ return true;
164157
+ return [
164158
+ "application/vnd.google-apps.document",
164159
+ "application/vnd.google-apps.spreadsheet",
164160
+ "application/vnd.google-apps.presentation",
164161
+ "application/vnd.google-apps.drawing"
164162
+ ].includes(item.mime);
164163
+ }
164164
+ function createGoogleDriveMetadataArchive(item) {
164165
+ const metadata = {
164166
+ archived_as: "google-drive-metadata",
164167
+ reason: "Google Drive item is not exportable as file content through Drive export.",
164168
+ id: item.id,
164169
+ name: item.name,
164170
+ mime: item.mime,
164171
+ drive_id: item.drive_id,
164172
+ drive_name: item.drive_name,
164173
+ is_shared_drive: item.is_shared_drive,
164174
+ parent_id: item.parent_id,
164175
+ path: item.path,
164176
+ size: item.size,
164177
+ modified_at: item.modified_at,
164178
+ version: item.version,
164179
+ hash: item.hash
164180
+ };
164181
+ const data = Buffer.from(JSON.stringify(metadata, null, 2) + `
164182
+ `);
164183
+ return {
164184
+ data: data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength),
164185
+ filename: `${item.name}.gdrive-metadata.json`,
164186
+ mimeType: "application/json"
164187
+ };
164188
+ }
164154
164189
  function toApiFile(item) {
164155
164190
  return {
164156
164191
  id: item.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/files",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
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",