@velaro/cli 1.4.243 → 1.4.244
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 +343 -360
- package/lib/commands/billing.js +3 -71
- package/lib/commands/endpoint-parity.js +53 -58
- package/lib/commands/index.js +1 -43
- package/lib/commands/ingest.js +63 -36
- package/lib/commands/ingest.test.js +22 -0
- package/lib/commands/package-builder-my.js +13 -0
- package/lib/public-help.test.js +35 -0
- package/package.json +40 -40
- package/lib/commands/billing-agents.js +0 -51
- package/lib/commands/billing-automation.js +0 -184
- package/lib/commands/billing-email-preference.js +0 -64
- package/lib/commands/billing-subscription.js +0 -909
- package/lib/commands/order-form.js +0 -112
- package/lib/commands/package-builder.js +0 -35
- package/lib/commands/price-increase.js +0 -93
- package/lib/commands/sign.js +0 -253
- package/lib/commands/status-notify.js +0 -98
- package/lib/sign-fields.js +0 -49
- package/lib/sign-fields.test.js +0 -27
- package/lib/sign-versions.js +0 -58
- package/lib/sign-versions.test.js +0 -50
- package/lib/sign.test.js +0 -19
package/lib/commands/billing.js
CHANGED
|
@@ -58,81 +58,13 @@ async function planStatus() {
|
|
|
58
58
|
console.log('');
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
async function listContracts() {
|
|
64
|
-
const contracts = await request('GET', '/api/Contract');
|
|
65
|
-
if (!Array.isArray(contracts) || !contracts.length) {
|
|
66
|
-
console.log('No contracts found.');
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
console.log(`\nContracts (${contracts.length})\n${'─'.repeat(60)}`);
|
|
70
|
-
for (const c of contracts) {
|
|
71
|
-
const monthly = c.totalMonthlyValue ? ` $${Number(c.totalMonthlyValue).toFixed(2)}/mo` : '';
|
|
72
|
-
const signed = c.signedAt ? ` signed ${fmtDate(c.signedAt)}` : '';
|
|
73
|
-
console.log(` [${c.id}] ${c.status.padEnd(8)} "${c.title}" ${c.customerEmail || ''}${monthly}${signed}`);
|
|
74
|
-
}
|
|
75
|
-
console.log('');
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async function showContract(id) {
|
|
79
|
-
const c = await request('GET', `/api/Contract/${id}`);
|
|
80
|
-
console.log(`\nContract ${c.id}: "${c.title}"\n${'─'.repeat(50)}`);
|
|
81
|
-
console.log(` Status: ${c.status}`);
|
|
82
|
-
console.log(` Customer: ${c.customerName || '—'} <${c.customerEmail || '—'}>`);
|
|
83
|
-
if (c.customerCompany) console.log(` Company: ${c.customerCompany}`);
|
|
84
|
-
console.log(` Monthly: $${Number(c.totalMonthlyValue || 0).toFixed(2)}/mo Setup: $${Number(c.setupFee || 0).toFixed(2)}`);
|
|
85
|
-
console.log(` Service: ${fmtDate(c.serviceStartDate)} → ${fmtDate(c.serviceEndDate)}`);
|
|
86
|
-
console.log(` Activation: ${c.subscriptionActivationMode} activated: ${fmtDate(c.subscriptionActivatedAt)}`);
|
|
87
|
-
console.log(` QB Customer: ${c.qboCustomerId || 'not synced'}`);
|
|
88
|
-
console.log(` QB Invoice: ${c.qboInvoiceId || '—'}`);
|
|
89
|
-
if (c.signedAt) console.log(` Signed: ${fmtDate(c.signedAt)} by ${c.signedByEmail}`);
|
|
90
|
-
if (c.cancellationRequestedAt) console.log(` ⚠️ Cancelled: ${fmtDate(c.cancellationRequestedAt)} by ${c.cancellationRequestedBy}`);
|
|
91
|
-
if (c.amendments?.length) console.log(` Amendments: ${c.amendments.length}`);
|
|
92
|
-
console.log('');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async function sendContract(id) {
|
|
96
|
-
await request('POST', `/api/Contract/${id}/send`);
|
|
97
|
-
console.log(`✅ Contract ${id} sent — signing link dispatched to customer.`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// ── invoices ──────────────────────────────────────────────────────────────────
|
|
101
|
-
|
|
102
|
-
async function listInvoices() {
|
|
103
|
-
const invoices = await request('GET', '/api/BillingInvoiceRecord');
|
|
104
|
-
if (!Array.isArray(invoices) || !invoices.length) {
|
|
105
|
-
console.log('No invoices found.');
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
console.log(`\nInvoices (${invoices.length})\n${'─'.repeat(70)}`);
|
|
109
|
-
for (const i of invoices) {
|
|
110
|
-
const qb = `QB:${(i.qboSyncStatus || 'not pushed').padEnd(10)}`;
|
|
111
|
-
const attempts = i.qboSyncAttempts > 0 ? ` (${i.qboSyncAttempts}x)` : '';
|
|
112
|
-
console.log(` [${i.id}] ${(i.invoiceNumber || '').padEnd(16)} ${fmtCents(i.totalCents).padEnd(10)} ${i.status.padEnd(8)} ${qb}${attempts} ${fmtDate(i.createdAt)}`);
|
|
113
|
-
if (i.qboLastSyncError) console.log(` QB error: ${i.qboLastSyncError.slice(0, 80)}`);
|
|
114
|
-
}
|
|
115
|
-
console.log('');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async function dispatchInvoice(id) {
|
|
119
|
-
await request('POST', `/api/BillingInvoiceRecord/${id}/dispatch`);
|
|
120
|
-
console.log(`✅ Invoice ${id} dispatched — email sent and status set to open.`);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// ── command export ────────────────────────────────────────────────────────────
|
|
124
|
-
|
|
61
|
+
// Customer-safe: plan-status is scoped to the caller site. Contract and invoice subcommands are staff-gated server side and live only in the unpublished staff folder.
|
|
125
62
|
export const billingCommand = {
|
|
126
63
|
command: 'billing <subcommand>',
|
|
127
|
-
describe: '
|
|
64
|
+
describe: 'Your plan status',
|
|
128
65
|
builder: (yargs) =>
|
|
129
66
|
yargs
|
|
130
67
|
.command('plan-status', 'Show current plan flags, seats, QB sync state, and deferred revenue', {}, () => planStatus())
|
|
131
|
-
.
|
|
132
|
-
.command('contract <id>', 'Show a specific contract', {}, (args) => showContract(args.id))
|
|
133
|
-
.command('contract-send <id>', 'Send a contract to the customer for signing', {}, (args) => sendContract(args.id))
|
|
134
|
-
.command('invoices', 'List invoice records with QB sync status', {}, () => listInvoices())
|
|
135
|
-
.command('invoice-dispatch <id>', 'Email an invoice to the customer (sets status to open)', {}, (args) => dispatchInvoice(args.id))
|
|
136
|
-
.demandCommand(1, 'Specify a subcommand: plan-status | contracts | contract <id> | contract-send <id> | invoices | invoice-dispatch <id>'),
|
|
68
|
+
.demandCommand(1, 'Specify a subcommand: plan-status'),
|
|
137
69
|
handler: () => {},
|
|
138
70
|
};
|
|
@@ -1,58 +1,53 @@
|
|
|
1
|
-
// CLI halves of the MCP parity tools in mcp/parity/endpoints.customer.js and endpoints.staff.js.
|
|
2
|
-
// Each handler names the controller action it calls.
|
|
3
|
-
import { request } from '../api.js';
|
|
4
|
-
|
|
5
|
-
const show = (r) => console.log(JSON.stringify(r, null, 2));
|
|
6
|
-
const int = (y, k, d) => y.option(k, { type: 'number', demandOption: true, describe: d });
|
|
7
|
-
|
|
8
|
-
export const recycleBinCommand = {
|
|
9
|
-
command: 'recycle-bin',
|
|
10
|
-
describe: 'List and restore soft-deleted contact lists, members, segments and KB articles/topics (one id at a time)',
|
|
11
|
-
builder: (y) => y
|
|
12
|
-
.command({ command: 'contact-lists', describe: 'List deleted contact lists', handler: async () => show(await request('GET', '/ContactLists/deleted')) }) // controller action: GetDeletedLists
|
|
13
|
-
.command({ command: 'restore-contact-list', describe: 'Restore one contact list', builder: (z) => int(z, 'id', 'List id'), handler: async (a) => show(await request('POST', `/ContactLists/${a.id}/restore`)) }) // controller action: RestoreList
|
|
14
|
-
.command({ command: 'members', describe: 'List deleted members of a list', builder: (z) => int(z, 'list', 'List id'), handler: async (a) => show(await request('GET', `/ContactLists/${a.list}/Members/deleted`)) }) // controller action: GetDeletedMembers
|
|
15
|
-
.command({ command: 'restore-member', describe: 'Restore one list member', builder: (z) => int(int(z, 'list', 'List id'), 'member', 'Member id'), handler: async (a) => show(await request('POST', `/ContactLists/${a.list}/Members/${a.member}/restore`)) }) // controller action: RestoreMember
|
|
16
|
-
.command({ command: 'segments', describe: 'List deleted segments', handler: async () => show(await request('GET', '/ContactSegments/deleted')) }) // controller action: ListDeleted (ContactSegments)
|
|
17
|
-
.command({ command: 'kb-articles', describe: 'List deleted KB articles', handler: async () => show(await request('GET', '/api/kb/articles/deleted')) }) // controller action: ListDeleted (KBArticles)
|
|
18
|
-
.command({ command: 'restore-kb-article', describe: 'Restore one KB article', builder: (z) => int(z, 'id', 'Article id'), handler: async (a) => show(await request('POST', `/api/kb/articles/${a.id}/restore`)) }) // controller action: RestoreDeleted (KBArticles)
|
|
19
|
-
.command({ command: 'kb-topics', describe: 'List deleted KB topics', handler: async () => show(await request('GET', '/api/kb/topics/deleted')) }) // controller action: ListDeleted (KBTopics)
|
|
20
|
-
.command({ command: 'restore-kb-topic', describe: 'Restore one KB topic', builder: (z) => int(z, 'id', 'Topic id'), handler: async (a) => show(await request('POST', `/api/kb/topics/${a.id}/restore`)) }) // controller action: RestoreDeleted (KBTopics)
|
|
21
|
-
.demandCommand(1),
|
|
22
|
-
handler: () => {},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const aiUsageCommand = {
|
|
26
|
-
command: 'ai-usage',
|
|
27
|
-
describe: 'Your site AI usage summary and budget alert',
|
|
28
|
-
builder: (y) => y
|
|
29
|
-
.command({ command: 'summary', describe: 'AI usage summary', handler: async () => show(await request('GET', '/AiUsageReport/summary')) }) // controller action: GetSummary
|
|
30
|
-
.command({
|
|
31
|
-
command: 'budget-alert-set', describe: 'Update the budget alert',
|
|
32
|
-
builder: (z) => z.option('enabled', { type: 'boolean' }).option('threshold-percent', { type: 'number' }).option('recipients', { type: 'string', describe: 'Comma-separated emails' }),
|
|
33
|
-
handler: async (a) => show(await request('PUT', '/AiUsageReport/budget-alert', { enabled: a.enabled, thresholdPercent: a.thresholdPercent, recipientEmails: a.recipients })), // controller action: UpdateBudgetAlert
|
|
34
|
-
})
|
|
35
|
-
.command({ command: 'budget-alert-delete', describe: 'Delete the budget alert', handler: async () => show(await request('DELETE', '/AiUsageReport/budget-alert')) }) // controller action: DeleteBudgetAlert
|
|
36
|
-
.demandCommand(1),
|
|
37
|
-
handler: () => {},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const siteInfoCommand = {
|
|
41
|
-
command: 'site-info',
|
|
42
|
-
describe: 'Read-only site settings, entitlements and platform uptime for your site',
|
|
43
|
-
builder: (y) => y
|
|
44
|
-
.command({ command: 'settings', describe: 'Site settings', handler: async () => show(await request('GET', '/api/SiteSettings')) }) // controller action: GetSiteSettings
|
|
45
|
-
.command({ command: 'entitlements', describe: 'Your resolved entitlements', handler: async () => show(await request('GET', '/Entitlements/my')) }) // controller action: GetMyEntitlements
|
|
46
|
-
.command({ command: 'uptime', describe: 'Platform uptime', handler: async () => show(await request('GET', '/PlatformUptime')) }) // controller action: GetAsync (PlatformUptime)
|
|
47
|
-
.command({ command: 'last-copilot-session', describe: 'Your last Copilot session summary', handler: async () => show(await request('GET', '/Copilot/LastSession')) }) // controller action: LastSession
|
|
48
|
-
.command({ command: 'sender-domain-health', describe: 'Sender domain health', handler: async () => show(await request('GET', '/SenderDomains/Health')) }) // controller action: GetHealth
|
|
49
|
-
.command({ command: 'netsuite-interaction-summary', describe: 'NetSuite AI interaction summary for a conversation', builder: (z) => int(z, 'conversation', 'Conversation id'), handler: async (a) => show(await request('POST', `/NetSuite/interaction-summary?conversationId=${a.conversation}`)) }) // controller action: GetInteractionSummary
|
|
50
|
-
.demandCommand(1),
|
|
51
|
-
handler: () => {},
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const billingReceiptsCommand = {
|
|
55
|
-
command: 'billing-receipts-run',
|
|
56
|
-
describe: 'Staff only: run the payment receipt job now',
|
|
57
|
-
handler: async () => show(await request('POST', '/api/BillingNotifications/receipts/run-now')), // controller action: RunReceiptsNow
|
|
58
|
-
};
|
|
1
|
+
// CLI halves of the MCP parity tools in mcp/parity/endpoints.customer.js and endpoints.staff.js.
|
|
2
|
+
// Each handler names the controller action it calls.
|
|
3
|
+
import { request } from '../api.js';
|
|
4
|
+
|
|
5
|
+
const show = (r) => console.log(JSON.stringify(r, null, 2));
|
|
6
|
+
const int = (y, k, d) => y.option(k, { type: 'number', demandOption: true, describe: d });
|
|
7
|
+
|
|
8
|
+
export const recycleBinCommand = {
|
|
9
|
+
command: 'recycle-bin',
|
|
10
|
+
describe: 'List and restore soft-deleted contact lists, members, segments and KB articles/topics (one id at a time)',
|
|
11
|
+
builder: (y) => y
|
|
12
|
+
.command({ command: 'contact-lists', describe: 'List deleted contact lists', handler: async () => show(await request('GET', '/ContactLists/deleted')) }) // controller action: GetDeletedLists
|
|
13
|
+
.command({ command: 'restore-contact-list', describe: 'Restore one contact list', builder: (z) => int(z, 'id', 'List id'), handler: async (a) => show(await request('POST', `/ContactLists/${a.id}/restore`)) }) // controller action: RestoreList
|
|
14
|
+
.command({ command: 'members', describe: 'List deleted members of a list', builder: (z) => int(z, 'list', 'List id'), handler: async (a) => show(await request('GET', `/ContactLists/${a.list}/Members/deleted`)) }) // controller action: GetDeletedMembers
|
|
15
|
+
.command({ command: 'restore-member', describe: 'Restore one list member', builder: (z) => int(int(z, 'list', 'List id'), 'member', 'Member id'), handler: async (a) => show(await request('POST', `/ContactLists/${a.list}/Members/${a.member}/restore`)) }) // controller action: RestoreMember
|
|
16
|
+
.command({ command: 'segments', describe: 'List deleted segments', handler: async () => show(await request('GET', '/ContactSegments/deleted')) }) // controller action: ListDeleted (ContactSegments)
|
|
17
|
+
.command({ command: 'kb-articles', describe: 'List deleted KB articles', handler: async () => show(await request('GET', '/api/kb/articles/deleted')) }) // controller action: ListDeleted (KBArticles)
|
|
18
|
+
.command({ command: 'restore-kb-article', describe: 'Restore one KB article', builder: (z) => int(z, 'id', 'Article id'), handler: async (a) => show(await request('POST', `/api/kb/articles/${a.id}/restore`)) }) // controller action: RestoreDeleted (KBArticles)
|
|
19
|
+
.command({ command: 'kb-topics', describe: 'List deleted KB topics', handler: async () => show(await request('GET', '/api/kb/topics/deleted')) }) // controller action: ListDeleted (KBTopics)
|
|
20
|
+
.command({ command: 'restore-kb-topic', describe: 'Restore one KB topic', builder: (z) => int(z, 'id', 'Topic id'), handler: async (a) => show(await request('POST', `/api/kb/topics/${a.id}/restore`)) }) // controller action: RestoreDeleted (KBTopics)
|
|
21
|
+
.demandCommand(1),
|
|
22
|
+
handler: () => {},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const aiUsageCommand = {
|
|
26
|
+
command: 'ai-usage',
|
|
27
|
+
describe: 'Your site AI usage summary and budget alert',
|
|
28
|
+
builder: (y) => y
|
|
29
|
+
.command({ command: 'summary', describe: 'AI usage summary', handler: async () => show(await request('GET', '/AiUsageReport/summary')) }) // controller action: GetSummary
|
|
30
|
+
.command({
|
|
31
|
+
command: 'budget-alert-set', describe: 'Update the budget alert',
|
|
32
|
+
builder: (z) => z.option('enabled', { type: 'boolean' }).option('threshold-percent', { type: 'number' }).option('recipients', { type: 'string', describe: 'Comma-separated emails' }),
|
|
33
|
+
handler: async (a) => show(await request('PUT', '/AiUsageReport/budget-alert', { enabled: a.enabled, thresholdPercent: a.thresholdPercent, recipientEmails: a.recipients })), // controller action: UpdateBudgetAlert
|
|
34
|
+
})
|
|
35
|
+
.command({ command: 'budget-alert-delete', describe: 'Delete the budget alert', handler: async () => show(await request('DELETE', '/AiUsageReport/budget-alert')) }) // controller action: DeleteBudgetAlert
|
|
36
|
+
.demandCommand(1),
|
|
37
|
+
handler: () => {},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const siteInfoCommand = {
|
|
41
|
+
command: 'site-info',
|
|
42
|
+
describe: 'Read-only site settings, entitlements and platform uptime for your site',
|
|
43
|
+
builder: (y) => y
|
|
44
|
+
.command({ command: 'settings', describe: 'Site settings', handler: async () => show(await request('GET', '/api/SiteSettings')) }) // controller action: GetSiteSettings
|
|
45
|
+
.command({ command: 'entitlements', describe: 'Your resolved entitlements', handler: async () => show(await request('GET', '/Entitlements/my')) }) // controller action: GetMyEntitlements
|
|
46
|
+
.command({ command: 'uptime', describe: 'Platform uptime', handler: async () => show(await request('GET', '/PlatformUptime')) }) // controller action: GetAsync (PlatformUptime)
|
|
47
|
+
.command({ command: 'last-copilot-session', describe: 'Your last Copilot session summary', handler: async () => show(await request('GET', '/Copilot/LastSession')) }) // controller action: LastSession
|
|
48
|
+
.command({ command: 'sender-domain-health', describe: 'Sender domain health', handler: async () => show(await request('GET', '/SenderDomains/Health')) }) // controller action: GetHealth
|
|
49
|
+
.command({ command: 'netsuite-interaction-summary', describe: 'NetSuite AI interaction summary for a conversation', builder: (z) => int(z, 'conversation', 'Conversation id'), handler: async (a) => show(await request('POST', `/NetSuite/interaction-summary?conversationId=${a.conversation}`)) }) // controller action: GetInteractionSummary
|
|
50
|
+
.demandCommand(1),
|
|
51
|
+
handler: () => {},
|
|
52
|
+
};
|
|
53
|
+
|
package/lib/commands/index.js
CHANGED
|
@@ -119,46 +119,6 @@ const listCommand = {
|
|
|
119
119
|
},
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
-
// ── site (restricted, enforced server-side) ──────────────────────────────────────────────────
|
|
123
|
-
|
|
124
|
-
const siteCommand = {
|
|
125
|
-
command: 'site <siteId>',
|
|
126
|
-
describe: 'Show index breakdown for a specific site (restricted, enforced server-side)',
|
|
127
|
-
handler: async (argv) => {
|
|
128
|
-
const creds = await getCredentials();
|
|
129
|
-
if (!isVelaroAdmin(creds)) {
|
|
130
|
-
console.error('This command is restricted, enforced server-side.');
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
const data = await get(`/DatabaseTool/SearchIndexSite?siteId=${argv.siteId}`);
|
|
134
|
-
console.log(`\nSite ${argv.siteId} → \x1b[36m${data.physicalIndex}\x1b[0m [${data.assignmentType}]`);
|
|
135
|
-
console.log(`Total docs: ${data.totalDocuments.toLocaleString()}\n`);
|
|
136
|
-
for (const t of data.indexTypes) {
|
|
137
|
-
console.log(` ${t.indexName.padEnd(40)} ${t.count.toLocaleString()} docs`);
|
|
138
|
-
}
|
|
139
|
-
console.log('');
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// ── provision (restricted, enforced server-side) ─────────────────────────────────────────────
|
|
144
|
-
|
|
145
|
-
const provisionCommand = {
|
|
146
|
-
command: 'provision <siteId>',
|
|
147
|
-
describe: 'Provision a dedicated physical index for a site (restricted, enforced server-side)',
|
|
148
|
-
handler: async (argv) => {
|
|
149
|
-
const creds = await getCredentials();
|
|
150
|
-
if (!isVelaroAdmin(creds)) {
|
|
151
|
-
console.error('This command is restricted, enforced server-side.');
|
|
152
|
-
process.exit(1);
|
|
153
|
-
}
|
|
154
|
-
console.log(`Provisioning dedicated index for site ${argv.siteId}...`);
|
|
155
|
-
const result = await post('/DatabaseTool/ProvisionDedicatedIndex', { SiteId: argv.siteId });
|
|
156
|
-
console.log(`\x1b[32m✓ ${result.message}\x1b[0m`);
|
|
157
|
-
console.log(` Index: \x1b[36m${result.indexName}\x1b[0m`);
|
|
158
|
-
console.log('\nNote: Re-ingest content to populate the new index.');
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
|
|
162
122
|
// ── reingest (customer-facing, credit-gated) ──────────────────────────────────
|
|
163
123
|
|
|
164
124
|
const reingestCommand = {
|
|
@@ -248,12 +208,10 @@ export const indexCommand = {
|
|
|
248
208
|
builder: (yargs) =>
|
|
249
209
|
yargs
|
|
250
210
|
.command(listCommand)
|
|
251
|
-
.command(siteCommand)
|
|
252
|
-
.command(provisionCommand)
|
|
253
211
|
.command(reingestCommand)
|
|
254
212
|
.command(testCommand)
|
|
255
213
|
// Restricted subcommands (create, profile) exist only in the unpublished staff build.
|
|
256
214
|
.command(staffIndex?.restrictedCommands ? staffIndex.restrictedCommands() : [])
|
|
257
|
-
.demandCommand(1, 'Specify a subcommand: list,
|
|
215
|
+
.demandCommand(1, 'Specify a subcommand: list, reingest, test'),
|
|
258
216
|
handler: () => {},
|
|
259
217
|
};
|
package/lib/commands/ingest.js
CHANGED
|
@@ -1,36 +1,63 @@
|
|
|
1
|
-
import { getCredentials, messagingPost } from '../api.js';
|
|
2
|
-
import { runCommand } from '../run.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import { getCredentials, messagingPost, request } from '../api.js';
|
|
2
|
+
import { runCommand } from '../run.js';
|
|
3
|
+
|
|
4
|
+
const JOB_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{5,}$/;
|
|
5
|
+
|
|
6
|
+
/** Resolve the job id from `ingest status <id>`, `ingest <id>` or --job-id. */
|
|
7
|
+
export function resolveJobId(argv) {
|
|
8
|
+
const positional = [argv.action, argv.jobId].filter((v) => v !== undefined && v !== null && v !== '' && v !== 'status' && v !== 'start');
|
|
9
|
+
return String(argv['job-id'] ?? positional[0] ?? '');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Look the job up on the scraper before doing anything with it. A 404 (or empty body) means the job does not
|
|
14
|
+
* exist for this site and is reported as not found. `fetcher` is injectable for tests.
|
|
15
|
+
*/
|
|
16
|
+
export async function assertJobExists(jobId, fetcher = request) {
|
|
17
|
+
let res;
|
|
18
|
+
try {
|
|
19
|
+
res = await fetcher('GET', `/ScraperJobs/Jobs/${encodeURIComponent(jobId)}/Results`);
|
|
20
|
+
} catch (e) {
|
|
21
|
+
if (/→ (404|400)\b/.test(String(e.message))) throw new Error(`Job ${jobId} was not found for your site; nothing was started.`);
|
|
22
|
+
throw e;
|
|
23
|
+
}
|
|
24
|
+
if (res === null || res === undefined) throw new Error(`Job ${jobId} was not found for your site; nothing was started.`);
|
|
25
|
+
return res;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const ingestCommand = {
|
|
29
|
+
command: 'ingest [action] [jobId]',
|
|
30
|
+
describe: 'Trigger knowledge base ingestion for a completed scraper job (ingest status <jobId> only checks the job)',
|
|
31
|
+
builder: (y) =>
|
|
32
|
+
y.positional('action', { describe: '"status" to only check a job, omit to start ingestion', type: 'string' })
|
|
33
|
+
.positional('jobId', { describe: 'Scraper job ID', type: 'string' })
|
|
34
|
+
.option('job-id', { describe: 'Scraper job ID to ingest', type: 'string' }),
|
|
35
|
+
|
|
36
|
+
handler: runCommand(async (argv) => {
|
|
37
|
+
const jobId = resolveJobId(argv);
|
|
38
|
+
if (!jobId) throw new Error('A scraper job id is required: velaro ingest <jobId> or velaro ingest status <jobId>.');
|
|
39
|
+
if (!JOB_ID_RE.test(jobId)) throw new Error(`"${jobId}" is not a valid scraper job id.`);
|
|
40
|
+
const statusOnly = argv.action === 'status';
|
|
41
|
+
|
|
42
|
+
const creds = await getCredentials();
|
|
43
|
+
|
|
44
|
+
// Unknown ids fail here with a non-zero exit, never "Ingestion started".
|
|
45
|
+
const job = await assertJobExists(jobId);
|
|
46
|
+
if (statusOnly) {
|
|
47
|
+
console.log(`Job ${jobId} found for site ${creds.siteId}.`);
|
|
48
|
+
console.log(JSON.stringify(job, null, 2).slice(0, 2000));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
console.log(`Triggering ingestion for job ${jobId} on site ${creds.siteId}...`);
|
|
53
|
+
|
|
54
|
+
// AzureIndexesController (IngestJobDirect) lives on the MESSAGING api; the admin api has no such route.
|
|
55
|
+
const result = await messagingPost('/AzureIndexes/IngestJobDirect', { siteId: creds.siteId, jobId });
|
|
56
|
+
|
|
57
|
+
if (!result?.jobId) throw new Error(`Job ${jobId} was not found or could not be ingested; nothing was started.`);
|
|
58
|
+
console.log('Ingestion started.');
|
|
59
|
+
console.log(` Job ID: ${result.jobId}`);
|
|
60
|
+
console.log(` Index: ${result.physicalIndex}`);
|
|
61
|
+
console.log('\nEmbedding runs in the background. Check logs for completion.');
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { assertJobExists, resolveJobId } from './ingest.js';
|
|
4
|
+
|
|
5
|
+
test('unknown job (404) is reported as not found', async () => {
|
|
6
|
+
const f = async () => { throw new Error('GET /x → 404: {}'); };
|
|
7
|
+
await assert.rejects(() => assertJobExists('fake-id-123', f), /was not found/);
|
|
8
|
+
});
|
|
9
|
+
test('empty body is not found', async () => {
|
|
10
|
+
await assert.rejects(() => assertJobExists('fake-id-123', async () => null), /was not found/);
|
|
11
|
+
});
|
|
12
|
+
test('other errors propagate unchanged', async () => {
|
|
13
|
+
await assert.rejects(() => assertJobExists('abcdef', async () => { throw new Error('GET /x → 500: boom'); }), /500/);
|
|
14
|
+
});
|
|
15
|
+
test('existing job passes', async () => {
|
|
16
|
+
assert.deepEqual(await assertJobExists('abcdef', async () => ({ ok: 1 })), { ok: 1 });
|
|
17
|
+
});
|
|
18
|
+
test('resolveJobId handles status positional and --job-id', () => {
|
|
19
|
+
assert.equal(resolveJobId({ action: 'status', jobId: 'abc123' }), 'abc123');
|
|
20
|
+
assert.equal(resolveJobId({ action: 'abc123' }), 'abc123');
|
|
21
|
+
assert.equal(resolveJobId({ 'job-id': 'zzz999' }), 'zzz999');
|
|
22
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// velaro package-builder my: customer-safe read of the caller's own package and what it includes.
|
|
2
|
+
// Server: PackageBuilderController.My (server/Velaro.Admin/Controllers/PackageBuilderController.cs) takes the site from the
|
|
3
|
+
// authenticated session and returns no prices, keys or staff data. All other package-builder actions are staff-gated and live in cli/staff.
|
|
4
|
+
import { request } from '../api.js';
|
|
5
|
+
|
|
6
|
+
export const packageBuilderMyCommand = {
|
|
7
|
+
command: 'package-builder',
|
|
8
|
+
describe: 'Your own package and what it includes',
|
|
9
|
+
builder: (y) => y
|
|
10
|
+
.command('my', 'Your own package and what it includes', () => {}, async () => console.log(JSON.stringify(await request('GET', '/PackageBuilder/my'), null, 2)))
|
|
11
|
+
.demandCommand(1, 'Specify a subcommand: my'),
|
|
12
|
+
handler: () => {},
|
|
13
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Gate: the public @velaro/cli (cli/ minus cli/staff) may only expose top-level commands on the explicit customer-safe allowlist
|
|
2
|
+
// scripts/cli-customer-command-allowlist.json, and never a staff command name. A new command defaults to cli/staff until allowlisted.
|
|
3
|
+
// Regenerate the allowlist deliberately: CLI_ALLOWLIST_PRINT=1 node --test lib/public-help.test.js (prints the current names).
|
|
4
|
+
import { test } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { execFileSync } from 'node:child_process';
|
|
10
|
+
|
|
11
|
+
const cli = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
12
|
+
const root = path.resolve(cli, '..');
|
|
13
|
+
|
|
14
|
+
export function publicCommandNames() {
|
|
15
|
+
const tmp = path.join(cli, '.pubcheck-test');
|
|
16
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
17
|
+
fs.mkdirSync(tmp);
|
|
18
|
+
try {
|
|
19
|
+
for (const d of ['bin', 'lib', 'scripts']) fs.cpSync(path.join(cli, d), path.join(tmp, d), { recursive: true });
|
|
20
|
+
fs.copyFileSync(path.join(cli, 'package.json'), path.join(tmp, 'package.json'));
|
|
21
|
+
const out = execFileSync(process.execPath, [path.join(tmp, 'bin', 'velaro.js'), '--help'], { encoding: 'utf8' });
|
|
22
|
+
return [...new Set(out.split('\n').map((l) => /^ {2}velaro (\S+)/.exec(l)?.[1]).filter(Boolean))].sort();
|
|
23
|
+
} finally { fs.rmSync(tmp, { recursive: true, force: true }); }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
test('public velaro --help exposes only allowlisted, non-staff commands', () => {
|
|
27
|
+
const names = publicCommandNames();
|
|
28
|
+
if (process.env.CLI_ALLOWLIST_PRINT) console.log(JSON.stringify(names));
|
|
29
|
+
const allow = JSON.parse(fs.readFileSync(path.join(root, 'scripts', 'cli-customer-command-allowlist.json'), 'utf8')).commands;
|
|
30
|
+
const staff = JSON.parse(fs.readFileSync(path.join(root, 'scripts', 'cli-staff-command-names.json'), 'utf8')).staffCommandNames;
|
|
31
|
+
assert.ok(names.length > 50, 'could not parse help output');
|
|
32
|
+
for (const n of names) assert.ok(!staff.includes(n), `staff command "${n}" is in the public help`);
|
|
33
|
+
const extra = names.filter((n) => !allow.includes(n));
|
|
34
|
+
assert.deepEqual(extra, [], `commands not on cli-customer-command-allowlist.json (put staff commands in cli/staff, or allowlist with a documented server gate): ${extra.join(', ')}`);
|
|
35
|
+
});
|
package/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@velaro/cli",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"description": "Velaro Workspace v20
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"velaro": "bin/velaro.js"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"postinstall": "node scripts/postinstall.js",
|
|
11
|
-
"test": "node --test lib/*.test.js lib/commands/*.test.js staff/tests/*.test.js"
|
|
12
|
-
},
|
|
13
|
-
"engines": {
|
|
14
|
-
"node": ">=18.0.0"
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"yargs": "^17.7.2"
|
|
18
|
-
},
|
|
19
|
-
"optionalDependencies": {
|
|
20
|
-
"playwright": "^1.43.1",
|
|
21
|
-
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
|
|
22
|
-
},
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "https://github.com/velaro/velaro-admin"
|
|
26
|
-
},
|
|
27
|
-
"files": [
|
|
28
|
-
"bin/",
|
|
29
|
-
"lib/",
|
|
30
|
-
"scripts/"
|
|
31
|
-
],
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"license-checker-rseidelsohn": "^4.4.2"
|
|
34
|
-
},
|
|
35
|
-
"overrides": {
|
|
36
|
-
"@azure/msal-node": "^7.1.0",
|
|
37
|
-
"minimatch": "^11.0.1",
|
|
38
|
-
"glob": "^14.0.2"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@velaro/cli",
|
|
3
|
+
"version": "1.4.244",
|
|
4
|
+
"description": "Velaro Workspace v20 \u00e2\u20ac\u201d command-line interface for managing bots, knowledge base ingestion, MCP API keys, search indexes, and ops health.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"velaro": "bin/velaro.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node scripts/postinstall.js",
|
|
11
|
+
"test": "node --test lib/*.test.js lib/commands/*.test.js staff/tests/*.test.js"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18.0.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"yargs": "^17.7.2"
|
|
18
|
+
},
|
|
19
|
+
"optionalDependencies": {
|
|
20
|
+
"playwright": "^1.43.1",
|
|
21
|
+
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/velaro/velaro-admin"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"bin/",
|
|
29
|
+
"lib/",
|
|
30
|
+
"scripts/"
|
|
31
|
+
],
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"license-checker-rseidelsohn": "^4.4.2"
|
|
34
|
+
},
|
|
35
|
+
"overrides": {
|
|
36
|
+
"@azure/msal-node": "^7.1.0",
|
|
37
|
+
"minimatch": "^11.0.1",
|
|
38
|
+
"glob": "^14.0.2"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// velaro billing-agents: run and review the billing agents (staff only). Contract: docs/architecture/billing-agents-and-package-builder.md
|
|
2
|
-
import { request } from '../api.js';
|
|
3
|
-
|
|
4
|
-
const show = (o) => console.log(JSON.stringify(o, null, 2));
|
|
5
|
-
|
|
6
|
-
async function list() {
|
|
7
|
-
const agents = await request('GET', '/BillingAgents');
|
|
8
|
-
for (const a of agents) console.log(`${a.key.padEnd(12)} ${a.name.padEnd(18)} open findings: ${a.openFindings} last run: ${a.lastRun ? `${a.lastRun.mode}/${a.lastRun.status} ${a.lastRun.startedAt}` : 'never'}`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async function run(args) {
|
|
12
|
-
const mode = args.live ? 'live' : 'test';
|
|
13
|
-
const body = { mode };
|
|
14
|
-
if (args.site) body.siteId = args.site;
|
|
15
|
-
if (args.days) body.params = { days: args.days };
|
|
16
|
-
const r = await request('POST', `/BillingAgents/${args.agent}/run`, body);
|
|
17
|
-
console.log(`Run ${r.run.id} [${r.run.mode}] ${r.run.status}: ${r.findings.length} findings${mode === 'test' ? ' (dry run, no side effects)' : ''}`);
|
|
18
|
-
for (const f of r.findings) console.log(` #${f.id} ${f.severity.padEnd(5)} ${f.ruleKey.padEnd(26)} ${f.title}`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function runs(args) {
|
|
22
|
-
const q = new URLSearchParams();
|
|
23
|
-
if (args.agent) q.set('agentKey', args.agent);
|
|
24
|
-
if (args.mode) q.set('mode', args.mode);
|
|
25
|
-
show(await request('GET', `/BillingAgents/runs?${q}`));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async function findings(args) {
|
|
29
|
-
const q = new URLSearchParams();
|
|
30
|
-
for (const k of ['status', 'severity']) if (args[k]) q.set(k, args[k]);
|
|
31
|
-
if (args.agent) q.set('agentKey', args.agent);
|
|
32
|
-
show(await request('GET', `/BillingAgents/findings?${q}`));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const step = (verb) => async (args) => show(await request('POST', `/BillingAgents/findings/${args.id}/${verb}`, {}));
|
|
36
|
-
|
|
37
|
-
export function billingAgentsCommand(yargs) {
|
|
38
|
-
return yargs
|
|
39
|
-
.command('list', 'List agents with last run and open findings', () => {}, () => list())
|
|
40
|
-
.command('run <agent>', 'Run an agent (default TEST mode = dry run)', y => y
|
|
41
|
-
.positional('agent', { type: 'string', desc: 'close|collections|analyst|pricing|orders|utilization|syncfailure' })
|
|
42
|
-
.option('live', { type: 'boolean', desc: 'Live mode (findings + approval queue; still no side effects until apply)' })
|
|
43
|
-
.option('site', { type: 'number' }).option('days', { type: 'number' }), a => run(a))
|
|
44
|
-
.command('runs', 'List runs', y => y.option('agent', { type: 'string' }).option('mode', { type: 'string' }), a => runs(a))
|
|
45
|
-
.command('findings', 'List findings', y => y.option('status', { type: 'string' }).option('severity', { type: 'string' }).option('agent', { type: 'string' }), a => findings(a))
|
|
46
|
-
.command('approve <id>', 'Approve a finding (two-person rule for financial actions)', y => y.positional('id', { type: 'number' }), step('approve'))
|
|
47
|
-
.command('reject <id>', 'Reject a finding', y => y.positional('id', { type: 'number' }), step('reject'))
|
|
48
|
-
.command('apply <id>', 'Apply an approved finding (draft-safe actions only)', y => y.positional('id', { type: 'number' }), step('apply'))
|
|
49
|
-
.command('monitor', 'Agent health: last runs, 7d failure rate, stale agents', () => {}, async () => show(await request('GET', '/BillingAgents/monitor')))
|
|
50
|
-
.demandCommand(1, 'Specify a subcommand: list | run | runs | findings | approve | reject | apply | monitor');
|
|
51
|
-
}
|