@velaro/cli 1.4.162 → 1.4.164

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
@@ -103,6 +103,7 @@ import { authorityCommand } from '../lib/commands/authority.js';
103
103
  import { caseCommand } from '../lib/commands/case.js';
104
104
  import { dealCommand } from '../lib/commands/deal.js';
105
105
  import { ticketCommand } from '../lib/commands/ticket.js';
106
+ import { emailRouteCommand } from '../lib/commands/email-route.js';
106
107
  import { pickupCommand } from '../lib/commands/pickup.js';
107
108
  import { siteSaleCommand } from '../lib/commands/site-sale.js';
108
109
  import { visitorMonitorCommand } from '../lib/commands/visitor-monitor.js';
@@ -255,6 +256,7 @@ await (registerStaffCommands ? registerStaffCommands(baseYargs) : baseYargs)
255
256
  .command(caseCommand)
256
257
  .command(dealCommand)
257
258
  .command(ticketCommand)
259
+ .command(emailRouteCommand)
258
260
  .command(pickupCommand)
259
261
  .command(siteSaleCommand)
260
262
  .command(visitorMonitorCommand)
@@ -0,0 +1,89 @@
1
+ import { messagingGet, messagingPost, messagingPut, messagingDel } from '../api.js';
2
+ import { runCommand } from '../run.js';
3
+
4
+ // -- velaro email-route -------------------------------------------------------
5
+ // CLI for ticket email routes: TicketController Ticket/email-routes (GET, POST, PUT /{id}, DELETE /{id}).
6
+ // Rules are evaluated in sort order, first match wins. The site always comes from the signed-in credential.
7
+ // MCP parity: mcp/parity/email-route.customer.js (email_route_* tools).
8
+
9
+ const BOLD = '\x1b[1m';
10
+ const DIM = '\x1b[2m';
11
+ const RST = '\x1b[0m';
12
+
13
+ function printJson(v) {
14
+ console.log(JSON.stringify(v, null, 2));
15
+ }
16
+
17
+ function bodyFrom(argv) {
18
+ return {
19
+ name: argv.name,
20
+ recipientPattern: argv.recipient ?? null,
21
+ senderDomainPattern: argv['sender-domain'] ?? null,
22
+ subjectKeywords: argv.subject ?? null,
23
+ teamId: argv['team-id'] ?? null,
24
+ priority: argv.priority ?? null,
25
+ category: argv.category ?? null,
26
+ sortOrder: argv['sort-order'] ?? 0,
27
+ isActive: argv.active !== false,
28
+ mode: argv.mode ?? null,
29
+ };
30
+ }
31
+
32
+ async function listHandler(argv) {
33
+ const list = await messagingGet('/Ticket/email-routes');
34
+ if (argv.json) return printJson(list);
35
+ console.log(`\n${BOLD}Email routes${RST}`);
36
+ for (const r of Array.isArray(list) ? list : []) {
37
+ const match = [r.recipientPattern && `to ~ ${r.recipientPattern}`, r.senderDomainPattern && `from ~ ${r.senderDomainPattern}`, r.subjectKeywords && `subject ~ ${r.subjectKeywords}`].filter(Boolean).join('; ') || 'matches everything';
38
+ console.log(` #${r.id} ${r.name} ${DIM}order ${r.sortOrder} ${match} -> ${r.teamName ?? 'default team'}${r.mode ? ` mode ${r.mode}` : ''}${r.priority ? ` ${r.priority}` : ''}${r.category ? ` ${r.category}` : ''}${r.isActive ? '' : ' inactive'}${RST}`);
39
+ }
40
+ console.log('');
41
+ }
42
+
43
+ async function createHandler(argv) {
44
+ const r = await messagingPost('/Ticket/email-routes', bodyFrom(argv));
45
+ if (argv.json) return printJson(r);
46
+ console.log(`\n Created email route #${r?.id} (${r?.name}).\n`);
47
+ }
48
+
49
+ async function updateHandler(argv) {
50
+ const r = await messagingPut(`/Ticket/email-routes/${encodeURIComponent(argv.id)}`, bodyFrom(argv));
51
+ if (argv.json) return printJson(r);
52
+ console.log(`\n Updated email route #${argv.id}.\n`);
53
+ }
54
+
55
+ async function deleteHandler(argv) {
56
+ await messagingDel(`/Ticket/email-routes/${encodeURIComponent(argv.id)}`);
57
+ console.log(`\n Deleted email route #${argv.id}.\n`);
58
+ }
59
+
60
+ const json = (y) => y.option('json', { type: 'boolean', describe: 'Print raw JSON' });
61
+ const fieldOpts = (y) => y
62
+ .option('name', { type: 'string', demandOption: true })
63
+ .option('recipient', { type: 'string', describe: 'Recipient address substring, e.g. billing@acme.com or @acme.com' })
64
+ .option('sender-domain', { type: 'string', describe: 'Sender domain, e.g. client.com' })
65
+ .option('subject', { type: 'string', describe: 'Comma-separated subject keywords' })
66
+ .option('team-id', { type: 'number', describe: 'Target team id (default: site default team)' })
67
+ .option('priority', { type: 'string' })
68
+ .option('category', { type: 'string' })
69
+ .option('sort-order', { type: 'number', default: 0, describe: 'Lower runs first' })
70
+ .option('active', { type: 'boolean', default: true })
71
+ .option('mode', { choices: ['ticket', 'conversation', 'ignore'], describe: 'Omit to inherit the site ticketing setting' });
72
+
73
+ export const emailRouteCommand = {
74
+ command: 'email-route',
75
+ describe: 'Manage ticket email routes (recipient/sender/subject rules that pick team, priority, category, mode)',
76
+ builder: (y) => y
77
+ .command({ command: 'list', describe: 'List email routes', builder: json, handler: runCommand(listHandler) })
78
+ .command({ command: 'create', describe: 'Create an email route', builder: (yy) => json(fieldOpts(yy)), handler: runCommand(createHandler) })
79
+ .command({
80
+ command: 'update <id>',
81
+ describe: 'Update an email route (replaces all fields; pass the full route)',
82
+ builder: (yy) => json(fieldOpts(yy)),
83
+ handler: runCommand(updateHandler),
84
+ })
85
+ .command({ command: 'delete <id>', describe: 'Delete an email route', handler: runCommand(deleteHandler) })
86
+ .demandCommand(1, 'Specify an email-route subcommand.')
87
+ .strict(),
88
+ handler: () => {},
89
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.162",
3
+ "version": "1.4.164",
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": {