@velaro/cli 1.4.193 → 1.4.195

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
@@ -47,6 +47,7 @@ import { reportCommand } from '../lib/commands/report.js';
47
47
  import { scheduleAdherenceCommand } from '../lib/commands/schedule-adherence.js';
48
48
  import { reportSubscriptionCommand } from '../lib/commands/report-subscription.js';
49
49
  import { experienceImpactCommand } from '../lib/commands/experience-impact.js';
50
+ import { commerceSafetyCommand } from '../lib/commands/commerce-safety.js';
50
51
  import { enterpriseReportsCommand } from '../lib/commands/enterprise-reports.js';
51
52
  import { reportBackfillCommand } from '../lib/commands/report-backfill.js';
52
53
  import { reportExplainCommand } from '../lib/commands/report-explain.js';
@@ -212,6 +213,7 @@ await (registerStaffCommands ? registerStaffCommands(baseYargs) : baseYargs)
212
213
  .command(executiveInsightsCommand)
213
214
  .command(scheduleAdherenceCommand)
214
215
  .command(experienceImpactCommand)
216
+ .command(commerceSafetyCommand)
215
217
  .command(enterpriseReportsCommand)
216
218
  .command(reportSubscriptionCommand)
217
219
  .command(reportBackfillCommand)
@@ -0,0 +1,84 @@
1
+ import { messagingGet, messagingPut, messagingPost } from '../api.js';
2
+ import { runCommand } from '../run.js';
3
+
4
+ // -- velaro commerce-safety get|set|rollback ------------------------------------
5
+ // Backend: velaro-messaging GET/PUT /api/Commerce/MoneyPolicy and POST /api/Commerce/MoneyPolicy/rollback.
6
+ // Site scope comes from the caller's auth, never an argument.
7
+
8
+ const NUMBERS = {
9
+ 'max-amount-per-action': 'maxAmountPerAction',
10
+ 'max-per-order': 'maxPerOrder',
11
+ 'max-per-conversation': 'maxPerConversation',
12
+ 'max-per-day-per-site': 'maxPerDayPerSite',
13
+ 'max-per-day-per-customer': 'maxPerDayPerCustomer',
14
+ 'max-count-per-day': 'maxCountPerDay',
15
+ 'approval-threshold': 'approvalThreshold',
16
+ 'cooldown-minutes': 'cooldownMinutes',
17
+ };
18
+ const PLATFORMS = ['shopify', 'magento', 'woocommerce', 'bigcommerce', 'square', 'netsuite', 'payments'];
19
+
20
+ export function buildBody(argv) {
21
+ const body = {};
22
+ if (argv.enabled !== undefined) body.enabled = argv.enabled;
23
+ if (argv.mode) body.mode = argv.mode;
24
+ if (argv.currency) body.currency = argv.currency.toUpperCase();
25
+ if (argv.requireVerifiedCustomer !== undefined) body.requireVerifiedCustomer = argv.requireVerifiedCustomer;
26
+ if (argv.methods) body.allowedMethods = String(argv.methods).split(',').map((s) => s.trim()).filter(Boolean);
27
+ if (argv.reasons) body.allowedReasons = String(argv.reasons).split(',').map((s) => s.trim()).filter(Boolean);
28
+ for (const [flag, key] of Object.entries(NUMBERS)) {
29
+ const camel = flag.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
30
+ const v = argv[camel] ?? argv[flag];
31
+ if (v === undefined) continue;
32
+ body[key] = v === 'default' ? null : Number(v);
33
+ }
34
+ if (argv.platform) {
35
+ if (!PLATFORMS.includes(argv.platform)) throw new Error(`--platform must be one of ${PLATFORMS.join(', ')}`);
36
+ return { overrides: { [argv.platform]: argv.reset ? null : body } };
37
+ }
38
+ return body;
39
+ }
40
+
41
+ export const commerceSafetyCommand = {
42
+ command: 'commerce-safety <action>',
43
+ describe: 'Commerce Safety (refund and credit controls): get | set | rollback',
44
+ builder: (y) => y
45
+ .positional('action', { choices: ['get', 'set', 'rollback'], describe: 'get, set (previews unless --confirm) or rollback' })
46
+ .option('platform', { type: 'string', describe: `Apply to one store override: ${PLATFORMS.join(', ')}` })
47
+ .option('reset', { type: 'boolean', default: false, describe: 'With --platform: remove that override' })
48
+ .option('enabled', { type: 'boolean' })
49
+ .option('mode', { type: 'string', choices: ['disabled', 'propose_only_agent_approves', 'auto_up_to_limit', 'auto'] })
50
+ .option('currency', { type: 'string' })
51
+ .option('require-verified-customer', { type: 'boolean' })
52
+ .option('methods', { type: 'string', describe: 'Comma list: original_payment,store_credit,adjustment_credit' })
53
+ .option('reasons', { type: 'string', describe: 'Comma list of accepted reasons' })
54
+ .option('max-amount-per-action', { type: 'string', describe: 'Number or "default"' })
55
+ .option('max-per-order', { type: 'string' })
56
+ .option('max-per-conversation', { type: 'string' })
57
+ .option('max-per-day-per-site', { type: 'string' })
58
+ .option('max-per-day-per-customer', { type: 'string' })
59
+ .option('max-count-per-day', { type: 'string' })
60
+ .option('approval-threshold', { type: 'string' })
61
+ .option('cooldown-minutes', { type: 'string' })
62
+ .option('confirm', { type: 'boolean', default: false, describe: 'Save the change (set) or restore (rollback); without it set only previews' })
63
+ .option('json', { type: 'boolean', default: false, describe: 'Raw JSON output' }),
64
+ handler: runCommand(async (argv) => {
65
+ const show = (d) => {
66
+ if (argv.json) { console.log(JSON.stringify(d, null, 2)); return; }
67
+ if (d.platformKillSwitchActive) console.log('Money actions are paused across the platform right now.');
68
+ console.log(JSON.stringify(d.policy ?? d, null, 2));
69
+ };
70
+ if (argv.action === 'get') { show(await messagingGet('/api/Commerce/MoneyPolicy')); return; }
71
+ if (argv.action === 'rollback') {
72
+ if (!argv.confirm) { console.log('This restores the previous saved policy. Re-run with --confirm.'); return; }
73
+ show(await messagingPost('/api/Commerce/MoneyPolicy/rollback', {})); return;
74
+ }
75
+ const body = buildBody(argv);
76
+ if (Object.keys(body).length === 0) throw new Error('Give at least one setting to change.');
77
+ if (!argv.confirm) {
78
+ console.log('Preview (nothing saved). Re-run with --confirm to save:');
79
+ console.log(JSON.stringify(body, null, 2));
80
+ return;
81
+ }
82
+ show(await messagingPut('/api/Commerce/MoneyPolicy', body));
83
+ }),
84
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.193",
3
+ "version": "1.4.195",
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": {