@velaro/cli 1.4.174 → 1.4.175

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.
@@ -824,6 +824,87 @@ const customRunCommand = {
824
824
  handler: runCommand(customRunHandler),
825
825
  };
826
826
 
827
+ // ── report range policy: long ranges are emailed as a link (ReportRangeController) ─────────────
828
+ // Backend: server/Velaro.Admin/Controllers/ReportRangeController.cs (docs/architecture/long-range-emailed-links.md)
829
+ // GET ReportRange/range-policy?start&end -> ReportRangeController.GetRangePolicy: what a range will do, before running it
830
+ // POST ReportRange/export -> ReportRangeController.StartRangeExport: 202 { exportId, deliverTo } over the limit, 200 inline otherwise
831
+ // Dates are yyyy-MM-dd inclusive Pacific days (or ISO instants, end exclusive). The server owns every limit; nothing is computed here.
832
+
833
+ function printWindow(r) {
834
+ fmtRow('Mode', r.mode === 'EmailLink' ? 'Emailed as a link' : 'On screen / inline');
835
+ fmtRow('Window', `${r.effectiveStartDay} to ${r.effectiveLastDay} (${r.timeZone})`);
836
+ fmtRow('Days', `${r.effectiveDays} (asked for ${r.requestedDays})`);
837
+ fmtRow('Limit', `${r.inlineLimitDays} days${r.thresholdLifted ? ' (raised by your package)' : ''}`);
838
+ if (r.retentionDays) fmtRow('Data kept', `${r.retentionDays} days`);
839
+ fmtRow('Shortened', r.clampedToRetention ? 'yes, to the data your account keeps' : (r.clampedToMaximum ? 'yes, to the maximum for one report' : 'no'));
840
+ if (r.notice) fmtRow('Note', r.notice);
841
+ if (r.defaultRecipient) fmtRow('Default email', r.defaultRecipient);
842
+ }
843
+
844
+ // GET ReportRange/range-policy -> ReportRangeController.GetRangePolicy
845
+ async function rangePolicyHandler(argv) {
846
+ const q = new URLSearchParams();
847
+ if (argv.start) q.set('start', argv.start);
848
+ if (argv.end) q.set('end', argv.end);
849
+ if (argv.inlineMaxDays) q.set('inlineMaxDays', String(argv.inlineMaxDays));
850
+ const r = await request('GET', `ReportRange/range-policy${q.toString() ? '?' + q : ''}`);
851
+ if (argv.json) { console.log(JSON.stringify(r, null, 2)); return; }
852
+ section('Report range');
853
+ printWindow(r);
854
+ console.log('');
855
+ }
856
+
857
+ // POST ReportRange/export -> ReportRangeController.StartRangeExport
858
+ async function longRangeHandler(argv) {
859
+ const options = {};
860
+ for (const kv of [].concat(argv.option || [])) {
861
+ const i = String(kv).indexOf('=');
862
+ if (i < 1) throw new Error(`--option must look like name=value (got "${kv}")`);
863
+ options[String(kv).slice(0, i)] = String(kv).slice(i + 1);
864
+ }
865
+ const r = await request('POST', 'ReportRange/export', {
866
+ reportType: argv.type,
867
+ startDate: argv.start,
868
+ endDate: argv.end,
869
+ format: argv.format,
870
+ deliverTo: argv.to,
871
+ options: Object.keys(options).length ? options : undefined,
872
+ });
873
+ if (argv.json) { console.log(JSON.stringify(r, null, 2)); return; }
874
+ if (r.mode === 'Inline') {
875
+ console.log(`\n${r.message}\n`);
876
+ return;
877
+ }
878
+ console.log(`\nExport queued (id ${r.exportId}). ${r.message}`);
879
+ if (r.notice?.message) console.log(`Note: ${r.notice.message}`);
880
+ console.log(`Check progress: velaro report export status ${r.exportId}\n`);
881
+ }
882
+
883
+ const rangePolicyCommand = {
884
+ command: 'range-policy',
885
+ describe: 'Show what a date range will do before you run it: shortened to the data your account keeps, and on screen or emailed as a link',
886
+ builder: (y) => y
887
+ .option('start', { type: 'string', describe: 'Start date (YYYY-MM-DD, Pacific). Default: 30 days ago' })
888
+ .option('end', { type: 'string', describe: 'End date (YYYY-MM-DD, Pacific, inclusive). Default: today' })
889
+ .option('inline-max-days', { type: 'number', describe: 'Lower the limit to what the report can show on screen' })
890
+ .option('json', { type: 'boolean', describe: 'Print the raw response' }),
891
+ handler: runCommand(rangePolicyHandler),
892
+ };
893
+
894
+ const longRangeCommand = {
895
+ command: 'long-range',
896
+ describe: 'Email a long-range report as a download link (ranges over the limit are built in the background; shorter ranges are not queued)',
897
+ builder: (y) => y
898
+ .option('type', { type: 'string', demandOption: true, describe: 'Report type, e.g. conversations' })
899
+ .option('start', { type: 'string', demandOption: true, describe: 'Start date (YYYY-MM-DD, Pacific)' })
900
+ .option('end', { type: 'string', demandOption: true, describe: 'End date (YYYY-MM-DD, Pacific, inclusive)' })
901
+ .option('format', { type: 'string', choices: ['xlsx', 'csv'], describe: 'Output format (default xlsx)' })
902
+ .option('to', { type: 'string', describe: 'Email address for the link (default: your own email)' })
903
+ .option('option', { type: 'string', array: true, describe: 'Report option as name=value, e.g. teamId=3 (repeatable)' })
904
+ .option('json', { type: 'boolean', describe: 'Print the raw response' }),
905
+ handler: runCommand(longRangeHandler),
906
+ };
907
+
827
908
  // ── top-level report command ──────────────────────────────────────────────────
828
909
 
829
910
  export const reportCommand = {
@@ -838,6 +919,8 @@ export const reportCommand = {
838
919
  .command(visitorTrafficCommand)
839
920
  .command(schedulesCommand)
840
921
  .command(exportCommand)
922
+ .command(rangePolicyCommand)
923
+ .command(longRangeCommand)
841
924
  .command(countryCommand)
842
925
  .command(customCatalogCommand)
843
926
  .command(customRunCommand)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.174",
3
+ "version": "1.4.175",
4
4
  "description": "Velaro Workspace v20 — command-line interface for managing bots, knowledge base ingestion, MCP API keys, search indexes, and ops health.",
5
5
  "type": "module",
6
6
  "bin": {