@velaro/cli 1.4.59 → 1.4.60

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.
@@ -54,6 +54,36 @@ async function generateHandler(argv) {
54
54
  printUrls(urls);
55
55
  }
56
56
 
57
+ // velaro netsuite m2m init|save|verify - OAuth 2.0 Client Credentials (machine-to-machine).
58
+ // Backend: NetSuiteAuthController POST NetSuite/M2M/Init | Save | Verify (velaro-messaging).
59
+ function printChecks(res) {
60
+ const checks = Array.isArray(res?.checks) ? res.checks : [];
61
+ console.log(`\n${BOLD}NetSuite M2M verification${RST}`);
62
+ for (const c of checks) {
63
+ console.log(` ${c.ok ? 'PASS' : 'FAIL'} ${c.name}${c.ok ? '' : ` - ${c.reason || c.reasonCode || 'failed'}`}`);
64
+ if (!c.ok && c.howToFix) console.log(` ${DIM}How to fix: ${c.howToFix}${RST}`);
65
+ }
66
+ console.log('');
67
+ }
68
+
69
+ async function m2mInitHandler(argv) {
70
+ const res = await messagingPost('/NetSuite/M2M/Init', { id: argv.config ?? null, company: argv.company, displayName: argv.name });
71
+ console.log(`\n${BOLD}Velaro public certificate${RST} (config ${res.id ?? argv.config ?? 'new'})`);
72
+ console.log('Upload in NetSuite: Setup > Integration > Manage Authentication > OAuth 2.0 Client Credentials (M2M) Setup');
73
+ console.log(res.certificatePem ?? '(no certificate returned)');
74
+ if (Array.isArray(res.steps)) res.steps.forEach((st, i) => console.log(` ${i + 1}. ${st}`));
75
+ console.log('');
76
+ }
77
+
78
+ async function m2mSaveHandler(argv) {
79
+ await messagingPost('/NetSuite/M2M/Save', { id: Number(argv.configId), clientId: argv.clientId, certificateId: argv.certificateId });
80
+ console.log(`\n ${GRN}Saved.${RST} Run "velaro netsuite m2m verify ${argv.configId}".\n`);
81
+ }
82
+
83
+ async function m2mVerifyHandler(argv) {
84
+ printChecks(await messagingPost('/NetSuite/M2M/Verify', { id: Number(argv.configId) }));
85
+ }
86
+
57
87
  export const netsuiteCommand = {
58
88
  command: 'netsuite <subcommand>',
59
89
  describe: 'NetSuite integration setup (click-to-dial / CTI)',
@@ -81,6 +111,31 @@ export const netsuiteCommand = {
81
111
  .strict(),
82
112
  handler: () => {},
83
113
  })
114
+ .command({
115
+ command: 'm2m <action>',
116
+ describe: 'NetSuite machine-to-machine (OAuth 2.0 Client Credentials) setup',
117
+ builder: yy => yy
118
+ .command({
119
+ command: 'init',
120
+ describe: 'Generate the Velaro public certificate to upload into NetSuite',
121
+ builder: a => a.option('config', { type: 'number' }).option('company', { type: 'string' }).option('name', { type: 'string' }),
122
+ handler: m2mInitHandler,
123
+ })
124
+ .command({
125
+ command: 'save <configId>',
126
+ describe: 'Store the Client ID and Certificate ID from NetSuite',
127
+ builder: a => a.option('client-id', { type: 'string', demandOption: true }).option('certificate-id', { type: 'string', demandOption: true }),
128
+ handler: argv => m2mSaveHandler({ configId: argv.configId, clientId: argv['client-id'], certificateId: argv['certificate-id'] }),
129
+ })
130
+ .command({
131
+ command: 'verify <configId>',
132
+ describe: 'Run the per-check verification (token, REST, customer read)',
133
+ handler: m2mVerifyHandler,
134
+ })
135
+ .demandCommand(1, 'Specify an m2m action: init, save, or verify.')
136
+ .strict(),
137
+ handler: () => {},
138
+ })
84
139
  .demandCommand(1, 'Specify a netsuite subcommand.')
85
140
  .strict(),
86
141
  handler: () => {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.59",
3
+ "version": "1.4.60",
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": {