@velaro/cli 1.4.174 → 1.4.176

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/bin/velaro.js CHANGED
@@ -99,6 +99,7 @@ import { packageBuilderCommand } from '../lib/commands/package-builder.js';
99
99
  import { routingCommand } from '../lib/commands/routing.js';
100
100
  import { statusNotifyCommand } from '../lib/commands/status-notify.js';
101
101
  import { callbackCommand } from '../lib/commands/callback.js';
102
+ import { cobrowseCommand } from '../lib/commands/cobrowse.js';
102
103
  import { callpresenceCommand } from '../lib/commands/callpresence.js';
103
104
  import { authorityCommand } from '../lib/commands/authority.js';
104
105
  import { caseCommand } from '../lib/commands/case.js';
@@ -258,6 +259,8 @@ await (registerStaffCommands ? registerStaffCommands(baseYargs) : baseYargs)
258
259
  .command(routingCommand)
259
260
  .command(statusNotifyCommand)
260
261
  .command(callbackCommand)
262
+ // The staff build already registers a cobrowse group that includes seats/seat set; only the public build adds this one.
263
+ .command(registerStaffCommands ? { command: 'cobrowse-seats-in-staff-group', describe: false, builder: (y) => y, handler: () => {} } : cobrowseCommand)
261
264
  .command(callpresenceCommand)
262
265
  .command(authorityCommand)
263
266
  .command(caseCommand)
@@ -0,0 +1,54 @@
1
+ import { messagingGet, messagingPut } from '../api.js';
2
+ import { runCommand } from '../run.js';
3
+
4
+ // velaro cobrowse seats | seat set <userId> --assign|--unassign
5
+ // Co-Browse seat assignment for the signed-in site's administrators. Routes live in velaro-messaging
6
+ // (GET /CobrowseSettings/Seats, PUT /CobrowseSettings/Seats/{userId}); the site always comes from the login,
7
+ // every change lands in the Activity Log (cobrowse.seat.assign / cobrowse.seat.unassign).
8
+
9
+ export function formatSeatsReport(data) {
10
+ const lines = [];
11
+ lines.push(data.licensed ? `Co-Browse seats: ${data.used} of ${data.seatCount} in use` : 'Co-Browse is not part of this plan.');
12
+ if (data.autoAssignAll) lines.push('Every agent automatically has a seat.');
13
+ for (const a of data.agents ?? []) lines.push(` ${String(a.userId).padEnd(8)} ${a.hasSeat ? 'seat ' : 'no seat'} ${a.name ?? ''}`);
14
+ return lines.join('\n');
15
+ }
16
+
17
+ export function resolveAssigned(argv) {
18
+ if (argv.assign && argv.unassign) throw new Error('Pass only one of --assign or --unassign');
19
+ if (!argv.assign && !argv.unassign) throw new Error('Pass --assign or --unassign');
20
+ return Boolean(argv.assign);
21
+ }
22
+
23
+ /** Subcommands shared by the public CLI and the staff build (which also has its own cobrowse group). */
24
+ export const seatsCommand = {
25
+ command: 'seats',
26
+ describe: 'Show Co-Browse seats and which agents have one',
27
+ builder: yy => yy.option('json', { type: 'boolean', describe: 'Print raw JSON' }),
28
+ handler: runCommand(async argv => {
29
+ const data = await messagingGet('/CobrowseSettings/Seats');
30
+ console.log(argv.json ? JSON.stringify(data, null, 2) : formatSeatsReport(data));
31
+ }),
32
+ };
33
+
34
+ export const seatSetCommand = {
35
+ command: 'seat set <userId>',
36
+ describe: 'Give an agent a Co-Browse seat or take it away',
37
+ builder: yy => yy
38
+ .positional('userId', { type: 'number', describe: 'Agent user id (see: velaro cobrowse seats)' })
39
+ .option('assign', { type: 'boolean', describe: 'Give the agent a seat' })
40
+ .option('unassign', { type: 'boolean', describe: 'Remove the agent\'s seat' }),
41
+ handler: runCommand(async argv => {
42
+ const assigned = resolveAssigned(argv);
43
+ if (!Number.isInteger(argv.userId) || argv.userId <= 0) throw new Error('userId must be a positive whole number');
44
+ await messagingPut(`/CobrowseSettings/Seats/${argv.userId}`, { assigned });
45
+ console.log(`Agent ${argv.userId} ${assigned ? 'now has' : 'no longer has'} a Co-Browse seat.`);
46
+ }),
47
+ };
48
+
49
+ export const cobrowseCommand = {
50
+ command: 'cobrowse <subcommand>',
51
+ describe: 'Co-Browse seat assignment for your agents',
52
+ builder: y => y.command(seatsCommand).command(seatSetCommand).demandCommand(1, 'Specify a subcommand: seats, seat set').strict(),
53
+ handler: () => {},
54
+ };
@@ -0,0 +1,19 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { formatSeatsReport, resolveAssigned } from './cobrowse.js';
4
+
5
+ test('formats usage and agents', () => {
6
+ const out = formatSeatsReport({ licensed: true, seatCount: 5, used: 2, autoAssignAll: false, agents: [{ userId: 7, name: 'Ann', hasSeat: true }, { userId: 8, name: 'Bo', hasSeat: false }] });
7
+ assert.match(out, /2 of 5/);
8
+ assert.match(out, /7\s+seat\s+Ann/);
9
+ assert.match(out, /8\s+no seat\s+Bo/);
10
+ });
11
+ test('says when not licensed', () => {
12
+ assert.match(formatSeatsReport({ licensed: false, agents: [] }), /not part of this plan/);
13
+ });
14
+ test('resolves assign / unassign and rejects ambiguity', () => {
15
+ assert.equal(resolveAssigned({ assign: true }), true);
16
+ assert.equal(resolveAssigned({ unassign: true }), false);
17
+ assert.throws(() => resolveAssigned({}));
18
+ assert.throws(() => resolveAssigned({ assign: true, unassign: true }));
19
+ });
@@ -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.176",
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": {