@hasna/files 0.2.21 → 0.2.23

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
@@ -167800,7 +167800,7 @@ async function syncGoogleDriveSource(source) {
167800
167800
  seen.push({ drive_id: item.drive_id, file_id: item.id });
167801
167801
  try {
167802
167802
  const existing = getGoogleDriveImportedObject(source.id, item.drive_id, item.id);
167803
- if (existing && !shouldImport(config9, item, existing, destination.source.id, destination.storage_type))
167803
+ if (existing && !shouldImport(config9, item, existing, destination.source, destination.storage_type))
167804
167804
  continue;
167805
167805
  const importResult = await importGoogleDriveItem(client2, item, config9, destination.source, destination.storage_type);
167806
167806
  const fileRecord = upsertFile({
@@ -168095,8 +168095,10 @@ function escapeDriveQueryValue(value) {
168095
168095
  function buildStorageKey(source, importedPath) {
168096
168096
  return source.prefix ? posix.join(source.prefix, importedPath) : importedPath;
168097
168097
  }
168098
- function shouldImport(config9, item, existing, destinationSourceId, storageType) {
168099
- return existing.path !== buildImportedPath(config9, item, existing.name) || existing.hash !== item.hash || existing.modified_at !== item.modified_at || existing.version !== item.version || existing.destination_source_id !== destinationSourceId || existing.storage_type !== storageType || existing.deleted;
168098
+ function shouldImport(config9, item, existing, destinationSource, storageType) {
168099
+ const importedPath = buildImportedPath(config9, item, existing.name);
168100
+ const storageKey = storageType === "s3" || storageType === "local" ? buildStorageKey(destinationSource, importedPath) : importedPath;
168101
+ return existing.path !== importedPath || existing.hash !== item.hash || existing.modified_at !== item.modified_at || existing.version !== item.version || existing.destination_source_id !== destinationSource.id || existing.storage_type !== storageType || existing.storage_key !== storageKey || existing.deleted;
168100
168102
  }
168101
168103
  function buildImportedPath(config9, item, importedName) {
168102
168104
  if (config9.path_mode === "id_based") {
@@ -168344,7 +168346,8 @@ sources.command("bootstrap-prod-files").description("Create or update the produc
168344
168346
  const activeDriveDestinationIds = new Set(allSources.filter((source2) => source2.enabled && source2.type === "google_drive").map((source2) => source2.config.destination_source_id).filter((id) => Boolean(id)));
168345
168347
  const configuredDefaultId = loadConfig().google_drive_default_destination_source_id;
168346
168348
  const candidates = allSources.filter((source2) => source2.type === "s3" && (legacyProductionNames.has(source2.name) || legacyProductionBuckets.has(source2.bucket ?? "")));
168347
- const existing = candidates.find((source2) => activeDriveDestinationIds.has(source2.id)) ?? candidates.find((source2) => configuredDefaultId === source2.id) ?? candidates.find((source2) => source2.enabled) ?? candidates[0];
168349
+ const existing = candidates.find((source2) => activeDriveDestinationIds.has(source2.id) && source2.enabled) ?? candidates.find((source2) => configuredDefaultId === source2.id && source2.enabled) ?? candidates.find((source2) => source2.enabled && source2.bucket === opts.bucket) ?? candidates.find((source2) => source2.enabled) ?? candidates.find((source2) => configuredDefaultId === source2.id) ?? candidates.find((source2) => activeDriveDestinationIds.has(source2.id)) ?? candidates[0];
168350
+ const candidateIds = new Set(candidates.map((source2) => source2.id));
168348
168351
  const source = existing ? updateSource(existing.id, {
168349
168352
  name: opts.name,
168350
168353
  bucket: opts.bucket,
@@ -168361,13 +168364,36 @@ sources.command("bootstrap-prod-files").description("Create or update the produc
168361
168364
  config: config9,
168362
168365
  machine_id: machine.id
168363
168366
  });
168367
+ const updatedGoogleDriveSourceIds = [];
168368
+ for (const driveSource of allSources.filter((source2) => source2.type === "google_drive")) {
168369
+ const driveConfig = driveSource.config;
168370
+ const shouldRepairDestination = !driveConfig.destination_source_id || candidateIds.has(driveConfig.destination_source_id);
168371
+ if (!shouldRepairDestination || driveConfig.destination_source_id === source.id)
168372
+ continue;
168373
+ updateSource(driveSource.id, {
168374
+ config: {
168375
+ ...driveConfig,
168376
+ destination_source_id: source.id
168377
+ }
168378
+ });
168379
+ updatedGoogleDriveSourceIds.push(driveSource.id);
168380
+ }
168381
+ const disabledLegacySourceIds = [];
168382
+ for (const candidate of candidates) {
168383
+ if (candidate.id === source.id || !candidate.enabled)
168384
+ continue;
168385
+ updateSource(candidate.id, { enabled: false });
168386
+ disabledLegacySourceIds.push(candidate.id);
168387
+ }
168364
168388
  if (opts.googleDriveDefault !== false) {
168365
168389
  setConfigValue("google_drive_default_destination_source_id", source.id);
168366
168390
  }
168367
168391
  if (opts.json) {
168368
168392
  console.log(JSON.stringify({
168369
168393
  source,
168370
- google_drive_default_destination_source_id: opts.googleDriveDefault === false ? undefined : source.id
168394
+ google_drive_default_destination_source_id: opts.googleDriveDefault === false ? undefined : source.id,
168395
+ updated_google_drive_source_ids: updatedGoogleDriveSourceIds,
168396
+ disabled_legacy_source_ids: disabledLegacySourceIds
168371
168397
  }, null, 2));
168372
168398
  return;
168373
168399
  }
@@ -168377,6 +168403,12 @@ sources.command("bootstrap-prod-files").description("Create or update the produc
168377
168403
  if (opts.googleDriveDefault !== false) {
168378
168404
  console.log(chalk.dim(" Google Drive default destination: set"));
168379
168405
  }
168406
+ if (updatedGoogleDriveSourceIds.length) {
168407
+ console.log(chalk.dim(` Google Drive sources repaired: ${updatedGoogleDriveSourceIds.join(", ")}`));
168408
+ }
168409
+ if (disabledLegacySourceIds.length) {
168410
+ console.log(chalk.dim(` Legacy S3 sources disabled: ${disabledLegacySourceIds.join(", ")}`));
168411
+ }
168380
168412
  });
168381
168413
  sources.command("google-drive-profiles").description("List Google Drive profiles available through connectors auth").option("--json", "Output as JSON").action(async (opts) => {
168382
168414
  const profiles = await listGoogleDriveProfiles();
package/dist/index.js CHANGED
@@ -164393,7 +164393,7 @@ async function syncGoogleDriveSource(source) {
164393
164393
  seen.push({ drive_id: item.drive_id, file_id: item.id });
164394
164394
  try {
164395
164395
  const existing = getGoogleDriveImportedObject(source.id, item.drive_id, item.id);
164396
- if (existing && !shouldImport(config9, item, existing, destination.source.id, destination.storage_type))
164396
+ if (existing && !shouldImport(config9, item, existing, destination.source, destination.storage_type))
164397
164397
  continue;
164398
164398
  const importResult = await importGoogleDriveItem(client2, item, config9, destination.source, destination.storage_type);
164399
164399
  const fileRecord = upsertFile({
@@ -164688,8 +164688,10 @@ function escapeDriveQueryValue(value) {
164688
164688
  function buildStorageKey(source, importedPath) {
164689
164689
  return source.prefix ? posix.join(source.prefix, importedPath) : importedPath;
164690
164690
  }
164691
- function shouldImport(config9, item, existing, destinationSourceId, storageType) {
164692
- return existing.path !== buildImportedPath(config9, item, existing.name) || existing.hash !== item.hash || existing.modified_at !== item.modified_at || existing.version !== item.version || existing.destination_source_id !== destinationSourceId || existing.storage_type !== storageType || existing.deleted;
164691
+ function shouldImport(config9, item, existing, destinationSource, storageType) {
164692
+ const importedPath = buildImportedPath(config9, item, existing.name);
164693
+ const storageKey = storageType === "s3" || storageType === "local" ? buildStorageKey(destinationSource, importedPath) : importedPath;
164694
+ return existing.path !== importedPath || existing.hash !== item.hash || existing.modified_at !== item.modified_at || existing.version !== item.version || existing.destination_source_id !== destinationSource.id || existing.storage_type !== storageType || existing.storage_key !== storageKey || existing.deleted;
164693
164695
  }
164694
164696
  function buildImportedPath(config9, item, importedName) {
164695
164697
  if (config9.path_mode === "id_based") {
package/dist/mcp/index.js CHANGED
@@ -183324,7 +183324,7 @@ async function syncGoogleDriveSource(source) {
183324
183324
  seen.push({ drive_id: item.drive_id, file_id: item.id });
183325
183325
  try {
183326
183326
  const existing = getGoogleDriveImportedObject(source.id, item.drive_id, item.id);
183327
- if (existing && !shouldImport(config9, item, existing, destination.source.id, destination.storage_type))
183327
+ if (existing && !shouldImport(config9, item, existing, destination.source, destination.storage_type))
183328
183328
  continue;
183329
183329
  const importResult = await importGoogleDriveItem(client2, item, config9, destination.source, destination.storage_type);
183330
183330
  const fileRecord = upsertFile({
@@ -183619,8 +183619,10 @@ function escapeDriveQueryValue(value) {
183619
183619
  function buildStorageKey(source, importedPath) {
183620
183620
  return source.prefix ? posix.join(source.prefix, importedPath) : importedPath;
183621
183621
  }
183622
- function shouldImport(config9, item, existing, destinationSourceId, storageType) {
183623
- return existing.path !== buildImportedPath(config9, item, existing.name) || existing.hash !== item.hash || existing.modified_at !== item.modified_at || existing.version !== item.version || existing.destination_source_id !== destinationSourceId || existing.storage_type !== storageType || existing.deleted;
183622
+ function shouldImport(config9, item, existing, destinationSource, storageType) {
183623
+ const importedPath = buildImportedPath(config9, item, existing.name);
183624
+ const storageKey = storageType === "s3" || storageType === "local" ? buildStorageKey(destinationSource, importedPath) : importedPath;
183625
+ return existing.path !== importedPath || existing.hash !== item.hash || existing.modified_at !== item.modified_at || existing.version !== item.version || existing.destination_source_id !== destinationSource.id || existing.storage_type !== storageType || existing.storage_key !== storageKey || existing.deleted;
183624
183626
  }
183625
183627
  function buildImportedPath(config9, item, importedName) {
183626
183628
  if (config9.path_mode === "id_based") {
@@ -164080,7 +164080,7 @@ async function syncGoogleDriveSource(source) {
164080
164080
  seen.push({ drive_id: item.drive_id, file_id: item.id });
164081
164081
  try {
164082
164082
  const existing = getGoogleDriveImportedObject(source.id, item.drive_id, item.id);
164083
- if (existing && !shouldImport(config9, item, existing, destination.source.id, destination.storage_type))
164083
+ if (existing && !shouldImport(config9, item, existing, destination.source, destination.storage_type))
164084
164084
  continue;
164085
164085
  const importResult = await importGoogleDriveItem(client2, item, config9, destination.source, destination.storage_type);
164086
164086
  const fileRecord = upsertFile({
@@ -164358,8 +164358,10 @@ function escapeDriveQueryValue(value) {
164358
164358
  function buildStorageKey(source, importedPath) {
164359
164359
  return source.prefix ? posix.join(source.prefix, importedPath) : importedPath;
164360
164360
  }
164361
- function shouldImport(config9, item, existing, destinationSourceId, storageType) {
164362
- return existing.path !== buildImportedPath(config9, item, existing.name) || existing.hash !== item.hash || existing.modified_at !== item.modified_at || existing.version !== item.version || existing.destination_source_id !== destinationSourceId || existing.storage_type !== storageType || existing.deleted;
164361
+ function shouldImport(config9, item, existing, destinationSource, storageType) {
164362
+ const importedPath = buildImportedPath(config9, item, existing.name);
164363
+ const storageKey = storageType === "s3" || storageType === "local" ? buildStorageKey(destinationSource, importedPath) : importedPath;
164364
+ return existing.path !== importedPath || existing.hash !== item.hash || existing.modified_at !== item.modified_at || existing.version !== item.version || existing.destination_source_id !== destinationSource.id || existing.storage_type !== storageType || existing.storage_key !== storageKey || existing.deleted;
164363
164365
  }
164364
164366
  function buildImportedPath(config9, item, importedName) {
164365
164367
  if (config9.path_mode === "id_based") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/files",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
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",