@opscompass/opscompass-cli 1.3.6 → 1.3.8

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.
@@ -24,43 +24,61 @@ async function listLocalScripts(args) {
24
24
  }
25
25
 
26
26
  const scriptTypes = Object.values(ScriptType);
27
- let scriptsLocal;
27
+ const scriptsLocal = { path: undefined, versions: [] };
28
+ const failedScriptTypes = [];
28
29
 
29
30
  try {
30
31
  const baseScriptFolderPath = findOrCreateScriptsFolder();
31
- scriptsLocal = { path: baseScriptFolderPath, versions: [] };
32
+ scriptsLocal.path = baseScriptFolderPath;
32
33
  const items = fs.readdirSync(baseScriptFolderPath, { withFileTypes: true });
33
34
 
34
35
  for (const item of items) {
35
- if (scriptTypes.includes(item.name) && item.isDirectory()) {
36
- let metaFile = path.join(
37
- baseScriptFolderPath,
38
- item.name,
39
- "metadata.json",
40
- );
41
- if (fs.existsSync(metaFile)) {
42
- const data = fs.readFileSync(metaFile);
43
- const metaVersion = JSON.parse(data.toString());
44
-
45
- scriptsLocal.versions.push({
46
- scriptType: item.name,
47
- scriptVersion: metaVersion.version,
48
- });
36
+ if (!scriptTypes.includes(item.name) || !item.isDirectory()) {
37
+ continue;
38
+ }
39
+
40
+ const metaFile = path.join(
41
+ baseScriptFolderPath,
42
+ item.name,
43
+ "metadata.json",
44
+ );
45
+ if (!fs.existsSync(metaFile)) {
46
+ failedScriptTypes.push(item.name);
47
+ continue;
48
+ }
49
+
50
+ try {
51
+ const data = fs.readFileSync(metaFile);
52
+ const metaVersion = JSON.parse(data.toString());
53
+ if (!metaVersion?.version) {
54
+ failedScriptTypes.push(item.name);
55
+ continue;
49
56
  }
57
+
58
+ scriptsLocal.versions.push({
59
+ scriptType: item.name,
60
+ scriptVersion: metaVersion.version,
61
+ });
62
+ } catch (err) {
63
+ console.log(err);
64
+ failedScriptTypes.push(item.name);
50
65
  }
51
66
  }
52
67
 
53
- if (items.length <= 0) {
54
- throw "Cannot list scripts. Make sure the scripts are downloaded.\nIf the issue persists, contact your OpsCompass rep.";
55
- } else {
56
- if (!quiet) {
57
- // Go with compact output for this display
58
- // console.log(JSON.stringify(scriptsLocal, null, 2));
59
- console.log(scriptsLocal);
60
- }
68
+
69
+ if (!quiet) {
70
+ // Go with compact output for this display
71
+ // console.log(JSON.stringify(scriptsLocal, null, 2));
72
+ console.log(scriptsLocal);
61
73
  }
62
74
  } catch (err) {
63
75
  console.log(err);
76
+ scriptsLocal.success = false;
77
+ scriptsLocal.error = err;
78
+ }
79
+ if (failedScriptTypes.length > 0) {
80
+ scriptsLocal.success = false;
81
+ scriptsLocal.failedScriptTypes = failedScriptTypes;
64
82
  }
65
83
 
66
84
  return scriptsLocal;
@@ -92,7 +110,8 @@ async function downloadScripts(args) {
92
110
  const scriptTypes = Object.values(ScriptType);
93
111
  if (!scriptTypes.includes(scriptType)) {
94
112
  console.log("Unsupported script type...");
95
- return;
113
+ process.exitCode = 1;
114
+ return { success: false, scriptType };
96
115
  }
97
116
 
98
117
  try {
@@ -106,9 +125,16 @@ async function downloadScripts(args) {
106
125
  );
107
126
 
108
127
  console.log("Downloaded %s (v%s)", scriptType, rcvdVersion);
128
+ return {
129
+ success: true,
130
+ scriptType,
131
+ downloadedVersion: rcvdVersion,
132
+ };
109
133
  } catch (err) {
110
134
  console.log("Download script type %s failed...", scriptType);
111
135
  console.log(err);
136
+ process.exitCode = 1;
137
+ return { success: false, scriptType, error: err };
112
138
  }
113
139
  }
114
140
 
@@ -142,6 +168,7 @@ async function listAvailableScripts(args) {
142
168
  } catch (err) {
143
169
  console.log("List available script versions failed...");
144
170
  console.log(err);
171
+ return { success: false, error: err };
145
172
  }
146
173
  }
147
174
 
@@ -152,6 +179,21 @@ async function listAvailableScripts(args) {
152
179
  async function checkScriptUpdates(args) {
153
180
  let scriptType = undefined;
154
181
  let autoUpdate = false;
182
+ const updateResult = { success: true, failedScriptTypes: [] };
183
+ const recordUpdateFailure = (failedScriptType) => {
184
+ updateResult.success = false;
185
+ if (
186
+ failedScriptType &&
187
+ !updateResult.failedScriptTypes.includes(failedScriptType)
188
+ ) {
189
+ updateResult.failedScriptTypes.push(failedScriptType);
190
+ }
191
+ process.exitCode = 1;
192
+ return updateResult;
193
+ };
194
+ const isValidVersion = (version) =>
195
+ typeof version === "string" && semver.valid(version) !== null;
196
+
155
197
  for (let i = 0; i < args.length; i++) {
156
198
  switch (args[i].toLowerCase()) {
157
199
  case "--auto-update":
@@ -168,30 +210,58 @@ async function checkScriptUpdates(args) {
168
210
  }
169
211
  }
170
212
 
171
- const client = await getOpsCompassClient();
213
+ const scriptTypes = Object.values(ScriptType);
172
214
 
173
215
  // If script type was specified, just check that one
174
216
  if (scriptType) {
175
217
  // If script type is not supported, we do not want to continue.
176
- const scriptTypes = Object.values(ScriptType);
177
218
  if (!scriptTypes.includes(scriptType)) {
178
219
  console.log("Unsupported script type...");
179
- return;
220
+ return recordUpdateFailure(scriptType);
180
221
  }
181
222
 
182
- const currentScriptVersion = await getInstalledScriptVersion(scriptType);
223
+ let currentScriptVersion;
224
+ try {
225
+ currentScriptVersion = await getInstalledScriptVersion(scriptType);
226
+ } catch (err) {
227
+ console.log("Check local script version for type %s failed...", scriptType);
228
+ console.log(err);
229
+ return recordUpdateFailure(scriptType);
230
+ }
183
231
 
184
232
  if (!currentScriptVersion) {
185
233
  console.log(
186
234
  `Local scripts for type ${scriptType} not found. Please make sure they are downloaded.`,
187
235
  );
188
236
  console.log("If the issue persists, please contact your OpsCompass rep.");
189
- return;
237
+ return recordUpdateFailure(scriptType);
190
238
  }
191
239
 
192
- console.log("Checking for latest version of module %s...", scriptType);
193
- const latestScriptVersion =
194
- await client.dataGatheringScripts.checkScriptUpdates(company, scriptType);
240
+ if (!isValidVersion(currentScriptVersion)) {
241
+ console.log("Local script version for type %s is malformed.", scriptType);
242
+ return recordUpdateFailure(scriptType);
243
+ }
244
+
245
+ let client;
246
+ let latestScriptVersion;
247
+ try {
248
+ client = await getOpsCompassClient();
249
+ console.log("Checking for latest version of module %s...", scriptType);
250
+ latestScriptVersion =
251
+ await client.dataGatheringScripts.checkScriptUpdates(
252
+ company,
253
+ scriptType,
254
+ );
255
+ } catch (err) {
256
+ console.log("Check latest script version for type %s failed...", scriptType);
257
+ console.log(err);
258
+ return recordUpdateFailure(scriptType);
259
+ }
260
+
261
+ if (!isValidVersion(latestScriptVersion?.scriptVersion)) {
262
+ console.log("Remote script version for type %s is malformed.", scriptType);
263
+ return recordUpdateFailure(scriptType);
264
+ }
195
265
 
196
266
  //Semver returns true if the latest version is higher than the currentScriptVersion.
197
267
  if (semver.gt(latestScriptVersion.scriptVersion, currentScriptVersion)) {
@@ -218,6 +288,7 @@ async function checkScriptUpdates(args) {
218
288
  } catch (err) {
219
289
  console.log("Update script type %s failed...", scriptType);
220
290
  console.log(err);
291
+ recordUpdateFailure(scriptType);
221
292
  }
222
293
  }
223
294
  console.log();
@@ -229,37 +300,98 @@ async function checkScriptUpdates(args) {
229
300
  console.log();
230
301
  }
231
302
  } else {
303
+ let client;
304
+ try {
305
+ client = await getOpsCompassClient();
306
+ } catch (err) {
307
+ console.log("Check script updates failed...");
308
+ console.log(err);
309
+ return recordUpdateFailure();
310
+ }
311
+
232
312
  const scriptsLocal = await listLocalScripts([...args, "--quiet"]);
233
313
 
234
- if (
235
- scriptsLocal &&
236
- Array.isArray(scriptsLocal?.versions) &&
237
- scriptsLocal.versions?.length > 0
238
- ) {
239
- // We have at least one scriptType downloaded
240
- } else {
314
+ if (scriptsLocal?.success === false) {
315
+ if (
316
+ Array.isArray(scriptsLocal.failedScriptTypes) &&
317
+ scriptsLocal.failedScriptTypes.length > 0
318
+ ) {
319
+ for (const failedScriptType of scriptsLocal.failedScriptTypes) {
320
+ recordUpdateFailure(failedScriptType);
321
+ }
322
+ } else {
323
+ recordUpdateFailure();
324
+ }
325
+ }
326
+
327
+ if (!scriptsLocal || !Array.isArray(scriptsLocal.versions)) {
328
+ return recordUpdateFailure();
329
+ }
330
+
331
+ // DECISION: Treat a successfully read empty recognized inventory as a normal first-run informational state, but require a successful remote listing before reporting it.
332
+ const noLocalScripts = scriptsLocal.versions.length === 0;
333
+ if (noLocalScripts) {
241
334
  console.error("\nScripts available for download:");
242
- listAvailableScripts(args);
243
- return;
335
+ } else {
336
+ // Sort by script-type
337
+ scriptsLocal.versions.sort(function (a, b) {
338
+ return a.scriptType < b.scriptType
339
+ ? -1
340
+ : a.scriptType > b.scriptType
341
+ ? 1
342
+ : 0;
343
+ });
344
+
345
+ console.log("\nCheck-Updates fetching remote versions...");
244
346
  }
245
347
 
246
- // Sort by script-type
247
- scriptsLocal.versions.sort(function (a, b) {
248
- return a.scriptType < b.scriptType
249
- ? -1
250
- : a.scriptType > b.scriptType
251
- ? 1
252
- : 0;
253
- });
348
+ const scriptsRemote = await listAvailableScripts(
349
+ noLocalScripts ? args : [...args, "--quiet"],
350
+ );
351
+
352
+ if (
353
+ scriptsRemote?.success === false ||
354
+ !Array.isArray(scriptsRemote?.versions)
355
+ ) {
356
+ if (scriptsRemote?.success !== false) {
357
+ console.log("Remote script version response was malformed.");
358
+ }
359
+ return recordUpdateFailure();
360
+ }
254
361
 
255
- console.log("\nCheck-Updates fetching remote versions...");
256
- const scriptsRemote = await listAvailableScripts([...args, "--quiet"]);
362
+ if (noLocalScripts) {
363
+ if (updateResult.success) {
364
+ updateResult.status = "no_local_scripts";
365
+ }
366
+ return updateResult;
367
+ }
257
368
 
258
369
  for (const scriptVer of scriptsLocal.versions) {
370
+ if (
371
+ !scriptVer?.scriptType ||
372
+ !isValidVersion(scriptVer.scriptVersion)
373
+ ) {
374
+ console.log(
375
+ "Local script version for type %s is malformed.",
376
+ scriptVer?.scriptType,
377
+ );
378
+ recordUpdateFailure(scriptVer?.scriptType);
379
+ continue;
380
+ }
381
+
259
382
  const remoteVer = scriptsRemote.versions.find(
260
- (version) => version.scriptType === scriptVer.scriptType,
383
+ (version) => version?.scriptType === scriptVer.scriptType,
261
384
  );
262
385
 
386
+ if (!remoteVer || !isValidVersion(remoteVer.scriptVersion)) {
387
+ console.log(
388
+ "Remote script version for type %s is missing or malformed.",
389
+ scriptVer.scriptType,
390
+ );
391
+ recordUpdateFailure(scriptVer.scriptType);
392
+ continue;
393
+ }
394
+
263
395
  const needsUpdate = semver.gt(
264
396
  remoteVer.scriptVersion,
265
397
  scriptVer.scriptVersion,
@@ -294,8 +426,12 @@ async function checkScriptUpdates(args) {
294
426
  rcvdVersion,
295
427
  );
296
428
  } catch (err) {
297
- console.log("Auto update script type %s failed...", scriptType);
429
+ console.log(
430
+ "Auto update script type %s failed...",
431
+ scriptVer.scriptType,
432
+ );
298
433
  console.log(err);
434
+ recordUpdateFailure(scriptVer.scriptType);
299
435
  }
300
436
  }
301
437
  console.log();
@@ -309,6 +445,7 @@ async function checkScriptUpdates(args) {
309
445
  }
310
446
  //console.log(scriptsRemote);
311
447
  }
448
+ return updateResult;
312
449
  }
313
450
 
314
451
  async function autoCheckScriptUpdates(args) {
@@ -599,6 +599,19 @@ async function printDataGatheringHelp(ui = createDataGatheringUi()) {
599
599
  ui.item("--parallel <n>", "Surface reserved for future parallel execution.");
600
600
  ui.item("--allow-unverified", "Break-glass: allow execution of unverified bundles.");
601
601
 
602
+ ui.blank();
603
+ ui.section("Send DG Parameters");
604
+ ui.item("<file> [...file]", "One or more DG artifacts. Plain files are archived, encrypted, and uploaded.");
605
+ ui.item("--metadata-type", "sql-server-database | oracle-database | vmware-vsphere | network-discovery | nutanix-prism");
606
+ ui.item("--file-type", "Required for oracle/sql-server: oracle supports ebusiness, licensing, compliance; sql-server supports licensing, compliance.");
607
+ ui.item("--destinations", "Only oc is supported; default oc.");
608
+ ui.item("--company", "Company slug; omitted only when a default company is configured.");
609
+ ui.item("--account", "Account token used for encryption; omitted only when a default account is configured.");
610
+ ui.item("--directory", "Base directory for relative file paths; default current directory.");
611
+ ui.item("--log-directory", "Directory of DG logs to include when eligible; default OpsCompass log directory.");
612
+ ui.item("Accepted archive names", ".tgz, .tar.gz, .tgz.gpg, and .tar.gz.gpg. Encrypted .tar.gz.gpg files upload with a .tgz.gpg-compatible name.");
613
+
614
+
602
615
  ui.blank();
603
616
  ui.section("Examples");
604
617
  ui.command(
@@ -613,9 +626,16 @@ async function printDataGatheringHelp(ui = createDataGatheringUi()) {
613
626
  `${cliCommand} data-gathering run --dry-run --config /path/to/dgConfig.json --module msql-license`,
614
627
  "Preview the execution plan without running collectors.",
615
628
  );
629
+ ui.command(
630
+ `${cliCommand} data-gathering send-dg /path/to/oracle-metadata.tgz.gpg --metadata-type oracle-database --file-type licensing --company <slug>`,
631
+ "Upload a pre-encrypted Oracle licensing artifact.",
632
+ );
616
633
  ui.blank();
634
+ return { exitCode: DATA_GATHERING_EXIT_CODES.success };
617
635
  }
618
636
 
637
+
638
+
619
639
  function getCompletionEventType(action) {
620
640
  return action?.toLowerCase() === "setup" ? "setup.completed" : "run.completed";
621
641
  }
@@ -656,6 +676,8 @@ async function runDataGatheringAction(action, args) {
656
676
  },
657
677
  );
658
678
  case "help":
679
+ case "--help":
680
+ case "-h":
659
681
  case "":
660
682
  return printDataGatheringHelp(ui);
661
683
  default:
@@ -0,0 +1,87 @@
1
+ import { getOpsCompassClient } from "../../opscompass.js";
2
+
3
+ function parseAssessmentArgs(args, oracle) {
4
+ let company = global.company;
5
+ let account = global.account;
6
+ const options = {};
7
+ const allowedFlags = ["--company", "--account", "--assessment-id", "--limit", "--offset"];
8
+ if (oracle) allowedFlags.push("--mlss-assessment-id", "--account-id", "--accountid");
9
+ for (let i = 0; i < args.length; i++) {
10
+ const flag = typeof args[i] === "string" ? args[i].toLowerCase() : "";
11
+ if (!allowedFlags.includes(flag)) {
12
+ throw new Error(`Unknown assessment option: ${args[i]}`);
13
+ }
14
+ const value = args[++i];
15
+ if (typeof value !== "string" || value.trim() === "" || value.startsWith("--")) {
16
+ throw new Error(`${flag} requires a nonblank value.`);
17
+ }
18
+ if (flag === "--company") company = value;
19
+ else if (["--account", "--account-id", "--accountid"].includes(flag)) account = value;
20
+ else {
21
+ const number = Number(value);
22
+ const minimum = flag === "--offset" ? 0 : 1;
23
+ const maximum = flag === "--limit" ? 500 : Number.MAX_SAFE_INTEGER;
24
+ if (!Number.isSafeInteger(number) || number < minimum || number > maximum) {
25
+ throw new Error(`${flag} must be an integer from ${minimum} through ${maximum}.`);
26
+ }
27
+ if (flag === "--assessment-id") options.assessmentId = number;
28
+ else if (flag === "--limit") options.limit = number;
29
+ else if (flag === "--offset") options.offset = number;
30
+ else if (flag === "--mlss-assessment-id") options.mlssAssessmentId = number;
31
+ }
32
+ }
33
+ if (typeof company !== "string" || company.trim() === "") {
34
+ throw new Error("--company is required (or set a default company).");
35
+ }
36
+ if ((typeof account !== "string" && typeof account !== "number") || String(account).trim() === "") {
37
+ throw new Error("--account is required (or set a default account).");
38
+ }
39
+ if (options.assessmentId !== undefined && options.mlssAssessmentId !== undefined) {
40
+ throw new Error("--assessment-id and --mlss-assessment-id are mutually exclusive; use one or the other.");
41
+ }
42
+ return { company: company.trim(), accountId: String(account).trim(), options };
43
+ }
44
+
45
+ export async function readAssessmentSection(args, method, oracle = false) {
46
+ let parsed;
47
+ try {
48
+ parsed = parseAssessmentArgs(args, oracle);
49
+ } catch (error) {
50
+ process.exitCode = 1;
51
+ console.error(`ERROR: ${error.message}`);
52
+ return;
53
+ }
54
+ try {
55
+ const client = await getOpsCompassClient();
56
+ const service = oracle ? client.licenseManager : client.licenseManager.mssql;
57
+ const result = await service[method](parsed.company, parsed.accountId, parsed.options);
58
+ console.log(JSON.stringify(result, null, 2));
59
+ } catch (error) {
60
+ process.exitCode = 1;
61
+ throw error;
62
+ }
63
+ }
64
+
65
+ export function printAssessmentHelp(vendor) {
66
+ console.log(`Persisted periodic ${vendor} assessment sections (no recalculation):`);
67
+ console.log(`get-${vendor}-assessment-summary — Compliance tab: assessmentSummary`);
68
+ console.log(`get-${vendor}-assessment-entitlements — Entitlements tab: assessmentEntitlements`);
69
+ console.log(`get-${vendor}-assessment-license-usage-summary — License usage map tab: licenseUsageSummary`);
70
+ console.log(`get-${vendor}-assessment-deployment-details — Deployment details tab: deploymentDetails`);
71
+ console.log("--company [slug] and --account [account-id-or-cloudSubscriptionId] use existing defaults when omitted.");
72
+ if (vendor === "oracle") console.log("--account-id / --accountid are account aliases and override the current account.");
73
+ console.log("--assessment-id [positive safe integer] pins the local row ID. Omit assessment selectors to read the current persisted assessment.");
74
+ if (vendor === "oracle") {
75
+ console.log("--mlss-assessment-id [positive safe integer] selects by MLSS assessment ID instead of local row ID.");
76
+ console.log("MLSS and local assessment ID are separate namespaces; when both selectors are omitted, the current persisted assessment is selected.");
77
+ console.log("--assessment-id and --mlss-assessment-id are mutually exclusive; the returned assessmentId is always the local row ID.");
78
+ }
79
+ console.log("--limit [1..500] defaults to 100; --offset [nonnegative safe integer] defaults to 0.");
80
+ console.log("Pin the returned assessmentId across pages/sections. Increment offset by limit until the section array is shorter than limit; an exact final full page needs an empty page.");
81
+ console.log("Nested details are complete and do not count against page size. ID pinning prevents selection rollover, not edits under the same ID.");
82
+ if (vendor === "mssql") {
83
+ console.log("Reads the stored layout used by v3 and shared with v2, without legacy calculation fallback. Current results have v3 provenance only after verified regeneration; historical v2/v3 provenance is unknown.");
84
+ console.log("Breaking change: get-mssql-assessment-entitlements now requires company/account scope, accepts --assessment-id (not --id), and returns a paginated envelope rather than an array. Coordinate backend/client release.");
85
+ }
86
+ console.log();
87
+ }
@@ -1,4 +1,5 @@
1
1
  import { getOpsCompassClient } from "../../opscompass.js";
2
+ import { readAssessmentSection, printAssessmentHelp } from "./assessment.js";
2
3
  import { utilsModule as utils } from "../../lib/utils.js";
3
4
  import maskValues from "../../lib/maskValues.js";
4
5
  import resolveMonitoringConfigId from "./resolveMonitoringConfigId.js";
@@ -189,24 +190,19 @@ async function getMssqlAssessment(args) {
189
190
  }
190
191
 
191
192
  async function getMssqlAssessmentEntitlements(args) {
192
- let assessmentId = undefined;
193
- for (let i = 0; i < args.length - 1; i++) {
194
- switch (args[i].toLowerCase()) {
195
- case "--assessmentId":
196
- case "--id":
197
- case "--assessmentid":
198
- assessmentId = args[++i];
199
- break;
200
- }
201
- }
193
+ return readAssessmentSection(args, "getMssqlAssessmentEntitlements");
194
+ }
202
195
 
203
- const client = await getOpsCompassClient();
204
- const response =
205
- await client.licenseManager.mssql.getMssqlAssessmentEntitlements(
206
- assessmentId,
207
- );
196
+ async function getMssqlAssessmentSummary(args) {
197
+ return readAssessmentSection(args, "getMssqlAssessmentSummary");
198
+ }
208
199
 
209
- console.log(JSON.stringify(response, null, 2));
200
+ async function getMssqlAssessmentLicenseUsageSummary(args) {
201
+ return readAssessmentSection(args, "getMssqlAssessmentLicenseUsageSummary");
202
+ }
203
+
204
+ async function getMssqlAssessmentDeploymentDetails(args) {
205
+ return readAssessmentSection(args, "getMssqlAssessmentDeploymentDetails");
210
206
  }
211
207
 
212
208
  async function getMssqlAssessmentLicenseUsageMaps(args) {
@@ -250,23 +246,46 @@ async function getMssqlAssessmentResources(args) {
250
246
  }
251
247
 
252
248
  async function checkMssqlConfigMetadata(args) {
253
- let callParams = {};
254
- for (let i = 0; i < args.length - 1; i++) {
249
+ const callParams = {};
250
+ let hasExplicitAccount = false;
251
+ for (let i = 0; i < args.length; i++) {
255
252
  switch (args[i].toLowerCase()) {
256
253
  case "--account-id":
257
254
  case "--accountid":
258
- callParams.accountId = args[++i];
255
+ hasExplicitAccount = true;
256
+ if (
257
+ args[i + 1] !== undefined &&
258
+ !args[i + 1].startsWith("--")
259
+ ) {
260
+ callParams.accountId = args[++i];
261
+ }
259
262
  break;
260
263
  case "--last-collected-before":
261
264
  case "--lastcollectedbefore":
262
- callParams.lastCollectedBefore = args[++i];
265
+ if (args[i + 1] !== undefined) {
266
+ callParams.lastCollectedBefore = args[++i];
267
+ }
263
268
  break;
264
269
  }
265
270
  }
266
271
 
272
+ const selectedAccount = hasExplicitAccount
273
+ ? callParams.accountId
274
+ : global.account;
275
+ if (selectedAccount === undefined || selectedAccount === null) {
276
+ console.error("ERROR: --account is required (or set a default account).");
277
+ return;
278
+ }
279
+
280
+ const normalizedAccount = String(selectedAccount).trim();
281
+ if (normalizedAccount === "") {
282
+ console.error("ERROR: --account is required (or set a default account).");
283
+ return;
284
+ }
285
+
267
286
  const client = await getOpsCompassClient();
268
287
  const response = await client.licenseManager.mssql.checkMssqlConfigMetadata(
269
- callParams.accountId,
288
+ normalizedAccount,
270
289
  global.company,
271
290
  callParams.lastCollectedBefore,
272
291
  );
@@ -593,6 +612,7 @@ async function updateMssqlConfigurations(args) {
593
612
  }
594
613
 
595
614
  async function printMssqlHelp() {
615
+ printAssessmentHelp("mssql");
596
616
  console.log(
597
617
  "create-mssql-shared-credential",
598
618
  "Creates MS SQL shared credentials",
@@ -810,13 +830,6 @@ async function printMssqlHelp() {
810
830
  console.log("Parameters:");
811
831
  console.log("--assessmentId [number] The id of the assessment to retrieve.");
812
832
  console.log();
813
- console.log(
814
- "get-mssql-assessment-entitlements",
815
- "Gets Entitlements for an MSSQL Assessment",
816
- );
817
- console.log("Parameters:");
818
- console.log("--assessmentId [number] The id of the assessment to retrieve.");
819
- console.log();
820
833
  console.log(
821
834
  "(DEPRECATED) get-mssql-assessment-license-usage-maps",
822
835
  "Gets LicenseUsageMaps for an MSSQL Assessment",
@@ -836,7 +849,8 @@ async function printMssqlHelp() {
836
849
  "Checks the mssql configuration metadata for a company.",
837
850
  );
838
851
  console.log("Parameters:");
839
- console.log("--accountId [string] The account id for the company.");
852
+ console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId for the company.");
853
+ console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (optional legacy aliases; override the current account)");
840
854
  console.log(`--company [company_slug] (default: ${global.company})\n`);
841
855
  console.log(
842
856
  "--lastCollectedBefore [string] (optional) Only returns records that have not been collected since the given date. Format: UTC, example: '2022-08-23T17:00:00Z'",
@@ -853,6 +867,9 @@ export {
853
867
  listMssqlAssessments,
854
868
  getMssqlAssessment,
855
869
  getMssqlAssessmentEntitlements,
870
+ getMssqlAssessmentSummary,
871
+ getMssqlAssessmentLicenseUsageSummary,
872
+ getMssqlAssessmentDeploymentDetails,
856
873
  getMssqlAssessmentLicenseUsageMaps,
857
874
  getMssqlAssessmentResources,
858
875
  checkMssqlConfigMetadata,
@@ -880,6 +897,9 @@ const licenseManagerMssqlModule = {
880
897
  listMssqlAssessments,
881
898
  getMssqlAssessment,
882
899
  getMssqlAssessmentEntitlements,
900
+ getMssqlAssessmentSummary,
901
+ getMssqlAssessmentLicenseUsageSummary,
902
+ getMssqlAssessmentDeploymentDetails,
883
903
  getMssqlAssessmentLicenseUsageMaps,
884
904
  getMssqlAssessmentResources,
885
905
  checkMssqlConfigMetadata,