@velaro/cli 1.4.113 → 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)
@@ -108,6 +108,33 @@ async function setOverride(args) {
108
108
  console.log(`✅ Site ${args.site}: ${args.key} = ${value}${args.reason ? ` (${args.reason})` : ''}`);
109
109
  }
110
110
 
111
+ async function getLimits(args) {
112
+ const r = await request('GET', `Entitlements/admin/limits/${args.site}`);
113
+ console.log(`
114
+ Site ${r.siteId} numeric limits (missing = no limit)${r.packageLookupFailed ? ' -- PACKAGE LOOKUP FAILED, overrides only' : ''}`);
115
+ for (const k of (r.definitions && r.definitions.keys) || []) {
116
+ console.log(` ${k}: ${r.limits && r.limits[k] != null ? r.limits[k] : 'no limit'}`);
117
+ }
118
+ if ((r.heldPackages || []).length) console.log(`Held packages: ${r.heldPackages.map(h => `${h.slug}=${h.value ?? 'none'}`).join(', ')}`);
119
+ if ((r.overrides || []).length) console.log(`Overrides: ${r.overrides.map(o => `${o.limitKey}=${o.value}${o.reason ? ` (${o.reason})` : ''}`).join(', ')}`);
120
+ console.log('');
121
+ }
122
+
123
+ async function setLimit(args) {
124
+ const value = Number(args.value);
125
+ if (!Number.isInteger(value) || value < 1) {
126
+ console.error('Usage: velaro entitlement set-limit --site 1032 --key email.transactional.monthly --value 20000 [--reason "Holiday volume"]');
127
+ process.exit(1);
128
+ }
129
+ const r = await request('PUT', `Entitlements/admin/limit-override/${args.site}`, { limitKey: args.key, value, reason: args.reason });
130
+ console.log(`Site ${args.site}: ${r.limitKey} ${r.previous ?? 'package value'} -> ${r.value}`);
131
+ }
132
+
133
+ async function removeLimit(args) {
134
+ await request('DELETE', `Entitlements/admin/limit-override/${args.site}/${encodeURIComponent(args.key)}`);
135
+ console.log(`Removed the ${args.key} override on site ${args.site}; it uses its package value again.`);
136
+ }
137
+
111
138
  async function seed() {
112
139
  const result = await request('POST', 'Entitlements/admin/seed');
113
140
  console.log(`✅ ${result.message}`);
@@ -283,6 +310,19 @@ export function entitlementCommand(yargs) {
283
310
  .option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
284
311
  .option('key', { type: 'string', demandOption: true, desc: 'Feature key to un-override' })
285
312
  , a => removeOverride(a))
313
+ .command('limits', 'Show the numeric limits of a site (e.g. ACS email send limits), the packages they come from and any overrides', y => y
314
+ .option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
315
+ , a => getLimits(a))
316
+ .command('set-limit', 'Override one numeric limit for a site (applied after the package value)', y => y
317
+ .option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
318
+ .option('key', { type: 'string', demandOption: true, desc: 'email.transactional.monthly | email.transactional.per_minute | email.campaign.monthly | email.campaign.per_minute' })
319
+ .option('value', { type: 'number', demandOption: true, desc: 'Whole number >= 1' })
320
+ .option('reason', { type: 'string', desc: 'Why (recorded)' })
321
+ , a => setLimit(a))
322
+ .command('remove-limit', 'Remove a per-site numeric limit override (back to the package value)', y => y
323
+ .option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
324
+ .option('key', { type: 'string', demandOption: true, desc: 'Limit key to un-override' })
325
+ , a => removeLimit(a))
286
326
  .command('seed', 'Seed the EntitlementFeature registry (idempotent, superadmin only)', () => {}, () => seed())
287
327
  .command('seed-plans', 'Seed PlanEntitlement rows from live PackageVersions in messaging DB (idempotent, superadmin only)', () => {}, () => seedPlans())
288
328
  .command('backfill-sap-tiers', 'Grant the four SAP add-on packages to existing SAP sites (dry run unless --apply; superadmin only)', (y) => y.option('apply', { type: 'boolean', default: false, describe: 'Write the grants (default is a dry run)' }), (a) => backfillSapTiers(a))
@@ -328,7 +368,7 @@ export function entitlementCommand(yargs) {
328
368
  .option('key', { type: 'string', demandOption: true, desc: 'Feature key, e.g. EnableIvr' })
329
369
  .option('rollback', { type: 'boolean', desc: 'Pass to roll back this flag to Subscription.cs (default: go live)' })
330
370
  , a => setCutover(a))
331
- .demandCommand(1, 'Specify a subcommand: get | list-features | enterprise-reports | report-packages | set-override | remove-override | seed | seed-plans | backfill | backfill-sap-tiers | backfill-legacy-write-tiers | reconcile | comp | set-lock | sync-stripe | trial | list-cutover | set-cutover');
371
+ .demandCommand(1, 'Specify a subcommand: get | list-features | enterprise-reports | report-packages | set-override | remove-override | limits | set-limit | remove-limit | seed | seed-plans | backfill | backfill-sap-tiers | backfill-legacy-write-tiers | reconcile | comp | set-lock | sync-stripe | trial | list-cutover | set-cutover');
332
372
  }
