@arbidocs/cli 0.3.30 → 0.3.31

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.3.31
4
+
5
+ [compare changes](https://github.com/arbicity/ARBI-frontend/compare/v0.3.30...HEAD)
6
+
7
+ ### 🚀 Enhancements
8
+
9
+ - **cli:** --interval for reprocess batches, --output for docs export ([#574](https://github.com/arbicity/ARBI-frontend/pull/574))
10
+
11
+ ### 🔥 Performance
12
+
13
+ - Instant workspace click feedback + bulk reprocess cap ([#573](https://github.com/arbicity/ARBI-frontend/pull/573))
14
+
3
15
  ## v0.3.30
4
16
 
5
17
  [compare changes](https://github.com/arbicity/ARBI-frontend/compare/v0.3.29...HEAD)
package/dist/index.js CHANGED
@@ -3637,7 +3637,7 @@ function getLatestVersion(skipCache = false) {
3637
3637
  }
3638
3638
  }
3639
3639
  function getCurrentVersion() {
3640
- return "0.3.30";
3640
+ return "0.3.31";
3641
3641
  }
3642
3642
  function readChangelog(fromVersion, toVersion) {
3643
3643
  try {
@@ -3690,17 +3690,17 @@ function showChangelog(fromVersion, toVersion) {
3690
3690
  async function checkForUpdates(autoUpdate) {
3691
3691
  try {
3692
3692
  const latest = getLatestVersion();
3693
- if (!latest || latest === "0.3.30") return;
3693
+ if (!latest || latest === "0.3.31") return;
3694
3694
  if (autoUpdate) {
3695
3695
  warn(`
3696
- Your arbi version is out of date (${"0.3.30"} \u2192 ${latest}). Updating...`);
3696
+ Your arbi version is out of date (${"0.3.31"} \u2192 ${latest}). Updating...`);
3697
3697
  child_process.execSync("npm install -g @arbidocs/cli@latest", { stdio: "inherit" });
3698
- showChangelog("0.3.30", latest);
3698
+ showChangelog("0.3.31", latest);
3699
3699
  console.log(`Updated to ${latest}.`);
3700
3700
  } else {
3701
3701
  warn(
3702
3702
  `
3703
- Your arbi version is out of date (${"0.3.30"} \u2192 ${latest}).
3703
+ Your arbi version is out of date (${"0.3.31"} \u2192 ${latest}).
3704
3704
  Run "arbi update" to upgrade, or "arbi update auto" to always stay up to date.`
3705
3705
  );
3706
3706
  }
@@ -3710,9 +3710,9 @@ Run "arbi update" to upgrade, or "arbi update auto" to always stay up to date.`
3710
3710
  function hintUpdateOnError() {
3711
3711
  try {
3712
3712
  const cached = readCache();
3713
- if (cached && cached.latest !== "0.3.30") {
3713
+ if (cached && cached.latest !== "0.3.31") {
3714
3714
  warn(
3715
- `Your arbi version is out of date (${"0.3.30"} \u2192 ${cached.latest}). Run "arbi update".`
3715
+ `Your arbi version is out of date (${"0.3.31"} \u2192 ${cached.latest}). Run "arbi update".`
3716
3716
  );
3717
3717
  }
3718
3718
  } catch {
@@ -4669,7 +4669,10 @@ async function fetchDocChoices(arbi, _workspaceId) {
4669
4669
  }));
4670
4670
  }
4671
4671
  function registerDocsCommand(program2) {
4672
- program2.command("docs").description("List documents in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").option("--json", "Output as JSON").option("--csv", "Output as CSV").option("--ids", "Output only document IDs (one per line)").option("--count", "Output only the count (combine with --status for filtered count)").option("-s, --status <status>", "Filter by status (comma-separated: completed,failed,queued)").option("-f, --folder <pattern>", "Filter by folder (substring match)").option("-e, --ext <extensions>", "Filter by file extension (comma-separated: pdf,docx,eml)").option("-q, --query <text>", "Search file name, title, or summary").option("--sort <field>", "Sort by field (name, status, date, size, created)", "status").option("-n, --limit <n>", "Limit number of results").action(
4672
+ program2.command("docs").description("List documents in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").option("--json", "Output as JSON").option("--csv", "Output as CSV").option("--ids", "Output only document IDs (one per line)").option("--count", "Output only the count (combine with --status for filtered count)").option("-s, --status <status>", "Filter by status (comma-separated: completed,failed,queued)").option("-f, --folder <pattern>", "Filter by folder (substring match)").option("-e, --ext <extensions>", "Filter by file extension (comma-separated: pdf,docx,eml)").option("-q, --query <text>", "Search file name, title, or summary").option("--sort <field>", "Sort by field (name, status, date, size, created)", "status").option("-n, --limit <n>", "Limit number of results").option(
4673
+ "-o, --output <path>",
4674
+ "Write output to a file instead of stdout. Extension determines the format when combined with --ids/--json/--csv (default: csv with doc_id, file_name, folder, status)"
4675
+ ).action(
4673
4676
  (opts) => runAction(async () => {
4674
4677
  const { arbi } = await resolveWorkspace(opts.workspace);
4675
4678
  let data = await sdk.documents.listDocuments(arbi);
@@ -4723,20 +4726,30 @@ function registerDocsCommand(program2) {
4723
4726
  }
4724
4727
  return;
4725
4728
  }
4729
+ const writeOut = (payload, defaultExt) => {
4730
+ if (opts.output) {
4731
+ fs4.writeFileSync(opts.output, payload.endsWith("\n") ? payload : payload + "\n");
4732
+ success(`Wrote ${data.length} rows to ${opts.output} (${defaultExt})`);
4733
+ } else {
4734
+ console.log(payload.endsWith("\n") ? payload.slice(0, -1) : payload);
4735
+ }
4736
+ };
4737
+ const csvEscape = (s) => `"${(s ?? "").replace(/"/g, '""')}"`;
4726
4738
  if (opts.ids) {
4727
- data.forEach((d) => console.log(d.external_id));
4739
+ writeOut(data.map((d) => d.external_id).join("\n"), "ids");
4728
4740
  return;
4729
4741
  }
4730
4742
  if (opts.json) {
4731
- console.log(JSON.stringify(data));
4743
+ writeOut(JSON.stringify(data, null, opts.output ? 2 : 0), "json");
4732
4744
  return;
4733
4745
  }
4734
- if (opts.csv) {
4735
- console.log("external_id,status,file_name,file_size,folder,n_pages,tokens,doc_date,title");
4746
+ if (opts.csv || opts.output && !opts.ids && !opts.json) {
4747
+ const lines = [
4748
+ "external_id,status,file_name,file_size,folder,n_pages,tokens,doc_date,title"
4749
+ ];
4736
4750
  for (const d of data) {
4737
4751
  const meta = d.doc_metadata;
4738
- const csvEscape = (s) => `"${(s ?? "").replace(/"/g, '""')}"`;
4739
- console.log(
4752
+ lines.push(
4740
4753
  [
4741
4754
  d.external_id,
4742
4755
  d.status,
@@ -4750,6 +4763,7 @@ function registerDocsCommand(program2) {
4750
4763
  ].join(",")
4751
4764
  );
4752
4765
  }
4766
+ writeOut(lines.join("\n"), "csv");
4753
4767
  return;
4754
4768
  }
4755
4769
  console.log(chalk2__default.default.dim(`${data.length} documents
@@ -4916,7 +4930,11 @@ function registerDocsCommand(program2) {
4916
4930
  console.log(JSON.stringify(data, null, 2));
4917
4931
  })()
4918
4932
  );
4919
- doc.command("reprocess [ids...]").description("Reprocess failed/completed documents (sets status back to processing)").option("-s, --status <status>", "Reprocess all docs with this status (e.g. failed)").option("-f, --folder <pattern>", "Filter by folder (substring match)").option("--dry-run", "Show what would be reprocessed without doing it").option("-b, --batch-size <n>", "Batch size for update requests", "50").action(
4933
+ doc.command("reprocess [ids...]").description("Reprocess failed/completed documents (sets status back to processing)").option("-s, --status <status>", "Reprocess all docs with this status (e.g. failed)").option("-f, --folder <pattern>", "Filter by folder (substring match)").option("--dry-run", "Show what would be reprocessed without doing it").option("-b, --batch-size <n>", "Batch size for update requests", "50").option(
4934
+ "-i, --interval <seconds>",
4935
+ "Seconds to wait between batches (float allowed, e.g. 0.5). Default 0 \u2014 send as fast as the server acks.",
4936
+ "0"
4937
+ ).action(
4920
4938
  (ids, opts) => runAction(async () => {
4921
4939
  const { arbi } = await resolveWorkspace();
4922
4940
  let docIds;
@@ -4948,6 +4966,8 @@ function registerDocsCommand(program2) {
4948
4966
  return;
4949
4967
  }
4950
4968
  const batchSize = parseInt(opts.batchSize ?? "50", 10);
4969
+ const intervalSec = parseFloat(opts.interval ?? "0");
4970
+ const intervalMs = Number.isFinite(intervalSec) && intervalSec > 0 ? intervalSec * 1e3 : 0;
4951
4971
  let processed = 0;
4952
4972
  for (let i = 0; i < docIds.length; i += batchSize) {
4953
4973
  const batch = docIds.slice(i, i + batchSize);
@@ -4958,6 +4978,9 @@ function registerDocsCommand(program2) {
4958
4978
  );
4959
4979
  processed += batch.length;
4960
4980
  console.log(` [${processed}/${docIds.length}] Triggered reprocessing...`);
4981
+ if (intervalMs > 0 && i + batchSize < docIds.length) {
4982
+ await new Promise((resolve3) => setTimeout(resolve3, intervalMs));
4983
+ }
4961
4984
  }
4962
4985
  success(`Triggered reprocessing for ${docIds.length} document(s).`);
4963
4986
  })()
@@ -7745,7 +7768,7 @@ console.info = (...args) => {
7745
7768
  _origInfo(...args);
7746
7769
  };
7747
7770
  var program = new commander.Command();
7748
- program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.3.30");
7771
+ program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.3.31");
7749
7772
  registerConfigCommand(program);
7750
7773
  registerLoginCommand(program);
7751
7774
  registerRegisterCommand(program);