@velaro/cli 1.4.114 → 1.4.115

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
@@ -21,6 +21,7 @@ import { deployStateCommand } from '../lib/commands/deploy-state.js';
21
21
  import { checkCommand } from '../lib/commands/check.js';
22
22
  import { logsCommand } from '../lib/commands/logs.js';
23
23
  import { aiModelsCommand } from '../lib/commands/ai-models.js';
24
+ import { reportSpeedCommand } from '../lib/commands/report-speed.js';
24
25
  import { siteCommand } from '../lib/commands/site.js';
25
26
  import { siteProvisionCommand } from '../lib/commands/site-provision.js';
26
27
  import { siteSyncCommand } from '../lib/commands/sitesync.js';
@@ -187,6 +188,7 @@ await yargs(hideBin(process.argv))
187
188
  .command(checkCommand)
188
189
  .command(logsCommand)
189
190
  .command(aiModelsCommand)
191
+ .command(reportSpeedCommand)
190
192
  .command(siteCommand)
191
193
  .command(siteProvisionCommand)
192
194
  .command(siteSyncCommand)
@@ -123,8 +123,11 @@ async function embedStatusHandler() {
123
123
  const d = r?.data ?? r;
124
124
  console.log(`\n${BOLD}NetSuite call-pop (CRM embed) status${RST}`);
125
125
  if (!d?.hasEmbedKey) { console.log(` ${DIM}No crm_embed API key set for this site.${RST}\n`); return; }
126
- if (d.connected) console.log(` ${GRN}SuiteApp connected${RST}, last polled ${d.lastPolledAt}\n`);
127
- else console.log(` ${DIM}Embed key exists; SuiteApp not connected (last polled: ${d.lastPolledAt ?? 'never'})${RST}\n`);
126
+ const who = d.lastAgentEmail ? ` by ${d.lastAgentEmail}` : '';
127
+ // "connected" = a NetSuite page polled in the last 2 minutes; an installed SuiteApp with nobody on the page is set_up_idle.
128
+ if (d.connected) console.log(` ${GRN}Connected now${RST}, last polled ${d.lastPolledAt}${who}\n`);
129
+ else if (d.lastPolledAt) console.log(` ${GRN}Set up${RST}, idle (no NetSuite page open in the last 2 minutes); last polled ${d.lastPolledAt}${who}\n`);
130
+ else console.log(` ${DIM}Key created, never used: no NetSuite page has polled with it yet${RST}\n`);
128
131
  }
129
132
 
