@velaro/cli 1.4.164 → 1.4.166
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 +2 -0
- package/lib/commands/dynamics.js +25 -1
- package/lib/commands/email-route-override.js +126 -0
- package/package.json +1 -1
package/bin/velaro.js
CHANGED
|
@@ -104,6 +104,7 @@ 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
106
|
import { emailRouteCommand } from '../lib/commands/email-route.js';
|
|
107
|
+
import { emailRouteOverrideCommand } from '../lib/commands/email-route-override.js';
|
|
107
108
|
import { pickupCommand } from '../lib/commands/pickup.js';
|
|
108
109
|
import { siteSaleCommand } from '../lib/commands/site-sale.js';
|
|
109
110
|
import { visitorMonitorCommand } from '../lib/commands/visitor-monitor.js';
|
|
@@ -257,6 +258,7 @@ await (registerStaffCommands ? registerStaffCommands(baseYargs) : baseYargs)
|
|
|
257
258
|
.command(dealCommand)
|
|
258
259
|
.command(ticketCommand)
|
|
259
260
|
.command(emailRouteCommand)
|
|
261
|
+
.command(emailRouteOverrideCommand)
|
|
260
262
|
.command(pickupCommand)
|
|
261
263
|
.command(siteSaleCommand)
|
|
262
264
|
.command(visitorMonitorCommand)
|
package/lib/commands/dynamics.js
CHANGED
|
@@ -39,6 +39,30 @@ export const dynamicsCommand = {
|
|
|
39
39
|
console.log(JSON.stringify(await request('PUT', `${base(argv.config)}/${argv.team}`, body), null, 2));
|
|
40
40
|
}),
|
|
41
41
|
})
|
|
42
|
-
.
|
|
42
|
+
.command({
|
|
43
|
+
command: 'copy-mappings',
|
|
44
|
+
describe: 'Copy field mappings + activity type from one Dynamics connection to another on the same site',
|
|
45
|
+
builder: y => y
|
|
46
|
+
.option('config', { type: 'number', demandOption: true, describe: 'Target Dynamics config id' })
|
|
47
|
+
.option('from', { type: 'number', demandOption: true, describe: 'Source Dynamics config id' })
|
|
48
|
+
.option('team-overrides', { type: 'boolean', default: false, describe: 'Also replace the target\'s per-group overrides with the source\'s' }),
|
|
49
|
+
handler: runCommand(async argv => {
|
|
50
|
+
const res = await request('POST', `/Dynamics/Configs/${argv.config}/copy-mappings-from/${argv.from}`, { includeTeamOverrides: argv.teamOverrides === true });
|
|
51
|
+
console.log(JSON.stringify(res, null, 2));
|
|
52
|
+
}),
|
|
53
|
+
})
|
|
54
|
+
.command({
|
|
55
|
+
command: 'restore-mappings',
|
|
56
|
+
describe: 'Put the connection field mappings + activity type back to given values (undo of copy-mappings; uses PUT Configs/{id}, other settings untouched)',
|
|
57
|
+
builder: y => y
|
|
58
|
+
.option('config', { type: 'number', demandOption: true, describe: 'Dynamics config id to restore' })
|
|
59
|
+
.option('mappings', { type: 'string', demandOption: true, describe: 'customFieldMappingsJson to put back (the `previous` value; empty string if it was empty)' })
|
|
60
|
+
.option('activity', { type: 'string', demandOption: true, describe: 'activityLogicalName to put back (empty string if it was empty)' }),
|
|
61
|
+
handler: runCommand(async argv => {
|
|
62
|
+
const res = await request('PUT', `/Dynamics/Configs/${argv.config}`, { customFieldMappingsJson: argv.mappings, activityLogicalName: argv.activity });
|
|
63
|
+
console.log(JSON.stringify(res, null, 2));
|
|
64
|
+
}),
|
|
65
|
+
})
|
|
66
|
+
.demandCommand(1, 'Specify a subcommand: team-overrides | copy-mappings | restore-mappings'),
|
|
43
67
|
handler: () => {},
|
|
44
68
|
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { messagingGet, messagingPost, messagingPut, messagingDel } from '../api.js';
|
|
2
|
+
import { runCommand } from '../run.js';
|
|
3
|
+
|
|
4
|
+
// -- velaro email-route-override ---------------------------------------------
|
|
5
|
+
// CLI for scoped email route overrides: TicketController Ticket/email-route-overrides
|
|
6
|
+
// (GET, POST, PUT /{id}, DELETE /{id}, POST /explain). Scope = mailbox (provider + id) and/or team; no scope = site-wide.
|
|
7
|
+
// Outcome fields (mode, priority, category, target-team-id) are per-field; at least one is required on create.
|
|
8
|
+
// Scope is immutable on update. The site always comes from the signed-in credential.
|
|
9
|
+
// MCP parity: mcp/parity/email-route-override.customer.js (email_route_override_* tools).
|
|
10
|
+
|
|
11
|
+
const BOLD = '\x1b[1m';
|
|
12
|
+
const DIM = '\x1b[2m';
|
|
13
|
+
const RST = '\x1b[0m';
|
|
14
|
+
|
|
15
|
+
const printJson = (v) => console.log(JSON.stringify(v, null, 2));
|
|
16
|
+
|
|
17
|
+
function createBody(argv) {
|
|
18
|
+
return {
|
|
19
|
+
mailboxProvider: argv['mailbox-provider'] ?? null,
|
|
20
|
+
mailboxId: argv['mailbox-id'] ?? null,
|
|
21
|
+
teamId: argv['team-id'] ?? null,
|
|
22
|
+
mode: argv.mode ?? null,
|
|
23
|
+
priority: argv.priority ?? null,
|
|
24
|
+
category: argv.category ?? null,
|
|
25
|
+
targetTeamId: argv['target-team-id'] ?? null,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Update is apply-if-present: only send what was passed.
|
|
30
|
+
function updateBody(argv) {
|
|
31
|
+
const b = {};
|
|
32
|
+
if (argv.mode !== undefined) b.mode = argv.mode;
|
|
33
|
+
if (argv.priority !== undefined) b.priority = argv.priority;
|
|
34
|
+
if (argv.category !== undefined) b.category = argv.category;
|
|
35
|
+
if (argv['target-team-id'] !== undefined) b.targetTeamId = argv['target-team-id'];
|
|
36
|
+
return b;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function listHandler(argv) {
|
|
40
|
+
const list = await messagingGet('/Ticket/email-route-overrides');
|
|
41
|
+
if (argv.json) return printJson(list);
|
|
42
|
+
console.log(`\n${BOLD}Email route overrides${RST}`);
|
|
43
|
+
for (const o of Array.isArray(list) ? list : []) {
|
|
44
|
+
const scope = [o.mailboxId != null && `${o.mailboxProvider} mailbox ${o.mailboxId}`, o.teamId != null && `team ${o.teamId}`].filter(Boolean).join(' + ') || 'site-wide';
|
|
45
|
+
const out = [o.mode && `mode ${o.mode}`, o.priority && `priority ${o.priority}`, o.category && `category ${o.category}`, o.targetTeamId != null && `-> team ${o.targetTeamId}`].filter(Boolean).join(', ');
|
|
46
|
+
console.log(` #${o.id} ${scope} ${DIM}${out}${RST}`);
|
|
47
|
+
}
|
|
48
|
+
console.log('');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function createHandler(argv) {
|
|
52
|
+
const r = await messagingPost('/Ticket/email-route-overrides', createBody(argv));
|
|
53
|
+
if (argv.json) return printJson(r);
|
|
54
|
+
console.log(`\n Created email route override #${r?.id}.\n`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function updateHandler(argv) {
|
|
58
|
+
const r = await messagingPut(`/Ticket/email-route-overrides/${encodeURIComponent(argv.id)}`, updateBody(argv));
|
|
59
|
+
if (argv.json) return printJson(r);
|
|
60
|
+
console.log(`\n Updated email route override #${argv.id}.\n`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function deleteHandler(argv) {
|
|
64
|
+
await messagingDel(`/Ticket/email-route-overrides/${encodeURIComponent(argv.id)}`);
|
|
65
|
+
console.log(`\n Deleted email route override #${argv.id}.\n`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function explainHandler(argv) {
|
|
69
|
+
const r = await messagingPost('/Ticket/email-route-overrides/explain', {
|
|
70
|
+
recipient: argv.recipient ?? null,
|
|
71
|
+
sender: argv.sender ?? null,
|
|
72
|
+
subject: argv.subject ?? null,
|
|
73
|
+
mailboxProvider: argv['mailbox-provider'] ?? null,
|
|
74
|
+
mailboxId: argv['mailbox-id'] ?? null,
|
|
75
|
+
mailboxTeamId: argv['mailbox-team-id'] ?? null,
|
|
76
|
+
});
|
|
77
|
+
if (argv.json) return printJson(r);
|
|
78
|
+
console.log(`\n${BOLD}Matched rule${RST} ${r?.matchedRuleName ? `#${r.matchedRuleId} ${r.matchedRuleName}` : 'none (site default)'}`);
|
|
79
|
+
console.log(`${BOLD}Effective${RST} ${JSON.stringify(r?.effective ?? null)} ${DIM}(${r?.overrideCount ?? 0} overrides on site)${RST}\n`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const json = (y) => y.option('json', { type: 'boolean', describe: 'Print raw JSON' });
|
|
83
|
+
const outcomeOpts = (y) => y
|
|
84
|
+
.option('mode', { choices: ['ticket', 'conversation'], describe: 'ticket or conversation ("ignore" is not allowed on an override)' })
|
|
85
|
+
.option('priority', { type: 'string', describe: '16 characters max' })
|
|
86
|
+
.option('category', { type: 'string', describe: '64 characters max' })
|
|
87
|
+
.option('target-team-id', { type: 'number', describe: 'Re-route to this team id' });
|
|
88
|
+
const scopeOpts = (y) => y
|
|
89
|
+
.option('mailbox-provider', { choices: ['Outlook', 'Gmail'], describe: 'Required with --mailbox-id' })
|
|
90
|
+
.option('mailbox-id', { type: 'number', describe: 'Mailbox integration id (scope)' })
|
|
91
|
+
.option('team-id', { type: 'number', describe: 'Department team id (scope)' });
|
|
92
|
+
|
|
93
|
+
export const emailRouteOverrideCommand = {
|
|
94
|
+
command: 'email-route-override',
|
|
95
|
+
describe: 'Manage scoped email route overrides (mailbox/team scope that override mode, priority, category, target team)',
|
|
96
|
+
builder: (y) => y
|
|
97
|
+
.command({ command: 'list', describe: 'List email route overrides', builder: json, handler: runCommand(listHandler) })
|
|
98
|
+
.command({
|
|
99
|
+
command: 'create',
|
|
100
|
+
describe: 'Create an override (omit scope flags for a site-wide default; set at least one of mode, priority, category, target-team-id)',
|
|
101
|
+
builder: (yy) => json(outcomeOpts(scopeOpts(yy))),
|
|
102
|
+
handler: runCommand(createHandler),
|
|
103
|
+
})
|
|
104
|
+
.command({
|
|
105
|
+
command: 'update <id>',
|
|
106
|
+
describe: 'Update an override outcome (scope is immutable; only passed fields change)',
|
|
107
|
+
builder: (yy) => json(outcomeOpts(yy)),
|
|
108
|
+
handler: runCommand(updateHandler),
|
|
109
|
+
})
|
|
110
|
+
.command({ command: 'delete <id>', describe: 'Delete an override', handler: runCommand(deleteHandler) })
|
|
111
|
+
.command({
|
|
112
|
+
command: 'explain',
|
|
113
|
+
describe: 'Show which route matches an email and what the overrides turn it into',
|
|
114
|
+
builder: (yy) => json(yy
|
|
115
|
+
.option('recipient', { type: 'string' })
|
|
116
|
+
.option('sender', { type: 'string', describe: 'Sender address' })
|
|
117
|
+
.option('subject', { type: 'string' })
|
|
118
|
+
.option('mailbox-provider', { choices: ['Outlook', 'Gmail'] })
|
|
119
|
+
.option('mailbox-id', { type: 'number' })
|
|
120
|
+
.option('mailbox-team-id', { type: 'number', describe: 'Team the mailbox is assigned to' })),
|
|
121
|
+
handler: runCommand(explainHandler),
|
|
122
|
+
})
|
|
123
|
+
.demandCommand(1, 'Specify an email-route-override subcommand.')
|
|
124
|
+
.strict(),
|
|
125
|
+
handler: () => {},
|
|
126
|
+
};
|
package/package.json
CHANGED