@hasna/files 0.2.20 → 0.2.22

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.
Files changed (2) hide show
  1. package/dist/cli/index.js +36 -2
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -168340,7 +168340,12 @@ sources.command("bootstrap-prod-files").description("Create or update the produc
168340
168340
  const config9 = { profile: opts.awsProfile };
168341
168341
  const legacyProductionNames = new Set([opts.name, "prod-files"]);
168342
168342
  const legacyProductionBuckets = new Set([opts.bucket, "hasna-xyz-prod-files", "hasna-prod-files"]);
168343
- const existing = listSources().find((source2) => source2.type === "s3" && (legacyProductionNames.has(source2.name) || legacyProductionBuckets.has(source2.bucket ?? "")));
168343
+ const allSources = listSources();
168344
+ 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
+ const configuredDefaultId = loadConfig().google_drive_default_destination_source_id;
168346
+ 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) && 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];
168348
+ const candidateIds = new Set(candidates.map((source2) => source2.id));
168344
168349
  const source = existing ? updateSource(existing.id, {
168345
168350
  name: opts.name,
168346
168351
  bucket: opts.bucket,
@@ -168357,13 +168362,36 @@ sources.command("bootstrap-prod-files").description("Create or update the produc
168357
168362
  config: config9,
168358
168363
  machine_id: machine.id
168359
168364
  });
168365
+ const updatedGoogleDriveSourceIds = [];
168366
+ for (const driveSource of allSources.filter((source2) => source2.type === "google_drive")) {
168367
+ const driveConfig = driveSource.config;
168368
+ const shouldRepairDestination = !driveConfig.destination_source_id || candidateIds.has(driveConfig.destination_source_id);
168369
+ if (!shouldRepairDestination || driveConfig.destination_source_id === source.id)
168370
+ continue;
168371
+ updateSource(driveSource.id, {
168372
+ config: {
168373
+ ...driveConfig,
168374
+ destination_source_id: source.id
168375
+ }
168376
+ });
168377
+ updatedGoogleDriveSourceIds.push(driveSource.id);
168378
+ }
168379
+ const disabledLegacySourceIds = [];
168380
+ for (const candidate of candidates) {
168381
+ if (candidate.id === source.id || !candidate.enabled)
168382
+ continue;
168383
+ updateSource(candidate.id, { enabled: false });
168384
+ disabledLegacySourceIds.push(candidate.id);
168385
+ }
168360
168386
  if (opts.googleDriveDefault !== false) {
168361
168387
  setConfigValue("google_drive_default_destination_source_id", source.id);
168362
168388
  }
168363
168389
  if (opts.json) {
168364
168390
  console.log(JSON.stringify({
168365
168391
  source,
168366
- google_drive_default_destination_source_id: opts.googleDriveDefault === false ? undefined : source.id
168392
+ google_drive_default_destination_source_id: opts.googleDriveDefault === false ? undefined : source.id,
168393
+ updated_google_drive_source_ids: updatedGoogleDriveSourceIds,
168394
+ disabled_legacy_source_ids: disabledLegacySourceIds
168367
168395
  }, null, 2));
168368
168396
  return;
168369
168397
  }
@@ -168373,6 +168401,12 @@ sources.command("bootstrap-prod-files").description("Create or update the produc
168373
168401
  if (opts.googleDriveDefault !== false) {
168374
168402
  console.log(chalk.dim(" Google Drive default destination: set"));
168375
168403
  }
168404
+ if (updatedGoogleDriveSourceIds.length) {
168405
+ console.log(chalk.dim(` Google Drive sources repaired: ${updatedGoogleDriveSourceIds.join(", ")}`));
168406
+ }
168407
+ if (disabledLegacySourceIds.length) {
168408
+ console.log(chalk.dim(` Legacy S3 sources disabled: ${disabledLegacySourceIds.join(", ")}`));
168409
+ }
168376
168410
  });
168377
168411
  sources.command("google-drive-profiles").description("List Google Drive profiles available through connectors auth").option("--json", "Output as JSON").action(async (opts) => {
168378
168412
  const profiles = await listGoogleDriveProfiles();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/files",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
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",