333
373
 
334
374
  // Registered group object (the CLI/MCP parity validator reads `command:` from a named const).
@@ -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
+ };
@@ -6,6 +6,7 @@
6
6
  import { readFileSync } from 'node:fs';
7
7
  import { messagingGet, messagingPost, messagingDel, messagingRequest } from '../api.js';
8
8
  import { runCommand } from '../run.js';
9
+ import { applyEmailSubmissionsTo } from '../survey-email.js';
9
10
 
10
11
  const get = messagingGet;
11
12
  const post = messagingPost;
@@ -70,9 +71,14 @@ const surveyGetCommand = {
70
71
  const surveyUpsertCommand = {
71
72
  command: 'upsert <file>',
72
73
  describe: 'Create (omit id or set id=0) or update (set id) a survey from a JSON file containing the full SurveyViewModel shape (id, name, questions[], ...). Use "survey get <id>" on an existing survey to fetch a starting template.',
73
- builder: (y) => y.positional('file', { type: 'string', describe: 'Path to a JSON file with the survey body' }),
74
+ builder: (y) => y
75
+ .positional('file', { type: 'string', describe: 'Path to a JSON file with the survey body' })
76
+ .option('email-submissions-to', {
77
+ type: 'string',
78
+ describe: 'Comma/semicolon list (max 10) of addresses that receive offline / closed-launcher submissions. Overrides the file. Pass "" to clear. Omit to keep the stored list.',
79
+ }),
74
80
  handler: runCommand(async (argv) => {
75
- const body = JSON.parse(readFileSync(argv.file, 'utf8'));
81
+ const body = applyEmailSubmissionsTo(JSON.parse(readFileSync(argv.file, 'utf8')), argv.emailSubmissionsTo);
76
82
  const survey = await post('/Surveys', body);
77
83
  console.log(`Upserted survey ${survey.id} (${survey.name ?? '(unnamed)'}).`);
78
84
  }),
@@ -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
+ });
@@ -0,0 +1,9 @@
1
+ // Survey.EmailSubmissionsTo helper (velaro-messaging PR #3209/#3214).
2
+ // Semantics enforced by the server on POST Surveys: field omitted/null keeps the stored
3
+ // recipients, "" clears them, a non-empty comma/semicolon list replaces them (max 10, validated
4
+ // server-side, 400 with { error } on a bad address). The server is the only validator.
5
+ // Mirrored in mcp/survey-email.js; keep in sync (both covered by their tests).
6
+ export function applyEmailSubmissionsTo(body, value) {
7
+ if (value === undefined || value === null) return body;
8
+ return { ...body, emailSubmissionsTo: String(value).trim() };
9
+ }
@@ -0,0 +1,22 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { applyEmailSubmissionsTo } from './survey-email.js';
4
+
5
+ test('undefined and null leave the body untouched so the server keeps stored recipients', () => {
6
+ const body = { id: 5, name: 'S' };
7
+ assert.deepEqual(applyEmailSubmissionsTo(body, undefined), body);
8
+ assert.deepEqual(applyEmailSubmissionsTo(body, null), body);
9
+ assert.equal('emailSubmissionsTo' in applyEmailSubmissionsTo(body, undefined), false);
10
+ });
11
+
12
+ test('empty string is sent as "" so the server clears the list', () => {
13
+ assert.equal(applyEmailSubmissionsTo({ id: 5 }, '').emailSubmissionsTo, '');
14
+ assert.equal(applyEmailSubmissionsTo({ id: 5 }, ' ').emailSubmissionsTo, '');
15
+ });
16
+
17
+ test('a list overrides any value already in the body and does not mutate the input', () => {
18
+ const body = { id: 5, emailSubmissionsTo: 'old@x.com' };
19
+ const out = applyEmailSubmissionsTo(body, ' a@x.com; b@x.com ');
20
+ assert.equal(out.emailSubmissionsTo, 'a@x.com; b@x.com');
21
+ assert.equal(body.emailSubmissionsTo, 'old@x.com');
22
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.113",
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": {