@velaro/cli 1.4.117 → 1.4.118
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.
|
@@ -41,6 +41,18 @@ async function call(s, a) {
|
|
|
41
41
|
return fn(s.method || 'GET', s.path(a), s.body ? s.body(a) : undefined);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// Safety guard for subscription/expiry writes. Default is DENY: these commands refuse to run
|
|
45
|
+
// unless VELARO_ALLOW_SUBSCRIPTION_WRITE=1 is set, and a protected site can never be written from
|
|
46
|
+
// the CLI. Site 20678 (Northern New England Poison Control) is protected: it stays on its own
|
|
47
|
+
// account and expiry controls, and must not be extended, flagged, or changed from this CLI.
|
|
48
|
+
const PROTECTED_SITE_IDS = new Set([20678]);
|
|
49
|
+
function subscriptionWriteGuard(a) {
|
|
50
|
+
if (process.env.VELARO_ALLOW_SUBSCRIPTION_WRITE !== '1') return 'Subscription writes are disabled in the CLI. Set VELARO_ALLOW_SUBSCRIPTION_WRITE=1 for one deliberate run.';
|
|
51
|
+
const id = Number(a.site);
|
|
52
|
+
if (PROTECTED_SITE_IDS.has(id)) return `Site ${id} is protected. Subscription and expiry changes for it are not allowed from the CLI.`;
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
44
56
|
export function addRoutes(y, specs) {
|
|
45
57
|
for (const s of specs) {
|
|
46
58
|
y.command(s.name, s.desc, (yy) => {
|
|
@@ -50,6 +62,7 @@ export function addRoutes(y, specs) {
|
|
|
50
62
|
}, async (a) => {
|
|
51
63
|
try {
|
|
52
64
|
if ((s.yes || (s.needsYes && s.needsYes(a))) && !a.yes) { console.error(`Refusing without --yes: ${s.desc}`); process.exit(1); }
|
|
65
|
+
if (s.guard) { const why = s.guard(a); if (why) { console.error(`Refused: ${why}`); process.exit(1); } }
|
|
53
66
|
out(s.run ? await s.run(a) : await call(s, a));
|
|
54
67
|
} catch (e) { console.error(e.message); process.exit(1); }
|
|
55
68
|
});
|
|
@@ -75,9 +88,9 @@ export const SUPPORT_EXTRA = [
|
|
|
75
88
|
{ name: 'site-health', desc: 'Site health: subscription, agents, last login, 7-day errors', opts: site, path: (a) => `${SP(a)}/health` },
|
|
76
89
|
{ name: 'site-agents', desc: 'Agents on a site', opts: site, path: (a) => `${SP(a)}/agents` },
|
|
77
90
|
{ name: 'site-activity', desc: 'Activity log for a site', opts: { ...site, page: N('Page'), 'page-size': N('Page size (max 200)'), category: S('Category') }, path: (a) => `${SP(a)}/activity${qs({ page: a.page ?? 1, pageSize: Math.min(200, a.pageSize ?? 50), category: a.category })}` },
|
|
78
|
-
{ name: 'extend-subscription', desc: 'Extend a site subscription by N days', yes: true, method: 'POST', opts: { ...site, days: N('Days', true) }, path: (a) => `${SP(a)}/extend-subscription`, body: (a) => ({ days: a.days }) },
|
|
91
|
+
{ name: 'extend-subscription', desc: 'Extend a site subscription by N days', guard: subscriptionWriteGuard, yes: true, method: 'POST', opts: { ...site, days: N('Days', true) }, path: (a) => `${SP(a)}/extend-subscription`, body: (a) => ({ days: a.days }) },
|
|
79
92
|
{ name: 'set-user-active', desc: 'Activate/deactivate a user on a site', yes: true, method: 'POST', opts: { ...site, 'user-id': N('User id', true), active: { type: 'boolean', demandOption: true, describe: 'true or false' } }, path: (a) => `SupportTools/users/${a.userId}/sites/${a.site}/set-active`, body: (a) => ({ isActive: a.active }) },
|
|
80
|
-
{ name: 'bulk-set-flags', desc: 'Set several subscription flags at once (JSON object)', yes: true, method: 'POST', opts: { ...site, flags: S('JSON object or @file.json', true) }, path: (a) => `${SP(a)}/subscription/bulk-flags`, body: (a) => ({ flags: json(a.flags) }) },
|
|
93
|
+
{ name: 'bulk-set-flags', desc: 'Set several subscription flags at once (JSON object)', guard: subscriptionWriteGuard, yes: true, method: 'POST', opts: { ...site, flags: S('JSON object or @file.json', true) }, path: (a) => `${SP(a)}/subscription/bulk-flags`, body: (a) => ({ flags: json(a.flags) }) },
|
|
81
94
|
{ name: 'create-agent', desc: 'Create an agent on any site (staff)', api: 'msg', method: 'POST', opts: { ...site, email: S('Email', true), 'first-name': S('First name'), 'last-name': S('Last name'), roles: S('Comma list of roles'), 'team-ids': S('Comma list of team ids'), 'max-chats': N('Max chats (0 = default)') }, path: (a) => `/SupportTools/sites/${a.site}/agents`, body: (a) => ({ email: a.email, firstName: a.firstName, lastName: a.lastName, roles: csv(a.roles), teamIds: csvN(a.teamIds), maxChats: a.maxChats ?? 0 }) },
|
|
82
95
|
{ name: 'schedule-adherence', desc: 'Schedule adherence diagnostics for a site', api: 'msg', opts: { ...site, role: S('role'), 'agent-id': N('Agent id (required when role=agent)'), start: S('Start'), end: S('End'), tz: S('Timezone') }, path: (a) => `/Reports/sites/${a.site}/schedule-adherence-diagnostics${qs({ detail: 'true', role: a.role, agentId: a.agentId, start: a.start, end: a.end, tz: a.tz })}` },
|
|
83
96
|
{ name: 'appointments-list-sites', desc: 'Sites with Velaro Appointments enabled', api: 'msg', path: () => '/Appointments/admin/sites-with-appointments' },
|
package/package.json
CHANGED