@velaro/cli 1.4.120 → 1.4.122
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/signature.js +39 -3
- package/lib/commands/teams.js +1 -1
- package/lib/commands/woocommerce.js +1 -1
- package/lib/commands/workflow.js +4 -31
- package/lib/signature-policy.js +42 -0
- package/lib/signature-policy.test.js +28 -2
- 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,102 +0,0 @@
|
|
|
1
|
-
// velaro subscription — apply/diff SubscriptionPackage packages on a site (superadmin only)
|
|
2
|
-
// Wraps SuperAdminController.ApplyPackageToSiteAsync / GetPackageDiffAsync in velaro-messaging,
|
|
3
|
-
// the same reflection-copy service the SuperAdmin browser UI uses -- never hand-toggles flags.
|
|
4
|
-
import { messagingPost, messagingGet, messagingPut } from '../api.js';
|
|
5
|
-
import { planChanges, parseFlagList, diffRows, verifyOnlyIntendedChanged } from '../site-flags.js';
|
|
6
|
-
|
|
7
|
-
async function applyPackage(args) {
|
|
8
|
-
if (!args.site || !args.package) {
|
|
9
|
-
console.error('Usage: velaro subscription apply-package --site 100150 --package 3 [--version 3] [--autoUpgrade] [--resetOverrides]');
|
|
10
|
-
process.exit(1);
|
|
11
|
-
}
|
|
12
|
-
const body = {
|
|
13
|
-
PackageId: args.package,
|
|
14
|
-
VersionId: args.version ?? null,
|
|
15
|
-
AutoUpgrade: !!args.autoUpgrade,
|
|
16
|
-
ResetOverrides: !!args.resetOverrides,
|
|
17
|
-
};
|
|
18
|
-
const result = await messagingPost(`SuperAdmin/subscription/${args.site}/apply-package`, body);
|
|
19
|
-
console.log(JSON.stringify(result, null, 2));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function packageDiff(args) {
|
|
23
|
-
if (!args.site) {
|
|
24
|
-
console.error('Usage: velaro subscription package-diff --site 100150');
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
const result = await messagingGet(`SuperAdmin/subscription/${args.site}/package-diff`);
|
|
28
|
-
console.log(JSON.stringify(result, null, 2));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Flip Enable* entitlement flags on exactly ONE site. Reads, prints the diff, PUTs only the
|
|
32
|
-
// changed flags, re-reads, prints before/after and the rollback snapshot id. The server
|
|
33
|
-
// snapshots before every PUT (SuperAdminController.UpdateSubscriptionAsync).
|
|
34
|
-
async function setFlags(args) {
|
|
35
|
-
const site = args.site;
|
|
36
|
-
if (!Number.isInteger(site) || site <= 0) {
|
|
37
|
-
console.error('set-flags takes exactly one --site <id> per call.');
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
const enable = parseFlagList(args.enable);
|
|
41
|
-
const disable = parseFlagList(args.disable);
|
|
42
|
-
const before = await messagingGet(`SuperAdmin/subscription/${site}`);
|
|
43
|
-
const plan = planChanges(before, enable, disable);
|
|
44
|
-
if (!plan.ok) { plan.errors.forEach(e => console.error(`x ${e}`)); process.exit(1); }
|
|
45
|
-
|
|
46
|
-
console.log(`\nSite ${site}: intended changes`);
|
|
47
|
-
for (const c of plan.changes) console.log(` ${c.key}: ${c.before} -> ${c.after}${c.before === c.after ? ' (already set, no-op)' : ''}`);
|
|
48
|
-
const real = plan.changes.filter(c => c.before !== c.after);
|
|
49
|
-
if (real.length === 0) { console.log('\nNothing to change.'); return; }
|
|
50
|
-
if (args['dry-run']) { console.log('\nDry run: no changes made.'); return; }
|
|
51
|
-
if (!args.yes) { console.log('\nAdd --yes to apply (or --dry-run to preview only). No changes made.'); return; }
|
|
52
|
-
|
|
53
|
-
const body = {};
|
|
54
|
-
for (const c of real) body[c.flag] = c.after;
|
|
55
|
-
const result = await messagingPut(`SuperAdmin/subscription/${site}`, body);
|
|
56
|
-
if (result && result.success === false) { console.error(`x Server rejected the update: ${result.error}`); process.exit(1); }
|
|
57
|
-
|
|
58
|
-
const after = await messagingGet(`SuperAdmin/subscription/${site}`);
|
|
59
|
-
console.log('\nAfter (re-read from server):');
|
|
60
|
-
for (const d of diffRows(before, after)) console.log(` ${d.key}: ${JSON.stringify(d.before)} -> ${JSON.stringify(d.after)}`);
|
|
61
|
-
|
|
62
|
-
const history = await messagingGet(`SuperAdmin/subscription/${site}/history`);
|
|
63
|
-
const snap = Array.isArray(history) ? (history.find(h => /before-update/i.test(h.reason ?? h.Reason ?? '')) ?? history[0]) : null;
|
|
64
|
-
const snapId = snap ? (snap.id ?? snap.Id) : null;
|
|
65
|
-
console.log(snapId != null
|
|
66
|
-
? `\nRollback snapshot id: ${snapId} (POST SuperAdmin/subscription/${site}/rollback/${snapId})`
|
|
67
|
-
: '\nWarning: no snapshot found in history; check SuperAdmin history before relying on rollback.');
|
|
68
|
-
|
|
69
|
-
if (args.verify) {
|
|
70
|
-
const v = verifyOnlyIntendedChanged(before, after, real);
|
|
71
|
-
if (!v.ok) {
|
|
72
|
-
console.error('\nx VERIFY FAILED');
|
|
73
|
-
v.missing.forEach(m => console.error(` not applied: ${m.key}`));
|
|
74
|
-
v.unexpected.forEach(u => console.error(` unexpected change: ${u.key} ${JSON.stringify(u.before)} -> ${JSON.stringify(u.after)}`));
|
|
75
|
-
process.exit(2);
|
|
76
|
-
}
|
|
77
|
-
console.log('\nVerify OK: only the requested flags changed.');
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function subscriptionCommand(yargs) {
|
|
82
|
-
return yargs
|
|
83
|
-
.command('apply-package', 'Apply a SubscriptionPackage to a site (superadmin only) -- correct reflection-copy path, never hand-toggles flags', y => y
|
|
84
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Target site ID' })
|
|
85
|
-
.option('package', { type: 'number', demandOption: true, desc: 'SubscriptionPackage.Id (e.g. 3 = Enterprise) -- verify by name in SuperAdmin first, IDs can drift between staging/prod' })
|
|
86
|
-
.option('version', { type: 'number', desc: 'Specific PackageVersion.Id (omit to use the package\'s latest published version)' })
|
|
87
|
-
.option('autoUpgrade', { type: 'boolean', desc: 'Auto-upgrade this site to future published versions of the package' })
|
|
88
|
-
.option('resetOverrides', { type: 'boolean', desc: 'Clear any existing per-site Subscription overrides before applying' })
|
|
89
|
-
, a => applyPackage(a))
|
|
90
|
-
.command('package-diff', 'Show what would change if the site\'s current package were re-applied (read-only)', y => y
|
|
91
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Target site ID' })
|
|
92
|
-
, a => packageDiff(a))
|
|
93
|
-
.command('set-flags', 'Flip Enable* entitlement flags on ONE site (superadmin only). Allowlisted flags only: never billing, package or limit fields', y => y
|
|
94
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Exactly one target site ID' })
|
|
95
|
-
.option('enable', { type: 'string', desc: 'Comma-separated Enable* flags to turn ON, e.g. EnableAgentDashboard,EnableCustomDashboards' })
|
|
96
|
-
.option('disable', { type: 'string', desc: 'Comma-separated Enable* flags to turn OFF' })
|
|
97
|
-
.option('dry-run', { type: 'boolean', desc: 'Print the intended diff and stop' })
|
|
98
|
-
.option('yes', { type: 'boolean', desc: 'Apply. Without it (or with --dry-run) nothing is written' })
|
|
99
|
-
.option('verify', { type: 'boolean', desc: 'After applying, confirm ONLY the requested flags changed (exit 2 otherwise)' })
|
|
100
|
-
, a => setFlags(a))
|
|
101
|
-
.demandCommand(1, 'Specify a subcommand: apply-package | package-diff | set-flags');
|
|
102
|
-
}
|
package/lib/commands/support.js
DELETED
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
// velaro support — staff SupportTools / staff-scoped actions (superadmin only)
|
|
2
|
-
import { request, messagingPost, messagingGet } from '../api.js';
|
|
3
|
-
import { ensureSiteUser } from '../siteUser.js';
|
|
4
|
-
|
|
5
|
-
async function toggleFlag(args) {
|
|
6
|
-
if (!args.site || !args.flag || args.enabled === undefined) {
|
|
7
|
-
console.error('Usage: velaro support toggle-flag --site 1032 --flag EnableScraperBotIndexing --enabled true');
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
const enabled = args.enabled === 'true' || args.enabled === true;
|
|
11
|
-
const result = await request('POST', `SupportTools/sites/${args.site}/features/${args.flag}`, { enabled });
|
|
12
|
-
console.log(`✅ Site ${args.site}: ${result.flag} ${result.oldValue} → ${result.newValue}`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function setLimit(args) {
|
|
16
|
-
const n = Number(args.value);
|
|
17
|
-
if (!args.site || !args.key || !Number.isInteger(n) || n < 0) {
|
|
18
|
-
console.error('Usage: velaro support set-limit --site 1032 --key maxBotTurnsPerMonth --value 10000');
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
const result = await request('POST', `SupportTools/sites/${args.site}/subscription/bulk-flags`, { flags: { [args.key]: n } });
|
|
22
|
-
console.log(`Site ${args.site}: applied ${(result.applied || []).join(', ') || '(none)'}`);
|
|
23
|
-
if ((result.skipped || []).length) {
|
|
24
|
-
console.error(`Skipped: ${result.skipped.join(', ')}`);
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Read-back for set-limit: GET SupportTools/sites/{id}/subscription/limits (messaging API, staff only).
|
|
30
|
-
async function getLimit(args) {
|
|
31
|
-
if (!args.site) {
|
|
32
|
-
console.error('Usage: velaro support get-limit --site 100140 [--key maxWorkflowRunsPerMonth]');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
const qs = args.key ? `?key=${encodeURIComponent(args.key)}` : '';
|
|
36
|
-
const r = await messagingGet(`SupportTools/sites/${args.site}/subscription/limits${qs}`);
|
|
37
|
-
if (args.json) { console.log(JSON.stringify(r, null, 2)); return; }
|
|
38
|
-
console.log(`Site ${r.siteId} (package version ${r.packageVersionId ?? 'none'}, overage: ${r.overageBehavior})`);
|
|
39
|
-
const fmt = v => (v === null || v === undefined ? '-' : String(v));
|
|
40
|
-
console.log('\nField'.padEnd(42) + 'Sub'.padEnd(12) + 'Plan'.padEnd(12) + 'Effective'.padEnd(12) + 'Override');
|
|
41
|
-
for (const f of r.fields || []) {
|
|
42
|
-
console.log(f.key.padEnd(41) + fmt(f.subscriptionValue).padEnd(12) + fmt(f.planValue).padEnd(12) + fmt(f.effective).padEnd(12) + (f.isOverride ? 'yes' : ''));
|
|
43
|
-
}
|
|
44
|
-
console.log('\nMetric (what enforcement checks)'.padEnd(42) + 'Effective'.padEnd(12) + 'Plan'.padEnd(12) + 'Cached'.padEnd(12) + 'Override');
|
|
45
|
-
for (const m of r.metrics || []) {
|
|
46
|
-
console.log(m.metric.padEnd(41) + fmt(m.effective).padEnd(12) + fmt(m.planValue).padEnd(12) + (fmt(m.cachedEffective) + (m.cacheStale ? ' (stale)' : '')).padEnd(12) + (m.isOverride ? 'yes' : ''));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Temporary grant: +N units on a metered cap until the period rolls over, then back to the plan value (no cleanup).
|
|
51
|
-
async function grantLimit(args) {
|
|
52
|
-
const n = Number(args.amount);
|
|
53
|
-
if (!args.site || !args.metric || !Number.isInteger(n) || n < 0) {
|
|
54
|
-
console.error('Usage: velaro support grant-limit --site 100140 --metric workflow_runs --amount 400 (amount 0 clears)');
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
const r = await messagingPost(`SupportTools/sites/${args.site}/subscription/temporary-grant`, { metric: args.metric, amount: n });
|
|
58
|
-
console.log(`Site ${r.siteId}: +${r.grantAmount} ${r.metric} until ${r.expiresAtPacific}; effective limit now ${r.effectiveLimitNow ?? '?'}. ${r.note}`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function scraperCreateJob(args) {
|
|
62
|
-
if (!args.site || !args.urls) {
|
|
63
|
-
console.error('Usage: velaro support scraper-create-job --site 1032 --urls "https://example.com" [--maxPages 30] [--crawlDepth 2] [--name "job name"]');
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
const urls = String(args.urls).split(',').map(u => u.trim()).filter(Boolean);
|
|
67
|
-
const body = {
|
|
68
|
-
name: args.name || `staff-triggered-${Date.now()}`,
|
|
69
|
-
urls,
|
|
70
|
-
crawlDepth: args.crawlDepth ?? 1,
|
|
71
|
-
maxPages: args.maxPages ?? 25,
|
|
72
|
-
};
|
|
73
|
-
const result = await request('POST', `ScraperJobs/StaffCreate/${args.site}`, body);
|
|
74
|
-
console.log(JSON.stringify(result, null, 2));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async function chatQuery(args) {
|
|
78
|
-
if (!args.site || !args.aiConfigId || !args.query) {
|
|
79
|
-
console.error('Usage: velaro support chat-query --site 100150 --aiConfigId 179 --query "your test question" [--channel Web]');
|
|
80
|
-
process.exit(1);
|
|
81
|
-
}
|
|
82
|
-
const body = {
|
|
83
|
-
aiConfigId: args.aiConfigId,
|
|
84
|
-
query: args.query,
|
|
85
|
-
channel: args.channel || 'Web',
|
|
86
|
-
overrideIndexes: args.overrideIndexes ? String(args.overrideIndexes).split(',').map(s => s.trim()).filter(Boolean) : undefined,
|
|
87
|
-
};
|
|
88
|
-
// Hits velaro-messaging's AzureIndexes/StaffChatQuery/{targetSiteId} -- staff-only override for
|
|
89
|
-
// the customer-facing test-chat (ChatQuery) endpoint, added 2026-08-21 so a Velaro staff member
|
|
90
|
-
// can adversarial-test ANY site's bot without needing that site's own login.
|
|
91
|
-
const result = await messagingPost(`AzureIndexes/StaffChatQuery/${args.site}`, body);
|
|
92
|
-
console.log(JSON.stringify(result, null, 2));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async function impersonate(args) {
|
|
96
|
-
if (!args.site) {
|
|
97
|
-
console.error('Usage: velaro support impersonate --site 100150 (SuperAdmin only; creates a 15-minute X-Support-Token to act as that site\'s admin, fully audit-logged)');
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}
|
|
100
|
-
// Hits SupportToolsController.CreateImpersonationSession (SuperAdmin only, 15-min token,
|
|
101
|
-
// logged to both BillingAuditLog and the app logger). Added 2026-08-28 to close the gap where
|
|
102
|
-
// the backend endpoint existed but no CLI verb wrapped it.
|
|
103
|
-
const result = await request('POST', `SupportTools/sites/${args.site}/impersonate`);
|
|
104
|
-
console.log(`Impersonation session created for site ${args.site}, expires ${result.expiresAt}`);
|
|
105
|
-
console.log(`Token: ${result.token}`);
|
|
106
|
-
console.log('Send this as header X-Support-Token on subsequent requests to act as that site\'s admin.');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async function sendEmail(args) {
|
|
110
|
-
if (!args.to || !args.subject || !args.html) {
|
|
111
|
-
console.error('Usage: velaro support send-email --to andrea@velaro.com --subject "..." --html "<p>...</p>" [--cc alex@velaro.com]');
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
114
|
-
// Hits velaro-messaging's SupportTools/send-internal-email -- staff JWT or internal-site
|
|
115
|
-
// vel_live_* key, same auth pattern as every other SupportTools action, never the raw
|
|
116
|
-
// X-Velaro-Internal-Secret. Restricted server-side to @velaro.com recipients on purpose,
|
|
117
|
-
// this is for internal staff notifications, not a general external-send relay. Added
|
|
118
|
-
// 2026-09-01 to close the gap where the only working path required manually fetching a
|
|
119
|
-
// raw production secret via az.
|
|
120
|
-
const result = await messagingPost('SupportTools/send-internal-email', {
|
|
121
|
-
to: args.to,
|
|
122
|
-
cc: args.cc,
|
|
123
|
-
subject: args.subject,
|
|
124
|
-
html: args.html,
|
|
125
|
-
});
|
|
126
|
-
console.log(`✅ Sent to ${result.sentCount}/${result.of} recipient(s).`);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
async function agentLookup(args) {
|
|
130
|
-
if (!args.id) {
|
|
131
|
-
console.error('Usage: velaro support agent-lookup --id 238');
|
|
132
|
-
process.exit(1);
|
|
133
|
-
}
|
|
134
|
-
// Hits velaro-messaging's SuperAdmin/agents/{id}/lookup -- read-only, cross-site WorkspaceUser.Id
|
|
135
|
-
// resolution for cases where a log line (AgentPresenceFlapping WARN, AgentConnectionLog, etc.)
|
|
136
|
-
// captured only a bare numeric AgentId with no SiteId. Added 2026-08-27.
|
|
137
|
-
const result = await messagingGet(`SuperAdmin/agents/${args.id}/lookup`);
|
|
138
|
-
console.log(JSON.stringify(result, null, 2));
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async function siteAuthMode(args) {
|
|
142
|
-
// Wraps the existing staff endpoints DatabaseTool/AuthMode/{siteId} (GET/PUT). No new backend.
|
|
143
|
-
const site = Number(args.site);
|
|
144
|
-
if (!Number.isInteger(site) || site <= 0) { console.error('site must be a positive integer.'); process.exit(1); }
|
|
145
|
-
try {
|
|
146
|
-
if (args.mode) {
|
|
147
|
-
const allowLocalLogin = args.allowLocalLogin === undefined ? true : (args.allowLocalLogin === true || args.allowLocalLogin === 'true');
|
|
148
|
-
await request('PUT', `DatabaseTool/AuthMode/${site}`, { authMode: args.mode, allowLocalLogin });
|
|
149
|
-
}
|
|
150
|
-
const r = await request('GET', `DatabaseTool/AuthMode/${site}`);
|
|
151
|
-
console.log(JSON.stringify({ siteId: r.siteId, authMode: r.authMode, allowLocalLogin: r.allowLocalLogin, hasConfig: r.hasConfig }));
|
|
152
|
-
} catch (e) {
|
|
153
|
-
console.error(`site-auth-mode failed: ${e.message}`);
|
|
154
|
-
process.exit(1);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async function addSiteUser(args) {
|
|
159
|
-
// Password via --password or VELARO_NEW_USER_PASSWORD env (preferred; keeps it out of shell history). Never printed.
|
|
160
|
-
const password = args.password || process.env.VELARO_NEW_USER_PASSWORD;
|
|
161
|
-
try {
|
|
162
|
-
const r = await ensureSiteUser({ get: messagingGet, post: messagingPost }, { ...args, siteId: args.site, password });
|
|
163
|
-
console.log(`${r.created ? 'Created' : 'Updated existing'} ${r.email} on site ${r.siteId} (userId ${r.userId}, roles ${r.roles.join(',')}); password set, usable immediately.`);
|
|
164
|
-
} catch (e) {
|
|
165
|
-
console.error(`add-site-user failed: ${e.message}`);
|
|
166
|
-
process.exit(1);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
async function listDeployments(args) {
|
|
171
|
-
const result = await request('GET', `SupportTools/sites/${args.site}/deployments`);
|
|
172
|
-
if (args.json) {
|
|
173
|
-
console.log(JSON.stringify(result, null, 2));
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
console.log(`Site ${result.siteId}: ${result.deployments.length} active widget deployment(s)`);
|
|
177
|
-
for (const d of result.deployments) {
|
|
178
|
-
console.log(` ${d.deploymentId || '—'} ${d.displayName || '(unnamed)'} team ${d.teamId} database ID ${d.id}`);
|
|
179
|
-
console.log(` surveys: pre-chat ${d.preChatSurveyId ?? '—'}, post-chat ${d.postChatSurveyId ?? '—'}, unavailable ${d.unavailableSurveyId ?? '—'}`);
|
|
180
|
-
}
|
|
181
|
-
console.log('Use the embed key as test-frame.html?siteId=<site>&deploymentId=<embed-key>.');
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
async function tourInsights(args) {
|
|
185
|
-
const days = Math.min(365, Math.max(1, args.days ?? 30));
|
|
186
|
-
const path = args.site
|
|
187
|
-
? `SupportTools/sites/${args.site}/tour-events?days=${days}`
|
|
188
|
-
: `SupportTools/tour-insights?days=${days}`;
|
|
189
|
-
const result = await request('GET', path);
|
|
190
|
-
console.log(JSON.stringify(result, null, 2));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function windowQuery(args, extra = {}) {
|
|
194
|
-
const q = new URLSearchParams();
|
|
195
|
-
if (args.from) q.set('from', args.from);
|
|
196
|
-
if (args.to) q.set('to', args.to);
|
|
197
|
-
for (const [k, v] of Object.entries(extra)) if (v !== undefined) q.set(k, String(v));
|
|
198
|
-
const s = q.toString();
|
|
199
|
-
return s ? `?${s}` : '';
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
async function connectionTimeline(args) {
|
|
203
|
-
// velaro-messaging SupportToolsController.AgentConnectionTimelineAsync (staff-only, read-only).
|
|
204
|
-
const result = await messagingGet(
|
|
205
|
-
`SupportTools/sites/${args.site}/agents/${args.agent}/connection-timeline${windowQuery(args, { limit: args.limit })}`);
|
|
206
|
-
console.log(JSON.stringify(result, null, 2));
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
async function connectionEvidence(args) {
|
|
210
|
-
// velaro-messaging SupportToolsController.ConnectionEvidenceAsync (staff-only, read-only).
|
|
211
|
-
const result = await messagingGet(
|
|
212
|
-
`SupportTools/sites/${args.site}/connection-evidence${windowQuery(args)}`);
|
|
213
|
-
console.log(JSON.stringify(result, null, 2));
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
async function hubspotCalls(args) {
|
|
217
|
-
// velaro-messaging SupportToolsController.GetHubSpotCallLoggingAsync (staff-only, read-only).
|
|
218
|
-
const take = args.take ? `?take=${encodeURIComponent(args.take)}` : '';
|
|
219
|
-
const result = await messagingGet(`SupportTools/sites/${args.site}/hubspot/calls${take}`);
|
|
220
|
-
console.log(JSON.stringify(result, null, 2));
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export function supportCommand(yargs) {
|
|
224
|
-
return yargs
|
|
225
|
-
.command('connection-timeline', 'Raw ordered agent connection events (connect/disconnect/reconnect) for one agent in a time window (Velaro staff, read-only)', y => y
|
|
226
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
227
|
-
.option('agent', { type: 'number', demandOption: true, desc: 'WorkspaceUser.Id of the agent' })
|
|
228
|
-
.option('from', { type: 'string', desc: 'ISO start (default: 24h before --to)' })
|
|
229
|
-
.option('to', { type: 'string', desc: 'ISO end (default: now)' })
|
|
230
|
-
.option('limit', { type: 'number', default: 2000, desc: 'Max events (1-5000)' })
|
|
231
|
-
, a => connectionTimeline(a))
|
|
232
|
-
.command('hubspot-calls', 'HubSpot call-logging snapshot for a site: connection state and the last N calls with their HubSpot log row (Velaro staff, read-only)', y => y
|
|
233
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
234
|
-
.option('take', { type: 'number', desc: 'Number of recent calls (default 20)' })
|
|
235
|
-
, a => hubspotCalls(a))
|
|
236
|
-
.command('connection-evidence', 'Dispute-grade connection evidence for a site: Velaro probe uptime, incidents (incl. excluded, with reason), per-agent disconnects and client-vs-server reconciliation (Velaro staff, read-only)', y => y
|
|
237
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
238
|
-
.option('from', { type: 'string', desc: 'ISO start (default: 30 days before --to)' })
|
|
239
|
-
.option('to', { type: 'string', desc: 'ISO end (default: now)' })
|
|
240
|
-
, a => connectionEvidence(a))
|
|
241
|
-
.command('tour-insights', 'Moshky setup-tour funnel + scrubbed feedback across all sites, or one site\'s tour timeline with --site (Velaro staff, read-only)', y => y
|
|
242
|
-
.option('site', { type: 'number', desc: 'Optional site ID: show that site\'s tour events and feedback instead of the funnel' })
|
|
243
|
-
.option('days', { type: 'number', default: 30, desc: 'Look-back window in days (max 365)' })
|
|
244
|
-
, a => tourInsights(a))
|
|
245
|
-
.command('deployments', 'List a site’s widget embed keys and survey assignments (Velaro staff, read-only)', y => y
|
|
246
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Target site ID' })
|
|
247
|
-
.option('json', { type: 'boolean', default: false, desc: 'Print the complete JSON response' })
|
|
248
|
-
, a => listDeployments(a))
|
|
249
|
-
.command('impersonate', 'Start a 15-minute impersonation session for any site (SuperAdmin only, fully audit-logged to the customer\'s own activity log and a management email)', y => y
|
|
250
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Target site ID to impersonate' })
|
|
251
|
-
, a => impersonate(a))
|
|
252
|
-
.command('send-email', 'Send an ad-hoc internal email via ACS, staff-authed, no raw secret ever needed (recipients must be @velaro.com)', y => y
|
|
253
|
-
.option('to', { type: 'string', demandOption: true, desc: 'Comma-separated @velaro.com recipient(s)' })
|
|
254
|
-
.option('cc', { type: 'string', desc: 'Comma-separated @velaro.com CC recipient(s)' })
|
|
255
|
-
.option('subject', { type: 'string', demandOption: true, desc: 'Email subject' })
|
|
256
|
-
.option('html', { type: 'string', demandOption: true, desc: 'Email body as HTML' })
|
|
257
|
-
, a => sendEmail(a))
|
|
258
|
-
.command('agent-lookup', 'Resolve a bare WorkspaceUser.Id (AgentId) to its Email/DisplayName/SiteId across all sites (superadmin only, read-only)', y => y
|
|
259
|
-
.option('id', { type: 'number', demandOption: true, desc: 'WorkspaceUser.Id / AgentId to look up' })
|
|
260
|
-
, a => agentLookup(a))
|
|
261
|
-
.command('add-site-user', 'Create or ensure a NORMAL user (agent|administrator, never staff) on ANY site with an explicit non-forcing password (staff only, idempotent)', y => y
|
|
262
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Target site ID' })
|
|
263
|
-
.option('email', { type: 'string', demandOption: true, desc: 'User email' })
|
|
264
|
-
.option('password', { type: 'string', desc: 'Password (or set VELARO_NEW_USER_PASSWORD; never logged)' })
|
|
265
|
-
.option('role', { type: 'string', default: 'agent', choices: ['agent', 'administrator'], desc: 'agent or administrator' })
|
|
266
|
-
.option('firstName', { type: 'string' })
|
|
267
|
-
.option('lastName', { type: 'string' })
|
|
268
|
-
, a => addSiteUser(a))
|
|
269
|
-
.command('site-auth-mode', 'Show or set a site messaging-app auth mode (V10|Dual|EntraId) and AllowLocalLogin (staff only)', y => y
|
|
270
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Target site ID' })
|
|
271
|
-
.option('mode', { type: 'string', choices: ['V10', 'Dual', 'EntraId'], desc: 'Set this auth mode (omit to just show)' })
|
|
272
|
-
.option('allow-local-login', { type: 'string', desc: 'true|false (default true when setting)' })
|
|
273
|
-
, a => siteAuthMode({ ...a, allowLocalLogin: a['allow-local-login'] }))
|
|
274
|
-
.command('toggle-flag', 'Toggle a single legacy Subscription.cs feature flag on a site (superadmin only, allowlisted flags)', y => y
|
|
275
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
276
|
-
.option('flag', { type: 'string', demandOption: true, desc: 'Flag name, e.g. EnableScraperBotIndexing (must be on SupportToolsController.AllowedFeatureFlags)' })
|
|
277
|
-
.option('enabled', { type: 'string', demandOption: true, desc: 'true or false' })
|
|
278
|
-
, a => toggleFlag(a))
|
|
279
|
-
.command('set-limit', 'Set a numeric Subscription cap on a site, e.g. maxBotTurnsPerMonth (superadmin only; 0 = plan value, never unlimited)', y => y
|
|
280
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
281
|
-
.option('key', { type: 'string', demandOption: true, desc: 'Cap name, e.g. maxBotTurnsPerMonth' })
|
|
282
|
-
.option('value', { type: 'number', demandOption: true, desc: 'Whole number >= 0' })
|
|
283
|
-
, a => setLimit(a))
|
|
284
|
-
.command('get-limit', 'Read back numeric Subscription caps for a site: subscription value, plan value, effective value, override flag (superadmin only, read-only)', y => y
|
|
285
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
286
|
-
.option('key', { type: 'string', desc: 'Only this cap, e.g. maxWorkflowRunsPerMonth or workflow_runs' })
|
|
287
|
-
.option('json', { type: 'boolean', desc: 'Raw JSON' })
|
|
288
|
-
, a => getLimit(a))
|
|
289
|
-
.command('grant-limit', 'Temporarily raise a metered cap for the rest of the billing period; it reverts to the plan value automatically (superadmin only)', y => y
|
|
290
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
291
|
-
.option('metric', { type: 'string', demandOption: true, desc: 'workflow_runs | webhook_invocations | http_request_actions | conversations | ivr_minutes | mcp_calls | workflow_ai_calls' })
|
|
292
|
-
.option('amount', { type: 'number', demandOption: true, desc: 'Extra units this period (0 clears the grant)' })
|
|
293
|
-
, a => grantLimit(a))
|
|
294
|
-
.command('scraper-create-job', 'Trigger a scraper job on behalf of any site (superadmin only — no need to be logged in as that site\'s own user)', y => y
|
|
295
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Target site ID' })
|
|
296
|
-
.option('urls', { type: 'string', demandOption: true, desc: 'Comma-separated URLs to crawl' })
|
|
297
|
-
.option('maxPages', { type: 'number', desc: 'Max pages for this job (default 25, still capped by the site\'s own plan limits)' })
|
|
298
|
-
.option('crawlDepth', { type: 'number', desc: 'Crawl depth (default 1)' })
|
|
299
|
-
.option('name', { type: 'string', desc: 'Job name' })
|
|
300
|
-
, a => scraperCreateJob(a))
|
|
301
|
-
.command('chat-query', 'Run a staff-only test-chat query against ANY site\'s AI config (superadmin only — no need to be logged in as that site\'s own user)', y => y
|
|
302
|
-
.option('site', { type: 'number', demandOption: true, desc: 'Target site ID' })
|
|
303
|
-
.option('aiConfigId', { type: 'number', demandOption: true, desc: 'AI Configuration ID on the target site' })
|
|
304
|
-
.option('query', { type: 'string', demandOption: true, desc: 'The test question to send' })
|
|
305
|
-
.option('channel', { type: 'string', desc: 'Conversation source, e.g. Web, TwilioSms (default Web)' })
|
|
306
|
-
.option('overrideIndexes', { type: 'string', desc: 'Comma-separated index names to override the config\'s own IndexName for this query' })
|
|
307
|
-
, a => chatQuery(a))
|
|
308
|
-
.demandCommand(1, 'Specify a subcommand: deployments | impersonate | agent-lookup | add-site-user | toggle-flag | set-limit | get-limit | grant-limit | scraper-create-job | chat-query | send-email | tour-insights | connection-timeline | connection-evidence');
|
|
309
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// velaro tour-policy — Velaro staff only. Guided-tour auto-open policy, resolved
|
|
2
|
-
// site override, then global default, then built-in default. Every write is versioned
|
|
3
|
-
// (last 20) and reversible. Site is always explicit in the route (TourPolicy/sites/{siteId}/...),
|
|
4
|
-
// never derived from the caller's auth context; omit --site for the global default (Velaro Admin).
|
|
5
|
-
import { request } from '../api.js';
|
|
6
|
-
|
|
7
|
-
const enc = encodeURIComponent;
|
|
8
|
-
const base = (argv) =>
|
|
9
|
-
argv.site ? `TourPolicy/sites/${argv.site}/${enc(argv.tour)}` : `TourPolicy/global/${enc(argv.tour)}`;
|
|
10
|
-
|
|
11
|
-
const fmt = (p) =>
|
|
12
|
-
p ? `${p.enabled ? 'ON' : 'OFF'}, ${p.maxAutoOpens} opens, ${p.minHoursBetweenAutoOpens}h apart, ${p.windowDays}d window${p.source ? ` (source: ${p.source})` : ''}` : '(none)';
|
|
13
|
-
|
|
14
|
-
async function get(argv) {
|
|
15
|
-
const r = await request('GET', base(argv));
|
|
16
|
-
console.log(`\nTour ${r.tourKey}, ${argv.site ? `site ${argv.site}` : 'global default'}`);
|
|
17
|
-
console.log(` Stored: ${fmt(r.stored)}`);
|
|
18
|
-
if (argv.site) console.log(` Effective: ${fmt(r.effective)}`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function set(argv) {
|
|
22
|
-
const body = {};
|
|
23
|
-
if (argv.enabled !== undefined) body.enabled = argv.enabled;
|
|
24
|
-
if (argv.maxAutoOpens !== undefined) body.maxAutoOpens = argv.maxAutoOpens;
|
|
25
|
-
if (argv.minHours !== undefined) body.minHoursBetweenAutoOpens = argv.minHours;
|
|
26
|
-
if (argv.windowDays !== undefined) body.windowDays = argv.windowDays;
|
|
27
|
-
const r = await request('PUT', base(argv), body);
|
|
28
|
-
console.log(`Saved as version ${r.version.version}. Undo with: velaro tour-policy rollback --tour ${argv.tour}${argv.site ? ` --site ${argv.site}` : ''} --version <n>`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async function history(argv) {
|
|
32
|
-
const r = await request('GET', `${base(argv)}/history`);
|
|
33
|
-
if (!r.versions?.length) { console.log('No history yet.'); return; }
|
|
34
|
-
for (const v of r.versions) {
|
|
35
|
-
const restored = v.restoredFromVersion ? ` (from v${v.restoredFromVersion})` : '';
|
|
36
|
-
console.log(`v${v.version} ${v.action}${restored} by ${v.by} at ${v.at}: ${fmt(v.oldPolicy)} -> ${fmt(v.newPolicy)}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function rollback(argv) {
|
|
41
|
-
const r = await request('POST', `${base(argv)}/rollback`, { version: argv.version });
|
|
42
|
-
console.log(`Restored v${argv.version} as new version ${r.version.version}.`);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const common = (y) => y
|
|
46
|
-
.option('tour', { type: 'string', default: 'CommerceWelcome', describe: 'CommerceWelcome or ShopifyWelcome' })
|
|
47
|
-
.option('site', { type: 'number', describe: 'Site id. Omit for the global default (Velaro Admin).' });
|
|
48
|
-
|
|
49
|
-
export function tourPolicyCommand(yargs) {
|
|
50
|
-
return yargs
|
|
51
|
-
.command('get', 'Show stored and effective tour policy', common, (a) => get(a))
|
|
52
|
-
.command('set', 'Set tour policy (partial: omitted fields keep their value)', (y) => common(y)
|
|
53
|
-
.option('enabled', { type: 'boolean' })
|
|
54
|
-
.option('max-auto-opens', { type: 'number', alias: 'maxAutoOpens', describe: '0-20' })
|
|
55
|
-
.option('min-hours', { type: 'number', describe: 'Hours between auto-opens, 0-720' })
|
|
56
|
-
.option('window-days', { type: 'number', alias: 'windowDays', describe: '1-365' }), (a) => set(a))
|
|
57
|
-
.command('history', 'List the last 20 versions, newest first', common, (a) => history(a))
|
|
58
|
-
.command('rollback', 'Restore the state after a version (recorded as a new version)', (y) => common(y)
|
|
59
|
-
.option('version', { type: 'number', demandOption: true }), (a) => rollback(a))
|
|
60
|
-
.demandCommand(1, 'Specify a subcommand: get | set | history | rollback');
|
|
61
|
-
}
|
package/lib/commands/triage.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// Staff-only (Velaro Administrator) Triage Economy controls: platform default/force mode,
|
|
2
|
-
// per-site effective modes, and the savings/quality report. Resolution is
|
|
3
|
-
// force ?? perSite ?? platformDefault ?? "economy". Skill: .claude/skills/triage-economy-report/SKILL.md
|
|
4
|
-
import { messagingGet, messagingPut } from '../api.js';
|
|
5
|
-
import { renderTriageReport } from './focus.js';
|
|
6
|
-
|
|
7
|
-
const MODES = ['off', 'economy', 'null'];
|
|
8
|
-
const toMode = (v) => (v === 'null' ? null : v);
|
|
9
|
-
|
|
10
|
-
const platformGet = {
|
|
11
|
-
command: 'get',
|
|
12
|
-
describe: 'Show platform forceMode / defaultMode',
|
|
13
|
-
builder: (y) => y,
|
|
14
|
-
handler: async () => console.log(JSON.stringify(await messagingGet('/superadmin/focus-triage/platform'), null, 2)),
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const platformSet = {
|
|
18
|
-
command: 'set',
|
|
19
|
-
describe: 'Set platform defaultMode and/or forceMode (off|economy|null; omitted = unchanged)',
|
|
20
|
-
builder: (y) => y
|
|
21
|
-
.option('default', { type: 'string', choices: MODES, describe: 'Mode for sites with no own setting' })
|
|
22
|
-
.option('force', { type: 'string', choices: MODES, describe: 'Mode forced on ALL sites (null clears)' }),
|
|
23
|
-
handler: async (argv) => {
|
|
24
|
-
const body = {};
|
|
25
|
-
if (argv.default !== undefined) body.defaultMode = toMode(argv.default);
|
|
26
|
-
if (argv.force !== undefined) body.forceMode = toMode(argv.force);
|
|
27
|
-
if (!Object.keys(body).length) throw new Error('Provide --default and/or --force.');
|
|
28
|
-
console.log(JSON.stringify(await messagingPut('/superadmin/focus-triage/platform', body), null, 2));
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const platformCommand = {
|
|
33
|
-
command: 'platform <action>',
|
|
34
|
-
describe: 'Platform-wide triage mode',
|
|
35
|
-
builder: (y) => y.command(platformGet).command(platformSet).demandCommand(1).strict(),
|
|
36
|
-
handler: () => {},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const sitesCommand = {
|
|
40
|
-
command: 'sites',
|
|
41
|
-
describe: 'Every site with effective triage mode and source (force|site|default)',
|
|
42
|
-
builder: (y) => y,
|
|
43
|
-
handler: async () => console.log(JSON.stringify(await messagingGet('/superadmin/focus-triage/sites'), null, 2)),
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const reportCommand = {
|
|
47
|
-
command: 'report',
|
|
48
|
-
describe: 'Triage Economy report; no --site = platform-wide with per-site breakdown',
|
|
49
|
-
builder: (y) => y
|
|
50
|
-
.option('site', { type: 'number' })
|
|
51
|
-
.option('days', { type: 'number', default: 30 })
|
|
52
|
-
.option('json', { type: 'boolean', default: false }),
|
|
53
|
-
handler: async (argv) => {
|
|
54
|
-
const qs = new URLSearchParams({ days: String(argv.days) });
|
|
55
|
-
if (argv.site != null) qs.set('siteId', String(argv.site));
|
|
56
|
-
const r = await messagingGet('/superadmin/focus-triage/report?' + qs);
|
|
57
|
-
console.log(argv.json ? JSON.stringify(r, null, 2) : renderTriageReport(r));
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const triageCommand = {
|
|
62
|
-
command: 'triage <subcommand>',
|
|
63
|
-
describe: 'Staff: Triage Economy platform mode, per-site modes, and savings report (Velaro Administrator)',
|
|
64
|
-
builder: (y) => y.command(platformCommand).command(sitesCommand).command(reportCommand).demandCommand(1).strict(),
|
|
65
|
-
handler: () => {},
|
|
66
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// `velaro entitlement report-packages` must stay wired to GET Entitlements/report-packages and render the five category packages.
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
import assert from 'node:assert/strict';
|
|
4
|
-
import fs from 'node:fs';
|
|
5
|
-
import { formatReportPackages } from './commands/entitlement.js';
|
|
6
|
-
|
|
7
|
-
const sample = (siteId, enabled) => ({
|
|
8
|
-
siteId,
|
|
9
|
-
defaultOff: true,
|
|
10
|
-
plan: 'plan.enterprise-internal',
|
|
11
|
-
top: { slug: 'enterprise-reports', name: 'Enterprise Reports', tagline: 'Includes all five category packages.', enabled, reportCount: 2 },
|
|
12
|
-
categories: [
|
|
13
|
-
{
|
|
14
|
-
slug: 'reports-conversations-channels', name: 'Conversations & Channels', category: 'Conversations & Channels', tagline: 'Know what is coming in.', audience: 'Teams',
|
|
15
|
-
enabled, enabledCount: enabled ? 2 : 0, reportCount: 2,
|
|
16
|
-
reports: [
|
|
17
|
-
{ id: 'conversations', name: 'Conversations', packageSlug: 'report-conversations', packageKey: 'EnableReportConversations', enabled },
|
|
18
|
-
{ id: 'missed', name: 'Missed Chats', packageSlug: 'report-missed', packageKey: 'EnableReportMissed', enabled },
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('without a site the output lists the package and every report with no on/off marks', () => {
|
|
25
|
-
const out = formatReportPackages(sample(null, false));
|
|
26
|
-
assert.match(out, /Enterprise Reports \(enterprise-reports\) - plan plan\.enterprise-internal, default OFF/);
|
|
27
|
-
assert.match(out, /Conversations & Channels \(reports-conversations-channels\) 2 reports/);
|
|
28
|
-
assert.match(out, /Missed Chats \(missed\) - package report-missed, key EnableReportMissed/);
|
|
29
|
-
assert.doesNotMatch(out, /\[ON \]|\[off\]/);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('with a site each report and category shows its on/off state', () => {
|
|
33
|
-
const on = formatReportPackages(sample(1032, true));
|
|
34
|
-
assert.match(on, /site 1032 \[ALL ON\]/);
|
|
35
|
-
assert.match(on, /\[ON \] 2\/2 reports/);
|
|
36
|
-
assert.match(on, /\[ON \] Conversations/);
|
|
37
|
-
const off = formatReportPackages(sample(40001, false));
|
|
38
|
-
assert.match(off, /\[off\] 0\/2 reports/);
|
|
39
|
-
assert.match(off, /\[off\] Missed Chats/);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('the command calls the admin route and is registered in the usage line', () => {
|
|
43
|
-
const src = fs.readFileSync(new URL('./commands/entitlement.js', import.meta.url), 'utf8');
|
|
44
|
-
assert.ok(src.includes("`Entitlements/report-packages${q}`"));
|
|
45
|
-
assert.ok(src.includes(".command('report-packages'"));
|
|
46
|
-
assert.ok(src.includes('enterprise-reports | report-packages'));
|
|
47
|
-
});
|