130
133
  export const netsuiteCommand = {
@@ -0,0 +1,112 @@
1
+ import { getCredentials } from '../api.js';
2
+ import { readConfig, ENVS } from '../config.js';
3
+
4
+ // velaro report-speed: staff control of report/export speed levels (global default + per-customer override).
5
+ // Routes live in velaro-messaging (superadmin/report-speed). Docs: docs/architecture/report-speed-levels.md
6
+
7
+ const RESET = '\x1b[0m';
8
+ const DIM = '\x1b[2m';
9
+ const BOLD = '\x1b[1m';
10
+ const GREEN = '\x1b[32m';
11
+
12
+ async function getMsgBase(argv) {
13
+ const cfg = readConfig();
14
+ const env = argv.env || cfg.env || 'staging';
15
+ return cfg.envs?.[env]?.messagingApiBase ?? ENVS[env]?.messagingApiBase
16
+ ?? 'https://velaro-messaging-api-staging.azurewebsites.net';
17
+ }
18
+
19
+ async function call(argv, path, opts = {}) {
20
+ const creds = await getCredentials();
21
+ if (creds.siteId !== 1032) {
22
+ console.error('velaro report-speed is only available to Velaro staff (site 1032).');
23
+ process.exit(1);
24
+ }
25
+ const msgBase = await getMsgBase(argv);
26
+ const res = await fetch(`${msgBase}/superadmin/report-speed/${path}`, {
27
+ method: opts.method ?? 'GET',
28
+ headers: {
29
+ Authorization: `Bearer ${creds.velaroToken}`,
30
+ 'X-Internal-SiteId': String(creds.siteId),
31
+ ...(opts.body ? { 'Content-Type': 'application/json' } : {}),
32
+ },
33
+ body: opts.body ? JSON.stringify(opts.body) : undefined,
34
+ signal: AbortSignal.timeout(20000),
35
+ });
36
+ if (!res.ok) {
37
+ const body = await res.text().catch(() => '');
38
+ console.error(`HTTP ${res.status}: ${body}`);
39
+ process.exit(1);
40
+ }
41
+ return res.json();
42
+ }
43
+
44
+ export function formatReportSpeed(data) {
45
+ const e = data.effective;
46
+ const rate = e.ruPerSecond > 0 ? `${e.ruPerSecond} RU/s` : 'not paced';
47
+ const where = data.siteId
48
+ ? (data.inherited ? `inherited (${data.source})` : `overridden by ${data.overrideBy ?? 'staff'}`)
49
+ : 'global default';
50
+ const lines = [
51
+ `${BOLD}${data.siteId ? `Site ${data.siteId}` : 'Global'}${RESET}: ${e.name} ${DIM}(${where})${RESET}`,
52
+ `${DIM}Limits:${RESET} ${e.maxConcurrentJobs} job(s) at once, ${rate}, burst ${e.burstSeconds}s, page ${e.pageSize}, ${e.interPageDelayMs} ms between pages`,
53
+ `${DIM}Global default:${RESET} ${data.globalDefault}`,
54
+ `${DIM}Levels:${RESET} ${data.levels.map(l => l.key).join(', ')}`,
55
+ ];
56
+ return lines.join('\n');
57
+ }
58
+
59
+ async function getLevels(argv) {
60
+ const data = argv.site ? await call(argv, `site/${argv.site}`) : await call(argv, 'levels');
61
+ console.log(`\n${formatReportSpeed(data)}\n`);
62
+ }
63
+
64
+ async function setSite(argv) {
65
+ const level = argv.clear ? null : argv.level;
66
+ if (!argv.clear && !level) {
67
+ console.error('Give --level <economy|standard|fast|unlimited> or --clear.');
68
+ process.exit(1);
69
+ }
70
+ const data = await call(argv, `site/${argv.site}`, { method: 'PUT', body: { level, reason: argv.reason ?? null } });
71
+ console.log(`\n${GREEN}OK${RESET} ${formatReportSpeed(data)}\n`);
72
+ }
73
+
74
+ async function setDefault(argv) {
75
+ const data = await call(argv, 'default', { method: 'PUT', body: { level: argv.level, reason: argv.reason ?? null } });
76
+ console.log(`\n${GREEN}OK${RESET} ${formatReportSpeed(data)}\n`);
77
+ }
78
+
79
+ export const reportSpeedCommand = {
80
+ command: 'report-speed <subcommand>',
81
+ describe: 'Report and export speed levels: global default and per-customer override (Velaro staff only)',
82
+ builder: yargs => yargs
83
+ .command({
84
+ command: 'get',
85
+ describe: 'Show the levels table and global default, or one customer\'s effective level (--site)',
86
+ builder: y => y
87
+ .option('site', { describe: 'Customer site ID (omit for the global view)', type: 'number' })
88
+ .option('env', { describe: 'staging or prod', type: 'string' }),
89
+ handler: getLevels,
90
+ })
91
+ .command({
92
+ command: 'set',
93
+ describe: 'Set or clear (--clear) one customer\'s override, e.g. velaro report-speed set --site 1234 --level economy --reason "2-year reports"',
94
+ builder: y => y
95
+ .option('site', { describe: 'Customer site ID', type: 'number', demandOption: true })
96
+ .option('level', { describe: 'economy, standard, fast or unlimited', type: 'string', choices: ['economy', 'standard', 'fast', 'unlimited'] })
97
+ .option('clear', { describe: 'Remove the override (inherit the global default)', type: 'boolean', default: false })
98
+ .option('reason', { describe: 'Saved in the audit trail', type: 'string' })
99
+ .option('env', { describe: 'staging or prod', type: 'string' }),
100
+ handler: setSite,
101
+ })
102
+ .command({
103
+ command: 'default',
104
+ describe: 'Set the GLOBAL default level (economy, standard or fast; unlimited is internal-only)',
105
+ builder: y => y
106
+ .option('level', { describe: 'economy, standard or fast', type: 'string', choices: ['economy', 'standard', 'fast'], demandOption: true })
107
+ .option('reason', { describe: 'Saved in the audit trail', type: 'string' })
108
+ .option('env', { describe: 'staging or prod', type: 'string' }),
109
+ handler: setDefault,
110
+ })
111
+ .demandCommand(1, 'Specify a subcommand: get, set, or default'),
112
+ };
@@ -0,0 +1,26 @@
1
+ // velaro report-speed output formatting (global view and one customer's inherited / overridden level).
2
+ import test from 'node:test';
3
+ import assert from 'node:assert/strict';
4
+ import { formatReportSpeed } from './commands/report-speed.js';
5
+
6
+ const levels = ['economy', 'standard', 'fast', 'unlimited'].map(key => ({ key }));
7
+ const standard = { name: 'Standard', maxConcurrentJobs: 2, ruPerSecond: 400, burstSeconds: 5, pageSize: 500, interPageDelayMs: 50 };
8
+
9
+ test('shows an inherited customer level', () => {
10
+ const out = formatReportSpeed({ siteId: 1234, effective: standard, inherited: true, source: 'GlobalDefault', globalDefault: 'standard', levels });
11
+ assert.match(out, /Site 1234/);
12
+ assert.match(out, /inherited \(GlobalDefault\)/);
13
+ assert.match(out, /400 RU\/s/);
14
+ });
15
+
16
+ test('shows an override and who set it', () => {
17
+ const out = formatReportSpeed({ siteId: 1234, effective: { ...standard, name: 'Economy', ruPerSecond: 100 }, inherited: false, overrideBy: 'alex@velaro.com', globalDefault: 'standard', levels });
18
+ assert.match(out, /overridden by alex@velaro.com/);
19
+ });
20
+
21
+ test('unpaced level says so, global view says global default', () => {
22
+ const out = formatReportSpeed({ siteId: 0, effective: { ...standard, name: 'Unlimited (internal)', ruPerSecond: 0 }, inherited: true, globalDefault: 'standard', levels });
23
+ assert.match(out, /not paced/);
24
+ assert.match(out, /Global/);
25
+ assert.match(out, /global default/);
26
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.114",
3
+ "version": "1.4.115",
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": {