@velaro/cli 1.4.113 → 1.4.114
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/lib/commands/entitlement.js +41 -1
- package/lib/commands/survey.js +8 -2
- package/lib/survey-email.js +9 -0
- package/lib/survey-email.test.js +22 -0
- package/package.json +1 -1
|
@@ -108,6 +108,33 @@ async function setOverride(args) {
|
|
|
108
108
|
console.log(`✅ Site ${args.site}: ${args.key} = ${value}${args.reason ? ` (${args.reason})` : ''}`);
|
|
109
109
|
}
|
|
110
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
|
+
|
|
111
138
|
async function seed() {
|
|
112
139
|
const result = await request('POST', 'Entitlements/admin/seed');
|
|
113
140
|
console.log(`✅ ${result.message}`);
|
|
@@ -283,6 +310,19 @@ export function entitlementCommand(yargs) {
|
|
|
283
310
|
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
284
311
|
.option('key', { type: 'string', demandOption: true, desc: 'Feature key to un-override' })
|
|
285
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))
|
|
286
326
|
.command('seed', 'Seed the EntitlementFeature registry (idempotent, superadmin only)', () => {}, () => seed())
|
|
287
327
|
.command('seed-plans', 'Seed PlanEntitlement rows from live PackageVersions in messaging DB (idempotent, superadmin only)', () => {}, () => seedPlans())
|
|
288
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))
|
|
@@ -328,7 +368,7 @@ export function entitlementCommand(yargs) {
|
|
|
328
368
|
.option('key', { type: 'string', demandOption: true, desc: 'Feature key, e.g. EnableIvr' })
|
|
329
369
|
.option('rollback', { type: 'boolean', desc: 'Pass to roll back this flag to Subscription.cs (default: go live)' })
|
|
330
370
|
, a => setCutover(a))
|
|
331
|
-
.demandCommand(1, 'Specify a subcommand: get | list-features | enterprise-reports | report-packages | set-override | remove-override | seed | seed-plans | backfill | backfill-sap-tiers | backfill-legacy-write-tiers | reconcile | comp | set-lock | sync-stripe | trial | list-cutover | set-cutover');
|
|
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');
|
|
332
372
|
}
|
|
333
373
|
|
|
334
374
|
// Registered group object (the CLI/MCP parity validator reads `command:` from a named const).
|
package/lib/commands/survey.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { readFileSync } from 'node:fs';
|
|
7
7
|
import { messagingGet, messagingPost, messagingDel, messagingRequest } from '../api.js';
|
|
8
8
|
import { runCommand } from '../run.js';
|
|
9
|
+
import { applyEmailSubmissionsTo } from '../survey-email.js';
|
|
9
10
|
|
|
10
11
|
const get = messagingGet;
|
|
11
12
|
const post = messagingPost;
|
|
@@ -70,9 +71,14 @@ const surveyGetCommand = {
|
|
|
70
71
|
const surveyUpsertCommand = {
|
|
71
72
|
command: 'upsert <file>',
|
|
72
73
|
describe: 'Create (omit id or set id=0) or update (set id) a survey from a JSON file containing the full SurveyViewModel shape (id, name, questions[], ...). Use "survey get <id>" on an existing survey to fetch a starting template.',
|
|
73
|
-
builder: (y) => y
|
|
74
|
+
builder: (y) => y
|
|
75
|
+
.positional('file', { type: 'string', describe: 'Path to a JSON file with the survey body' })
|
|
76
|
+
.option('email-submissions-to', {
|
|
77
|
+
type: 'string',
|
|
78
|
+
describe: 'Comma/semicolon list (max 10) of addresses that receive offline / closed-launcher submissions. Overrides the file. Pass "" to clear. Omit to keep the stored list.',
|
|
79
|
+
}),
|
|
74
80
|
handler: runCommand(async (argv) => {
|
|
75
|
-
const body = JSON.parse(readFileSync(argv.file, 'utf8'));
|
|
81
|
+
const body = applyEmailSubmissionsTo(JSON.parse(readFileSync(argv.file, 'utf8')), argv.emailSubmissionsTo);
|
|
76
82
|
const survey = await post('/Surveys', body);
|
|
77
83
|
console.log(`Upserted survey ${survey.id} (${survey.name ?? '(unnamed)'}).`);
|
|
78
84
|
}),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Survey.EmailSubmissionsTo helper (velaro-messaging PR #3209/#3214).
|
|
2
|
+
// Semantics enforced by the server on POST Surveys: field omitted/null keeps the stored
|
|
3
|
+
// recipients, "" clears them, a non-empty comma/semicolon list replaces them (max 10, validated
|
|
4
|
+
// server-side, 400 with { error } on a bad address). The server is the only validator.
|
|
5
|
+
// Mirrored in mcp/survey-email.js; keep in sync (both covered by their tests).
|
|
6
|
+
export function applyEmailSubmissionsTo(body, value) {
|
|
7
|
+
if (value === undefined || value === null) return body;
|
|
8
|
+
return { ...body, emailSubmissionsTo: String(value).trim() };
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { applyEmailSubmissionsTo } from './survey-email.js';
|
|
4
|
+
|
|
5
|
+
test('undefined and null leave the body untouched so the server keeps stored recipients', () => {
|
|
6
|
+
const body = { id: 5, name: 'S' };
|
|
7
|
+
assert.deepEqual(applyEmailSubmissionsTo(body, undefined), body);
|
|
8
|
+
assert.deepEqual(applyEmailSubmissionsTo(body, null), body);
|
|
9
|
+
assert.equal('emailSubmissionsTo' in applyEmailSubmissionsTo(body, undefined), false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('empty string is sent as "" so the server clears the list', () => {
|
|
13
|
+
assert.equal(applyEmailSubmissionsTo({ id: 5 }, '').emailSubmissionsTo, '');
|
|
14
|
+
assert.equal(applyEmailSubmissionsTo({ id: 5 }, ' ').emailSubmissionsTo, '');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('a list overrides any value already in the body and does not mutate the input', () => {
|
|
18
|
+
const body = { id: 5, emailSubmissionsTo: 'old@x.com' };
|
|
19
|
+
const out = applyEmailSubmissionsTo(body, ' a@x.com; b@x.com ');
|
|
20
|
+
assert.equal(out.emailSubmissionsTo, 'a@x.com; b@x.com');
|
|
21
|
+
assert.equal(body.emailSubmissionsTo, 'old@x.com');
|
|
22
|
+
});
|
package/package.json
CHANGED