@velaro/cli 1.4.120 → 1.4.121
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/README.md +0 -19
- package/bin/velaro.js +21 -92
- package/lib/avatar-motion.test.js +1 -1
- package/lib/avatar-switch.test.js +1 -1
- package/lib/commands/agent.js +7 -58
- package/lib/commands/ai-config.js +8 -34
- package/lib/commands/index.js +18 -14
- package/lib/commands/kb.js +4 -94
- package/lib/commands/knowledge.js +2 -2
- package/lib/commands/ops-groups.js +0 -13
- package/lib/commands/safety.js +1 -1
- package/lib/commands/salesforce.js +1 -1
- package/lib/commands/sap.js +1 -1
- package/lib/commands/schedule-adherence.js +1 -1
- package/lib/commands/teams.js +1 -1
- package/lib/commands/woocommerce.js +1 -1
- package/lib/commands/workflow.js +4 -31
- package/lib/staff-optional.js +10 -0
- package/package.json +2 -2
- package/lib/cobrowse-settings.js +0 -90
- package/lib/cobrowse-settings.test.js +0 -45
- package/lib/commands/activity.js +0 -147
- package/lib/commands/acuity.js +0 -66
- package/lib/commands/ai-federation.js +0 -55
- package/lib/commands/ai-models.js +0 -203
- package/lib/commands/ai-spend.js +0 -71
- package/lib/commands/avatar.js +0 -253
- package/lib/commands/bigcommerce.js +0 -50
- package/lib/commands/calendly.js +0 -62
- package/lib/commands/cobrowse.js +0 -99
- package/lib/commands/coupon-grant.js +0 -192
- package/lib/commands/diag-groups.js +0 -108
- package/lib/commands/diagnostics.js +0 -298
- package/lib/commands/email-inbox.js +0 -110
- package/lib/commands/entitlement.js +0 -375
- package/lib/commands/image-analysis.js +0 -27
- package/lib/commands/logs-insights.js +0 -342
- package/lib/commands/logs.js +0 -1248
- package/lib/commands/migrate.js +0 -379
- package/lib/commands/migration-status.js +0 -66
- package/lib/commands/ops.js +0 -266
- package/lib/commands/parity-staff-tools.js +0 -205
- package/lib/commands/pricing.js +0 -132
- package/lib/commands/report-speed.js +0 -112
- package/lib/commands/scraper.js +0 -38
- package/lib/commands/site-provision.js +0 -68
- package/lib/commands/sitesync.js +0 -158
- package/lib/commands/skill-usage.js +0 -39
- package/lib/commands/staff.js +0 -31
- package/lib/commands/status-page.js +0 -95
- package/lib/commands/status-sla.js +0 -47
- package/lib/commands/subscription.js +0 -102
- package/lib/commands/support.js +0 -309
- package/lib/commands/tour-policy.js +0 -61
- package/lib/commands/triage.js +0 -66
- package/lib/entitlement-report-packages.test.js +0 -47
- package/lib/log-search.js +0 -252
- package/lib/log-search.test.js +0 -374
- package/lib/logs-insights.test.js +0 -146
- package/lib/messaging-routes.test.js +0 -37
- package/lib/report-speed.test.js +0 -26
- package/lib/siteUser.js +0 -35
- package/lib/siteUser.test.js +0 -45
- package/lib/skill-usage.test.js +0 -36
- package/lib/status-sla.test.js +0 -23
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { messagingGet, messagingPost, messagingPatch, messagingDel } from '../api.js';
|
|
2
|
-
import { runCommand } from '../run.js';
|
|
3
|
-
|
|
4
|
-
// ── velaro email-inbox ────────────────────────────────────────────────────────
|
|
5
|
-
// Staff commands to manage Gmail/Outlook inbox mailbox connections for any site.
|
|
6
|
-
// Requires a Velaro internal-staff JWT (site 1032) or vel_live_* service key bound
|
|
7
|
-
// to site 1032 — same gate as every other SupportTools/sites/{siteId}/... endpoint.
|
|
8
|
-
//
|
|
9
|
-
// Backed by velaro-messaging SupportToolsController's email-inbox endpoints:
|
|
10
|
-
// GET SupportTools/sites/{siteId}/email-inbox/{provider}/list
|
|
11
|
-
// GET SupportTools/sites/{siteId}/email-inbox/gmail/config-status
|
|
12
|
-
// PATCH SupportTools/sites/{siteId}/email-inbox/{provider}/{id}/team
|
|
13
|
-
// POST SupportTools/sites/{siteId}/email-inbox/outlook/{id}/resubscribe
|
|
14
|
-
// DELETE SupportTools/sites/{siteId}/email-inbox/{provider}/{id}
|
|
15
|
-
|
|
16
|
-
function providerOption(y) {
|
|
17
|
-
return y.option('provider', {
|
|
18
|
-
type: 'string', choices: ['gmail', 'outlook'], demandOption: true,
|
|
19
|
-
describe: 'Which inbox integration',
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function printMailboxes(provider, siteId, mailboxes) {
|
|
24
|
-
if (!Array.isArray(mailboxes) || mailboxes.length === 0) {
|
|
25
|
-
console.log(`\nSite ${siteId}: no ${provider} mailboxes connected.\n`);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
console.log(`\nSite ${siteId} — ${provider} mailboxes:\n`);
|
|
29
|
-
for (const m of mailboxes) {
|
|
30
|
-
const team = m.teamName ? m.teamName : (m.TeamId || m.teamId ? `team #${m.TeamId ?? m.teamId}` : '(no team — site default)');
|
|
31
|
-
const status = (m.IsEnabled ?? m.isEnabled) ? 'enabled' : 'disabled';
|
|
32
|
-
console.log(` #${m.Id ?? m.id} ${m.MailboxEmail ?? m.mailboxEmail} [${status}] ${team}`);
|
|
33
|
-
}
|
|
34
|
-
console.log('');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const emailInboxCommand = {
|
|
38
|
-
command: 'email-inbox <subcommand>',
|
|
39
|
-
describe: 'Manage Gmail/Outlook inbox mailbox connections for any site (Velaro staff only)',
|
|
40
|
-
builder: yargs => yargs
|
|
41
|
-
.command({
|
|
42
|
-
command: 'list',
|
|
43
|
-
describe: 'List mailboxes connected for a site',
|
|
44
|
-
builder: y => providerOption(y)
|
|
45
|
-
.option('site', { type: 'number', demandOption: true, describe: 'Site ID' }),
|
|
46
|
-
handler: runCommand(async argv => {
|
|
47
|
-
const mailboxes = await messagingGet(`/SupportTools/sites/${argv.site}/email-inbox/${argv.provider}/list`);
|
|
48
|
-
printMailboxes(argv.provider, argv.site, mailboxes);
|
|
49
|
-
}),
|
|
50
|
-
})
|
|
51
|
-
.command({
|
|
52
|
-
command: 'status',
|
|
53
|
-
describe: 'Show global Gmail OAuth/DWD/Pub-Sub config status (gmail only — Outlook has no global status endpoint, use "list")',
|
|
54
|
-
builder: y => y.option('site', { type: 'number', demandOption: true, describe: 'Site ID (accepted for a uniform call shape; global config is not per-site)' }),
|
|
55
|
-
handler: runCommand(async argv => {
|
|
56
|
-
const status = await messagingGet(`/SupportTools/sites/${argv.site}/email-inbox/gmail/config-status`);
|
|
57
|
-
console.log(`\nGmail global config status:`);
|
|
58
|
-
console.log(` OAuth configured: ${status.oauthConfigured ? 'yes' : 'no'}`);
|
|
59
|
-
console.log(` DWD configured: ${status.dwdConfigured ? 'yes' : 'no'}`);
|
|
60
|
-
console.log(` Pub/Sub configured: ${status.pubSubConfigured ? 'yes' : 'no'}`);
|
|
61
|
-
if (status.clientIdPrefix) console.log(` Client ID prefix: ${status.clientIdPrefix}...`);
|
|
62
|
-
if (status.credentialPair) console.log(` Credential pair: ${status.credentialPair}${status.credentialPair === 'PairValid' ? '' : ' <-- ' + (status.credentialPairDetail ?? '')}`);
|
|
63
|
-
if (status.redirectUri) console.log(` Redirect URI: ${status.redirectUri}`);
|
|
64
|
-
if (status.pubSubTopic) console.log(` Pub/Sub topic: ${status.pubSubTopic}`);
|
|
65
|
-
for (const d of status.duplicateKeys ?? []) {
|
|
66
|
-
console.log(` DUPLICATE SETTING: ${d.colonKey} and ${d.underscoreKey}${d.valuesDiffer ? ' with DIFFERENT values - delete the stale one' : ' (same value)'}`);
|
|
67
|
-
}
|
|
68
|
-
console.log('');
|
|
69
|
-
}),
|
|
70
|
-
})
|
|
71
|
-
.command({
|
|
72
|
-
command: 'set-team',
|
|
73
|
-
describe: 'Reassign (or clear) the team a mailbox routes inbound mail to',
|
|
74
|
-
builder: y => providerOption(y)
|
|
75
|
-
.option('site', { type: 'number', demandOption: true, describe: 'Site ID' })
|
|
76
|
-
.option('id', { type: 'number', demandOption: true, describe: 'Mailbox integration ID (from "list")' })
|
|
77
|
-
.option('team-id', { type: 'number', demandOption: true, describe: 'Team ID to assign, or 0 to clear (site default/catch-all)' }),
|
|
78
|
-
handler: runCommand(async argv => {
|
|
79
|
-
await messagingPatch(`/SupportTools/sites/${argv.site}/email-inbox/${argv.provider}/${argv.id}/team`, { teamId: argv['team-id'] });
|
|
80
|
-
console.log(argv['team-id'] === 0
|
|
81
|
-
? `\n✓ Mailbox #${argv.id} (${argv.provider}) team assignment cleared — now routes to site default.\n`
|
|
82
|
-
: `\n✓ Mailbox #${argv.id} (${argv.provider}) reassigned to team ${argv['team-id']}.\n`);
|
|
83
|
-
}),
|
|
84
|
-
})
|
|
85
|
-
.command({
|
|
86
|
-
command: 'resubscribe',
|
|
87
|
-
describe: 'Outlook only: (re)create the Microsoft Graph inbound-mail subscription for a mailbox (fixes connected-but-receives-nothing)',
|
|
88
|
-
builder: y => y
|
|
89
|
-
.option('site', { type: 'number', demandOption: true, describe: 'Site ID' })
|
|
90
|
-
.option('id', { type: 'number', demandOption: true, describe: 'Mailbox integration ID (from "list")' }),
|
|
91
|
-
handler: runCommand(async argv => {
|
|
92
|
-
const r = await messagingPost(`/SupportTools/sites/${argv.site}/email-inbox/outlook/${argv.id}/resubscribe`, {});
|
|
93
|
-
console.log(r.created
|
|
94
|
-
? `\n✓ Mailbox #${argv.id} subscribed (id ${r.graphSubscriptionId}, expires ${r.graphSubscriptionExpiresAt}).\n`
|
|
95
|
-
: `\n✗ Subscription NOT created. ${r.note ?? ''}\n Run: velaro activity OutlookInbox --site ${argv.site} --severity Error\n`);
|
|
96
|
-
}),
|
|
97
|
-
})
|
|
98
|
-
.command({
|
|
99
|
-
command: 'disconnect',
|
|
100
|
-
describe: 'Disconnect and remove a mailbox connection',
|
|
101
|
-
builder: y => providerOption(y)
|
|
102
|
-
.option('site', { type: 'number', demandOption: true, describe: 'Site ID' })
|
|
103
|
-
.option('id', { type: 'number', demandOption: true, describe: 'Mailbox integration ID (from "list")' }),
|
|
104
|
-
handler: runCommand(async argv => {
|
|
105
|
-
await messagingDel(`/SupportTools/sites/${argv.site}/email-inbox/${argv.provider}/${argv.id}`);
|
|
106
|
-
console.log(`\n✓ Mailbox #${argv.id} (${argv.provider}) disconnected from site ${argv.site}.\n`);
|
|
107
|
-
}),
|
|
108
|
-
})
|
|
109
|
-
.demandCommand(1, 'Specify a subcommand: list | status | set-team | resubscribe | disconnect'),
|
|
110
|
-
};
|
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
// velaro entitlement — query and manage site feature entitlements (superadmin only)
|
|
2
|
-
import { request } from '../api.js';
|
|
3
|
-
|
|
4
|
-
async function syncStripe(a) {
|
|
5
|
-
const r = await request('PUT', `Entitlements/admin/sync-stripe/${a.site}`, {
|
|
6
|
-
planKey: a.plan,
|
|
7
|
-
status: a.status,
|
|
8
|
-
cancelAtPeriodEnd: a['cancel-at-period-end'] ?? false,
|
|
9
|
-
currentPeriodEnd: a['current-period-end'] ?? null,
|
|
10
|
-
trialEndAt: a['trial-end-at'] ?? null,
|
|
11
|
-
stripeCustomerId: a['stripe-customer-id'],
|
|
12
|
-
stripeSubscriptionId: a['stripe-subscription-id'],
|
|
13
|
-
});
|
|
14
|
-
console.log(`Site ${a.site} synced: status=${r.status} plan=${r.planKey || 'unchanged'}`);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async function getSite(args) {
|
|
18
|
-
if (!args.site) { console.error('Usage: velaro entitlement get --site 1032'); process.exit(1); }
|
|
19
|
-
const result = await request('GET', `Entitlements/${args.site}`);
|
|
20
|
-
|
|
21
|
-
console.log(`\nSite ${result.siteId} — plan: ${result.planKey || 'none'} | status: ${result.status}`);
|
|
22
|
-
if (result.cancelAtPeriodEnd) console.log(`⚠️ Cancels at period end: ${result.currentPeriodEnd}`);
|
|
23
|
-
if (result.trialEndAt) console.log(` Trial ends: ${result.trialEndAt}`);
|
|
24
|
-
|
|
25
|
-
const features = Object.entries(result.features || {});
|
|
26
|
-
const enabled = features.filter(([,v]) => v).map(([k]) => k).sort();
|
|
27
|
-
const disabled = features.filter(([,v]) => !v).map(([k]) => k).sort();
|
|
28
|
-
|
|
29
|
-
console.log(`\nEnabled (${enabled.length}):`);
|
|
30
|
-
for (const k of enabled) console.log(` ✅ ${k}`);
|
|
31
|
-
|
|
32
|
-
if (args.all) {
|
|
33
|
-
console.log(`\nDisabled (${disabled.length}):`);
|
|
34
|
-
for (const k of disabled) console.log(` ❌ ${k}`);
|
|
35
|
-
} else {
|
|
36
|
-
console.log(`\n(${disabled.length} features disabled — use --all to show them)`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function enterpriseReportsPackage(args) {
|
|
41
|
-
const q = args.site ? `?siteId=${args.site}` : '';
|
|
42
|
-
const pkg = await request('GET', `Entitlements/packages/enterprise-reports${q}`);
|
|
43
|
-
console.log(`
|
|
44
|
-
${pkg.displayName} (${pkg.packageKey}) - plan ${pkg.plan}, default OFF${pkg.siteId ? `, site ${pkg.siteId}` : ''}
|
|
45
|
-
`);
|
|
46
|
-
for (const it of pkg.items) {
|
|
47
|
-
const mark = pkg.siteId ? (it.enabled ? '[ON ] ' : '[off] ') : '';
|
|
48
|
-
console.log(`${mark}${it.ask}. ${it.title}`);
|
|
49
|
-
console.log(` key: ${it.featureKey}; builds on: ${it.buildsOn.join(', ')}`);
|
|
50
|
-
console.log(` ${it.summary}`);
|
|
51
|
-
}
|
|
52
|
-
console.log('');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Formats the GET Entitlements/report-packages payload (five category packages nested under Enterprise Reports). Exported for the unit test.
|
|
56
|
-
export function formatReportPackages(pkg) {
|
|
57
|
-
const lines = [];
|
|
58
|
-
const site = pkg.siteId ? `, site ${pkg.siteId}` : '';
|
|
59
|
-
lines.push(`${pkg.top.name} (${pkg.top.slug}) - plan ${pkg.plan}, default OFF${site}${pkg.siteId ? (pkg.top.enabled ? ' [ALL ON]' : '') : ''}`);
|
|
60
|
-
lines.push(` ${pkg.top.tagline}`);
|
|
61
|
-
for (const c of pkg.categories) {
|
|
62
|
-
const state = pkg.siteId ? ` [${c.enabled ? 'ON ' : 'off'}] ${c.enabledCount}/${c.reportCount} reports` : ` ${c.reportCount} reports`;
|
|
63
|
-
lines.push('');
|
|
64
|
-
lines.push(`${c.name} (${c.slug})${state}`);
|
|
65
|
-
lines.push(` ${c.tagline}`);
|
|
66
|
-
for (const r of c.reports) {
|
|
67
|
-
const mark = pkg.siteId ? (r.enabled ? '[ON ] ' : '[off] ') : '';
|
|
68
|
-
lines.push(` ${mark}${r.name} (${r.id}) - package ${r.packageSlug}, key ${r.packageKey}`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return lines.join('\n');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async function reportPackages(args) {
|
|
75
|
-
const q = args.site ? `?siteId=${encodeURIComponent(args.site)}` : '';
|
|
76
|
-
const pkg = await request('GET', `Entitlements/report-packages${q}`);
|
|
77
|
-
console.log(`\n${formatReportPackages(pkg)}\n`);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async function listFeatures() {
|
|
81
|
-
const features = await request('GET', 'Entitlements/features');
|
|
82
|
-
|
|
83
|
-
const byCategory = {};
|
|
84
|
-
for (const f of features) {
|
|
85
|
-
if (!byCategory[f.category]) byCategory[f.category] = [];
|
|
86
|
-
byCategory[f.category].push(f);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
console.log(`\nEntitlementFeature registry (${features.length} features)\n`);
|
|
90
|
-
for (const [cat, rows] of Object.entries(byCategory).sort()) {
|
|
91
|
-
console.log(`── ${cat.toUpperCase()} (${rows.length}) ──`);
|
|
92
|
-
for (const f of rows) console.log(` ${f.featureKey.padEnd(40)} ${f.displayName}`);
|
|
93
|
-
console.log('');
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async function setOverride(args) {
|
|
98
|
-
if (!args.site || !args.key) {
|
|
99
|
-
console.error('Usage: velaro entitlement set-override --site 1032 --key EnableIvr --value true [--reason "Custom deal"]');
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
const value = args.value === 'true' || args.value === true;
|
|
103
|
-
await request('POST', `Entitlements/${args.site}/override`, {
|
|
104
|
-
featureKey: args.key,
|
|
105
|
-
value,
|
|
106
|
-
reason: args.reason,
|
|
107
|
-
});
|
|
108
|
-
console.log(`✅ Site ${args.site}: ${args.key} = ${value}${args.reason ? ` (${args.reason})` : ''}`);
|
|
109
|
-
}
|
|
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
|
-
|
|
138
|
-
async function seed() {
|
|
139
|
-
const result = await request('POST', 'Entitlements/admin/seed');
|
|
140
|
-
console.log(`✅ ${result.message}`);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async function compSite(args) {
|
|
144
|
-
if (!args.site || !args.plan) {
|
|
145
|
-
console.error('Usage: velaro entitlement comp --site 1032 --plan plan.professional [--until 2027-01-01] [--notes "Custom deal"]');
|
|
146
|
-
process.exit(1);
|
|
147
|
-
}
|
|
148
|
-
const result = await request('POST', `Entitlements/admin/comp/${args.site}`, {
|
|
149
|
-
planKey: args.plan,
|
|
150
|
-
compEndAt: args.until ?? null,
|
|
151
|
-
notes: args.notes,
|
|
152
|
-
});
|
|
153
|
-
const expiry = result.compEndAt ? ` — expires ${result.compEndAt}` : ' — indefinite';
|
|
154
|
-
console.log(`✅ Site ${args.site} comped on plan ${result.planKey}${expiry}`);
|
|
155
|
-
console.log(` Use 'velaro entitlement set-override --site ${args.site} ...' to customize features.`);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async function removeOverride(args) {
|
|
159
|
-
if (!args.site || !args.key) {
|
|
160
|
-
console.error('Usage: velaro entitlement remove-override --site 1032 --key EnableIvr');
|
|
161
|
-
process.exit(1);
|
|
162
|
-
}
|
|
163
|
-
await request('DELETE', `Entitlements/${args.site}/override/${args.key}`);
|
|
164
|
-
console.log(`✅ Removed override for ${args.key} on site ${args.site}.`);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
async function seedPlans() {
|
|
168
|
-
const result = await request('POST', 'Entitlements/admin/seed-plans');
|
|
169
|
-
if (result.error) { console.error(`❌ ${result.error}`); process.exit(1); }
|
|
170
|
-
console.log(`✅ Plan entitlements seeded: ${result.plansSeeded} plans, ${result.inserted} inserted, ${result.updated} versioned, ${result.unchanged} unchanged.`);
|
|
171
|
-
if (result.plans?.length) console.log(` Plans: ${result.plans.join(', ')}`);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
async function backfill() {
|
|
175
|
-
const result = await request('POST', 'Entitlements/admin/backfill-subscriptions');
|
|
176
|
-
console.log(`✅ Backfill: ${result.inserted} inserted, ${result.skipped} already existed, ${result.unknownPlan} skipped (unknown plan).`);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
async function backfillSapTiers(args) {
|
|
180
|
-
const result = await request('POST', `Entitlements/admin/backfill-sap-tiers?dryRun=${args.apply ? 'false' : 'true'}`);
|
|
181
|
-
if (result.error) { console.error(`❌ ${result.error}`); process.exit(1); }
|
|
182
|
-
console.log(`${args.apply ? '✅ APPLIED' : '🔍 DRY RUN'}: ${JSON.stringify(result, null, 2)}`);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
async function backfillLegacyWriteTiers(args) {
|
|
186
|
-
const result = await request('POST', `Entitlements/admin/backfill-legacy-write-tiers?dryRun=${args.apply ? 'false' : 'true'}`);
|
|
187
|
-
if (result.error) { console.error(`❌ ${result.error}`); process.exit(1); }
|
|
188
|
-
console.log(`${args.apply ? '✅ APPLIED' : '🔍 DRY RUN'}: ${JSON.stringify(result, null, 2)}`);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
async function reconcile(args) {
|
|
192
|
-
if (!args.site) {
|
|
193
|
-
console.error('Usage: velaro entitlement reconcile --site 1032');
|
|
194
|
-
process.exit(1);
|
|
195
|
-
}
|
|
196
|
-
const result = await request('GET', `Entitlements/admin/reconcile/${args.site}`);
|
|
197
|
-
const status = result.deltaCount === 0
|
|
198
|
-
? `✅ ZERO deltas — site ${args.site} is ready for entitlements cutover`
|
|
199
|
-
: `⚠️ ${result.deltaCount} delta(s) — NOT ready for cutover`;
|
|
200
|
-
console.log(`\n${status}`);
|
|
201
|
-
console.log(`Plan: ${result.planKey || 'none'} | Flags checked: ${result.totalFlags} | Matching: ${result.matching}`);
|
|
202
|
-
if (result.deltas?.length) {
|
|
203
|
-
console.log('\nDeltas:');
|
|
204
|
-
for (const d of result.deltas)
|
|
205
|
-
console.log(` ${d.featureKey}: Subscription=${d.subscriptionValue} → Entitlements=${d.entitlementValue}`);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
async function trial(args) {
|
|
210
|
-
const sub = args.action;
|
|
211
|
-
const need = (v, n) => { if (v === undefined || v === null || v === '') { console.error(`--${n} is required for trial ${sub}`); process.exit(1); } };
|
|
212
|
-
if (sub === 'get' || sub === 'recommend') {
|
|
213
|
-
need(args.site, 'site');
|
|
214
|
-
const r = await request('GET', `Entitlements/${args.site}/trial${sub === 'recommend' ? '/recommendation' : ''}`);
|
|
215
|
-
console.log(JSON.stringify(r, null, 2));
|
|
216
|
-
} else if (sub === 'not-paying') {
|
|
217
|
-
console.log(JSON.stringify(await request('GET', 'Entitlements/admin/trial/not-paying'), null, 2));
|
|
218
|
-
} else if (sub === 'grant') {
|
|
219
|
-
need(args.site, 'site'); need(args.feature, 'feature'); need(args.reason, 'reason');
|
|
220
|
-
const r = await request('POST', `Entitlements/${args.site}/trial/grant`, { featureKey: args.feature, reason: args.reason });
|
|
221
|
-
console.log(`Site ${args.site}: ${r.featureKey} granted for the trial (${r.state}).`);
|
|
222
|
-
} else if (sub === 'hold' || sub === 'reactivate') {
|
|
223
|
-
need(args.site, 'site');
|
|
224
|
-
const body = { featureKey: args.feature, dryRun: !!args['dry-run'] };
|
|
225
|
-
console.log(JSON.stringify(await request('POST', `Entitlements/${args.site}/trial/${sub}`, body)));
|
|
226
|
-
} else if (sub === 'set-limit') {
|
|
227
|
-
need(args.site, 'site'); need(args.key, 'key'); need(args.value, 'value'); need(args.reason, 'reason');
|
|
228
|
-
const r = await request('POST', `Entitlements/${args.site}/trial/limit`, { key: args.key, value: Number(args.value), reason: args.reason });
|
|
229
|
-
console.log(`Site ${args.site}: ${r.key} ${r.old} -> ${r.value}.`);
|
|
230
|
-
} else if (sub === 'set-text') {
|
|
231
|
-
need(args.feature, 'feature');
|
|
232
|
-
console.log(JSON.stringify(await request('POST', 'Entitlements/admin/trial/feature-text', { featureKey: args.feature, text: args.text })));
|
|
233
|
-
} else if (sub === 'approve-limit' || sub === 'deny-limit') {
|
|
234
|
-
need(args.request, 'request');
|
|
235
|
-
if (sub === 'approve-limit') {
|
|
236
|
-
need(args.key, 'key'); need(args.value, 'value');
|
|
237
|
-
console.log(JSON.stringify(await request('POST', `Entitlements/admin/trial/limit-request/${args.request}/approve`, { key: args.key, value: Number(args.value), message: args.message })));
|
|
238
|
-
} else {
|
|
239
|
-
need(args.reason, 'reason');
|
|
240
|
-
console.log(JSON.stringify(await request('POST', `Entitlements/admin/trial/limit-request/${args.request}/deny`, { reason: args.reason })));
|
|
241
|
-
}
|
|
242
|
-
} else {
|
|
243
|
-
console.error('Unknown trial action. Use: get | recommend | not-paying | grant | hold | reactivate | set-limit | approve-limit | deny-limit | set-text');
|
|
244
|
-
process.exit(1);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
async function setLock(args) {
|
|
249
|
-
if (!args.site) {
|
|
250
|
-
console.error('Usage: velaro entitlement set-lock --site 1032 --at 2026-01-01T00:00:00Z\n velaro entitlement set-lock --site 1032 --unlock');
|
|
251
|
-
process.exit(1);
|
|
252
|
-
}
|
|
253
|
-
if (!args.at && !args.unlock) {
|
|
254
|
-
console.error('Pass --at <ISO 8601 timestamp> to lock, or --unlock to clear an existing lock.');
|
|
255
|
-
process.exit(1);
|
|
256
|
-
}
|
|
257
|
-
const lockedAt = args.unlock ? null : args.at;
|
|
258
|
-
const result = await request('PUT', `Entitlements/admin/lock/${args.site}`, { lockedAt });
|
|
259
|
-
if (lockedAt) {
|
|
260
|
-
console.log(`✅ Site ${args.site} entitlements locked to ${result.entitlementLockedAt} (plan ${result.planKey}).`);
|
|
261
|
-
} else {
|
|
262
|
-
console.log(`✅ Site ${args.site} entitlement lock cleared — resolves against the current plan version again.`);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
async function listCutover() {
|
|
267
|
-
const result = await request('GET', 'Entitlements/admin/cutover');
|
|
268
|
-
console.log(`\nCutover flags: ${result.liveCount} live / ${result.total} total`);
|
|
269
|
-
const live = (result.flags || []).filter(f => f.isLive);
|
|
270
|
-
const pending = (result.flags || []).filter(f => !f.isLive);
|
|
271
|
-
if (live.length) {
|
|
272
|
-
console.log('\n✅ Live (messaging reads admin instead of Subscription.cs):');
|
|
273
|
-
for (const f of live) console.log(` ${f.featureKey} (since ${f.wentLiveAt?.slice(0,10) || 'n/a'})`);
|
|
274
|
-
}
|
|
275
|
-
if (pending.length) {
|
|
276
|
-
console.log(`\n⏸ Not live (${pending.length} flags) — use 'set-cutover' to flip`);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
async function setCutover(args) {
|
|
281
|
-
if (!args.key) {
|
|
282
|
-
console.error('Usage: velaro entitlement set-cutover --key EnableIvr --live [--rollback]');
|
|
283
|
-
process.exit(1);
|
|
284
|
-
}
|
|
285
|
-
const isLive = !args.rollback;
|
|
286
|
-
const result = await request('PUT', `Entitlements/admin/cutover/${args.key}`, { isLive });
|
|
287
|
-
console.log(result.message);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
export function entitlementCommand(yargs) {
|
|
291
|
-
return yargs
|
|
292
|
-
.command('get', 'Get resolved feature set for a site', y => y
|
|
293
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
294
|
-
.option('all', { type: 'boolean', desc: 'Show disabled features too (default: enabled only)' })
|
|
295
|
-
, a => getSite(a))
|
|
296
|
-
.command('list-features', 'List all registered entitlement feature keys', () => {}, () => listFeatures())
|
|
297
|
-
.command('enterprise-reports', 'Show the Enterprise Reports package items (with --site, which are ON for that site)', y => y
|
|
298
|
-
.option('site', { type: 'number', desc: 'Site ID' })
|
|
299
|
-
, a => enterpriseReportsPackage(a))
|
|
300
|
-
.command('report-packages', 'Show the five report category packages and every report in them (with --site, which are ON for that site)', y => y
|
|
301
|
-
.option('site', { type: 'number', desc: 'Site ID' })
|
|
302
|
-
, a => reportPackages(a))
|
|
303
|
-
.command('set-override', 'Enable or disable a feature for a specific site (overrides plan)', y => y
|
|
304
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
305
|
-
.option('key', { type: 'string', demandOption: true, desc: 'Feature key, e.g. EnableIvr' })
|
|
306
|
-
.option('value', { type: 'string', demandOption: true, desc: 'true or false' })
|
|
307
|
-
.option('reason', { type: 'string', desc: 'Reason / notes for the override' })
|
|
308
|
-
, a => setOverride(a))
|
|
309
|
-
.command('remove-override', 'Remove a per-site override, reverting to plan default', y => y
|
|
310
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
311
|
-
.option('key', { type: 'string', demandOption: true, desc: 'Feature key to un-override' })
|
|
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))
|
|
326
|
-
.command('seed', 'Seed the EntitlementFeature registry (idempotent, superadmin only)', () => {}, () => seed())
|
|
327
|
-
.command('seed-plans', 'Seed PlanEntitlement rows from live PackageVersions in messaging DB (idempotent, superadmin only)', () => {}, () => seedPlans())
|
|
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))
|
|
329
|
-
.command('backfill-legacy-write-tiers', 'Grant EnableServiceNowWrite/AccelaWrite/QuickBooksWrite to existing sites after the OR-gate sweep (dry run unless --apply; superadmin only)', (y) => y.option('apply', { type: 'boolean', default: false, describe: 'Write the grants (default is a dry run)' }), (a) => backfillLegacyWriteTiers(a))
|
|
330
|
-
.command('backfill', 'Backfill SiteSubscription rows from active Subscription rows in messaging DB (idempotent, superadmin only)', () => {}, () => backfill())
|
|
331
|
-
.command('reconcile', 'Diff Subscription.cs vs Entitlements API for a site — zero deltas = ready for cutover', y => y
|
|
332
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
333
|
-
, a => reconcile(a))
|
|
334
|
-
.command('comp', 'Comp a site on a plan (creates a SiteSubscription so overrides can be set)', y => y
|
|
335
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
336
|
-
.option('plan', { type: 'string', demandOption: true, desc: 'Plan key, e.g. plan.professional' })
|
|
337
|
-
.option('until', { type: 'string', desc: 'ISO 8601 comp expiry date (omit for indefinite)' })
|
|
338
|
-
.option('notes', { type: 'string', desc: 'Internal notes' })
|
|
339
|
-
, a => compSite(a))
|
|
340
|
-
.command('set-lock', 'Lock a site\'s entitlement resolution to a point-in-time plan version, or clear an existing lock', y => y
|
|
341
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
342
|
-
.option('at', { type: 'string', desc: 'ISO 8601 timestamp to lock entitlement resolution to' })
|
|
343
|
-
.option('unlock', { type: 'boolean', desc: 'Clear an existing lock (resolves against current plan version again)' })
|
|
344
|
-
, a => setLock(a))
|
|
345
|
-
.command('sync-stripe', 'Sync the Stripe subscription state into its entitlement record (superadmin only)', y => y
|
|
346
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
347
|
-
.option('status', { type: 'string', demandOption: true, desc: 'Stripe subscription status, e.g. active, trialing, canceled' })
|
|
348
|
-
.option('plan', { type: 'string', desc: 'Plan key, e.g. plan.professional' })
|
|
349
|
-
.option('cancel-at-period-end', { type: 'boolean', desc: 'Subscription cancels at period end' })
|
|
350
|
-
.option('current-period-end', { type: 'string', desc: 'ISO 8601 current period end' })
|
|
351
|
-
.option('trial-end-at', { type: 'string', desc: 'ISO 8601 trial end' })
|
|
352
|
-
.option('stripe-customer-id', { type: 'string', desc: 'Stripe customer id' })
|
|
353
|
-
.option('stripe-subscription-id', { type: 'string', desc: 'Stripe subscription id' })
|
|
354
|
-
, a => syncStripe(a))
|
|
355
|
-
.command('trial <action>', 'Trial governance (superadmin): get | recommend | not-paying | grant | hold | reactivate | set-limit | approve-limit | deny-limit | set-text', y => y
|
|
356
|
-
.option('site', { type: 'number', desc: 'Site ID' })
|
|
357
|
-
.option('feature', { type: 'string', desc: 'Feature key, e.g. EnableIvr' })
|
|
358
|
-
.option('key', { type: 'string', desc: 'Cap name, e.g. MaxKbArticles' })
|
|
359
|
-
.option('value', { type: 'string', desc: 'Whole number cap' })
|
|
360
|
-
.option('reason', { type: 'string', desc: 'Reason (audited)' })
|
|
361
|
-
.option('request', { type: 'number', desc: 'Limit-increase request id' })
|
|
362
|
-
.option('message', { type: 'string', desc: 'approve-limit: note added to the customer reply' })
|
|
363
|
-
.option('text', { type: 'string', desc: 'set-text: customer-safe, number-free limit text' })
|
|
364
|
-
.option('dry-run', { type: 'boolean', desc: 'hold: report only, write nothing' })
|
|
365
|
-
, a => trial(a))
|
|
366
|
-
.command('list-cutover', 'List all feature keys and whether they are live (messaging reads admin) or not (Subscription.cs)', () => {}, () => listCutover())
|
|
367
|
-
.command('set-cutover', 'Flip a feature key live (or roll it back). Live = messaging reads admin value within 45s. --rollback reverts to Subscription.cs.', y => y
|
|
368
|
-
.option('key', { type: 'string', demandOption: true, desc: 'Feature key, e.g. EnableIvr' })
|
|
369
|
-
.option('rollback', { type: 'boolean', desc: 'Pass to roll back this flag to Subscription.cs (default: go live)' })
|
|
370
|
-
, a => setCutover(a))
|
|
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');
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// Registered group object (the CLI/MCP parity validator reads `command:` from a named const).
|
|
375
|
-
export const entitlementGroup = { command: 'entitlement', desc: 'Query and manage site feature entitlements (superadmin only)', builder: entitlementCommand, handler: () => {} };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { request } from '../api.js';
|
|
2
|
-
import { runCommand } from '../run.js';
|
|
3
|
-
|
|
4
|
-
// velaro image-analysis limits --site N
|
|
5
|
-
// Shows the Image Analysis (analyze_image) add-on cap and usage for any site (Velaro admin only).
|
|
6
|
-
// To change the cap: velaro support set-limit --site N --key MaxImageAnalysesPerMonth --value 500
|
|
7
|
-
export const imageAnalysisCommand = {
|
|
8
|
-
command: 'image-analysis <subcommand>',
|
|
9
|
-
describe: 'Image Analysis add-on limits and usage (Velaro admin only)',
|
|
10
|
-
builder: yargs => yargs
|
|
11
|
-
.command({
|
|
12
|
-
command: 'limits',
|
|
13
|
-
describe: 'Show monthly cap, usage this month and per-chat cap for a site',
|
|
14
|
-
builder: y => y.option('site', { type: 'number', demandOption: true, describe: 'Site ID' }),
|
|
15
|
-
handler: runCommand(async argv => {
|
|
16
|
-
const d = await request('GET', `/ImageAnalysisLimits/superadmin?siteId=${argv.site}`);
|
|
17
|
-
const ent = d.entitled === null ? 'unknown' : d.entitled ? 'yes' : 'no';
|
|
18
|
-
console.log(`\nSite ${argv.site}: Image Analysis`);
|
|
19
|
-
console.log(` Entitled: ${ent}`);
|
|
20
|
-
console.log(` Monthly cap: ${d.monthlyCap} (effective ${d.effectiveMonthlyCap}, hard cap, no automatic overage)`);
|
|
21
|
-
console.log(` Used this month: ${d.usedThisMonth === null ? 'unknown' : d.usedThisMonth}`);
|
|
22
|
-
console.log(` Per-chat cap: ${d.perConversationCap}`);
|
|
23
|
-
console.log(` Extra block size: ${d.blockSize}\n`);
|
|
24
|
-
}),
|
|
25
|
-
})
|
|
26
|
-
.demandCommand(1),
|
|
27
|
-
};
|