@velaro/cli 1.4.115 → 1.4.116

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.
@@ -753,6 +753,70 @@ async function deleteAlertRule(argv) {
753
753
  console.log(`\nDeleted rule ${argv.id}.\n`);
754
754
  }
755
755
 
756
+ // ── Product family rules ─────────────────────────────────────────────────────
757
+ // Logger-prefix -> product-family rules (REST: /superadmin/logs/product-families).
758
+
759
+ async function productFamilyRequest(argv, method, path, body) {
760
+ const creds = await getCredentials();
761
+ await requireAdmin(creds);
762
+ const msgBase = await getMsgBase(argv);
763
+ const res = await fetch(`${msgBase}/superadmin/logs/product-families${path}`, {
764
+ method,
765
+ headers: {
766
+ Authorization: `Bearer ${creds.velaroToken}`,
767
+ 'X-Internal-SiteId': String(creds.siteId),
768
+ ...(body !== undefined ? { 'Content-Type': 'application/json' } : {}),
769
+ },
770
+ body: body !== undefined ? JSON.stringify(body) : undefined,
771
+ signal: AbortSignal.timeout(15000),
772
+ });
773
+ if (!res.ok) {
774
+ console.error(`HTTP ${res.status}: ${await res.text().catch(() => '')}`);
775
+ process.exit(1);
776
+ }
777
+ const text = await res.text().catch(() => '');
778
+ return text ? JSON.parse(text) : null;
779
+ }
780
+
781
+ async function listProductFamilies(argv) {
782
+ const qs = argv.site !== undefined ? `?siteId=${encodeURIComponent(argv.site)}` : '';
783
+ const rules = await productFamilyRequest(argv, 'GET', qs);
784
+ if (!Array.isArray(rules)) {
785
+ console.error('Unexpected response from product-families list (expected an array).');
786
+ process.exit(1);
787
+ }
788
+ if (!rules.length) {
789
+ console.log('No product family rules. Add one with: velaro logs product-family set <loggerPrefix> <productFamily>');
790
+ return;
791
+ }
792
+ console.log(`\n${DIM}${rules.length} product family rule(s)${RESET}\n`);
793
+ for (const r of rules) {
794
+ const scope = r.siteId == null ? 'platform' : `site ${r.siteId}`;
795
+ console.log(` ${String(r.id).padEnd(5)} ${String(r.loggerPrefix).padEnd(40)} ${CYN}${r.productFamily}${RESET} ${DIM}(${scope})${RESET}`);
796
+ }
797
+ console.log('');
798
+ }
799
+
800
+ async function setProductFamily(argv) {
801
+ if (!argv.loggerPrefix || !argv.productFamily) {
802
+ console.error('Usage: velaro logs product-family set <loggerPrefix> <productFamily> [--site <id>]');
803
+ process.exit(1);
804
+ }
805
+ const body = { loggerPrefix: String(argv.loggerPrefix), productFamily: String(argv.productFamily) };
806
+ if (argv.site !== undefined) body.siteId = Number(argv.site);
807
+ const saved = await productFamilyRequest(argv, 'PUT', '', body);
808
+ console.log(`Saved rule ${saved?.id ?? ''}: ${body.loggerPrefix} -> ${body.productFamily} (${body.siteId == null ? 'platform' : `site ${body.siteId}`})`);
809
+ }
810
+
811
+ async function deleteProductFamily(argv) {
812
+ if (argv.id === undefined || Number.isNaN(Number(argv.id))) {
813
+ console.error('Usage: velaro logs product-family delete <id>');
814
+ process.exit(1);
815
+ }
816
+ await productFamilyRequest(argv, 'DELETE', `/${encodeURIComponent(argv.id)}`);
817
+ console.log(`Deleted product family rule ${argv.id}.`);
818
+ }
819
+
756
820
  // ── Alert contacts ───────────────────────────────────────────────────────────
757
821
 
758
822
  function printAlertContact(c) {
@@ -1147,6 +1211,38 @@ export const logsCommand = {
1147
1211
  })
1148
1212
  .demandCommand(1, 'Specify a subcommand: list, add, update, or remove'),
1149
1213
  })
1214
+ .command({
1215
+ command: 'product-family <subcommand>',
1216
+ describe: 'Manage logger-prefix to product-family rules shown in the Product column (Velaro staff only)',
1217
+ builder: y => y
1218
+ .command({
1219
+ command: 'list',
1220
+ describe: 'List product family rules (platform rules, plus a site\'s rules with --site)',
1221
+ builder: yy => yy
1222
+ .option('site', { describe: 'Site id to include site-scoped rules for', type: 'number' })
1223
+ .option('env', { describe: 'staging or prod', type: 'string' }),
1224
+ handler: listProductFamilies,
1225
+ })
1226
+ .command({
1227
+ command: 'set <loggerPrefix> <productFamily>',
1228
+ describe: 'Create or update a rule: loggers starting with <loggerPrefix> belong to <productFamily>',
1229
+ builder: yy => yy
1230
+ .positional('loggerPrefix', { describe: 'Logger name prefix, e.g. Velaro.Messaging.Ivr', type: 'string' })
1231
+ .positional('productFamily', { describe: 'Product family label, e.g. IVR', type: 'string' })
1232
+ .option('site', { describe: 'Scope the rule to one site (default: all sites)', type: 'number' })
1233
+ .option('env', { describe: 'staging or prod', type: 'string' }),
1234
+ handler: setProductFamily,
1235
+ })
1236
+ .command({
1237
+ command: 'delete <id>',
1238
+ describe: 'Delete a rule by id (from: velaro logs product-family list)',
1239
+ builder: yy => yy
1240
+ .positional('id', { describe: 'Rule id', type: 'number' })
1241
+ .option('env', { describe: 'staging or prod', type: 'string' }),
1242
+ handler: deleteProductFamily,
1243
+ })
1244
+ .demandCommand(1, 'Specify a subcommand: list, set, or delete'),
1245
+ })
1150
1246
  .command(logsInsightsCommand)
1151
- .demandCommand(1, 'Specify a subcommand: search, tail, diagnose, digest-recipients, set-digest-recipients, alerts, contacts, or insights'),
1247
+ .demandCommand(1, 'Specify a subcommand: search, tail, diagnose, digest-recipients, set-digest-recipients, alerts, contacts, product-family, or insights'),
1152
1248
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.115",
3
+ "version": "1.4.116",
4
4
  "description": "Velaro Workspace v20 — command-line interface for managing bots, knowledge base ingestion, MCP API keys, search indexes, and ops health.",
5
5
  "type": "module",
6
6
  "bin": {