@opscompass/opscompass-cli 1.3.7 → 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.
package/README.md CHANGED
@@ -104,3 +104,42 @@ Here, the OpsCompass ID of the resource is 1234567. When you have the OpsCompass
104
104
  ```
105
105
  opscompass resources get --company your_company_id --id 1234567
106
106
  ```
107
+
108
+ ## Persisted Oracle and MSSQL assessments
109
+
110
+ These commands read periodically persisted licensing results, not live configuration or current-entitlement inventory. No call recalculates an assessment, looks up another account, or fetches every page automatically.
111
+
112
+ | UI tab | Oracle command | MSSQL command | JSON section |
113
+ | --- | --- | --- | --- |
114
+ | Compliance | `get-oracle-assessment-summary` | `get-mssql-assessment-summary` | `assessmentSummary` |
115
+ | Entitlements | `get-oracle-assessment-entitlements` | `get-mssql-assessment-entitlements` | `assessmentEntitlements` |
116
+ | License usage map | `get-oracle-assessment-license-usage-summary` | `get-mssql-assessment-license-usage-summary` | `licenseUsageSummary` |
117
+ | Deployment details | `get-oracle-assessment-deployment-details` | `get-mssql-assessment-deployment-details` | `deploymentDetails` |
118
+
119
+ Run each under `license-manager`, for example:
120
+
121
+ ```bash
122
+ opscompass license-manager get-oracle-assessment-summary --company acme --account 42 --limit 100 --offset 0
123
+ opscompass license-manager get-oracle-assessment-entitlements --company acme --account 42 --assessment-id 123 --limit 100 --offset 0
124
+ opscompass license-manager get-oracle-assessment-summary --company acme --account 42 --mlss-assessment-id 55
125
+ opscompass license-manager get-mssql-assessment-summary --company acme --account sql-account --limit 100 --offset 0
126
+ ```
127
+
128
+ - `--company` and `--account` use existing saved defaults when omitted. The backend resolves account by trying company-scoped positive numeric row ID first, then exact `cloudSubscriptionId` match; account accepts any nonblank opaque string (leading/trailing whitespace trimmed), so numeric strings such as `'0'` or oversized integers are valid client-side and resolved server-side within the company. Oracle also accepts `--account-id` / `--accountid`, overriding the current account.
129
+ - `--assessment-id` is an optional positive safe integer; when omitted and no `--mlss-assessment-id` is supplied, selects the current persisted assessment. Pin the returned `assessmentId` for subsequent pages and other sections to prevent current-selection rollover. This does not make rows immutable if ingestion edits them under the same ID.
130
+ - Oracle-only: `--mlss-assessment-id` selects by MLSS assessment ID instead of local row ID. MLSS and local assessment IDs are separate namespaces; when both selectors are omitted, the current persisted assessment is selected. `--assessment-id` and `--mlss-assessment-id` are mutually exclusive; supplying both is an error. The returned `assessmentId` is always the local row ID. MSSQL commands reject `--mlss-assessment-id`.
131
+ - `--limit` accepts integers 1 through 500 (default 100). `--offset` accepts nonnegative safe integers (default 0). Increment offset by limit and stop when the selected section array contains fewer than limit rows; an exact final full page is followed by an empty page.
132
+ - Pagination counts top-level rows only. Entitlement, usage and deployment modal details remain nested and complete for the selected rows; child arrays are not limited to 500.
133
+ - Each success prints one JSON object containing assessment metadata, effective `pagination`, and exactly one section. Missing assessments are errors; valid empty sections/pages retain metadata. Invalid, blank, missing or unknown flags fail with a nonzero exit and no request. API failures also exit nonzero, without a fake success document.
134
+
135
+ Oracle retains metric labels, decimal-string prices, negative availability, comments and nulls. Its physical-machine/deployment identifiers are MLSS/OLM IDs, not OpsCompass inventory resource IDs. MSSQL preserves stored entitlement prices, including zero/null, and real optional inventory resource links. MSSQL reads the stored layout used by v3 and shared with v2, with no v1 calculation fallback. Current results are known to have v3 provenance only after verified producer regeneration; pinned historical v2/v3 provenance is unknown.
136
+
137
+ ### Breaking release: assessment entitlements
138
+
139
+ `get-mssql-assessment-entitlements` deliberately replaces the old assessment-ID-only request and bare-array response. Use company/account scope and optional `--assessment-id` instead of `--id` / `--assessmentId`; read `assessmentEntitlements` from the page envelope. There is no legacy alias or dual response schema. Coordinate backend/API and client distribution; older installed clients do not accept this contract.
140
+
141
+ The SDK uses the same single-page contract. Oracle methods are on `client.licenseManager`; MSSQL methods are on `client.licenseManager.mssql`. Method names match the commands in camelCase (for example `getOracleAssessmentSummary` and `getMssqlAssessmentEntitlements`). All four Oracle methods take `(companySlug: string, accountId: string | number, options?: OracleAssessmentReadOptions)` with optional `assessmentId`, `mlssAssessmentId`, `limit`, and `offset`. The four MSSQL methods take `(companySlug: string, accountId: string | number, options?: AssessmentReadOptions)` with optional `assessmentId`, `limit`, and `offset`. Both reject on HTTP failures. Use the returned ID and offsets yourself; the SDK does not fan out or rename sections.
142
+
143
+ ### Operator rollout order
144
+
145
+ The MLSS source-selection feature requires staged deployment: MLSS service first, then the customer-facing API, then the SDK/CLI client. Do not release client support before the backend accepts the new query parameter.
@@ -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) {
@@ -616,6 +612,7 @@ async function updateMssqlConfigurations(args) {
616
612
  }
617
613
 
618
614
  async function printMssqlHelp() {
615
+ printAssessmentHelp("mssql");
619
616
  console.log(
620
617
  "create-mssql-shared-credential",
621
618
  "Creates MS SQL shared credentials",
@@ -833,13 +830,6 @@ async function printMssqlHelp() {
833
830
  console.log("Parameters:");
834
831
  console.log("--assessmentId [number] The id of the assessment to retrieve.");
835
832
  console.log();
836
- console.log(
837
- "get-mssql-assessment-entitlements",
838
- "Gets Entitlements for an MSSQL Assessment",
839
- );
840
- console.log("Parameters:");
841
- console.log("--assessmentId [number] The id of the assessment to retrieve.");
842
- console.log();
843
833
  console.log(
844
834
  "(DEPRECATED) get-mssql-assessment-license-usage-maps",
845
835
  "Gets LicenseUsageMaps for an MSSQL Assessment",
@@ -877,6 +867,9 @@ export {
877
867
  listMssqlAssessments,
878
868
  getMssqlAssessment,
879
869
  getMssqlAssessmentEntitlements,
870
+ getMssqlAssessmentSummary,
871
+ getMssqlAssessmentLicenseUsageSummary,
872
+ getMssqlAssessmentDeploymentDetails,
880
873
  getMssqlAssessmentLicenseUsageMaps,
881
874
  getMssqlAssessmentResources,
882
875
  checkMssqlConfigMetadata,
@@ -904,6 +897,9 @@ const licenseManagerMssqlModule = {
904
897
  listMssqlAssessments,
905
898
  getMssqlAssessment,
906
899
  getMssqlAssessmentEntitlements,
900
+ getMssqlAssessmentSummary,
901
+ getMssqlAssessmentLicenseUsageSummary,
902
+ getMssqlAssessmentDeploymentDetails,
907
903
  getMssqlAssessmentLicenseUsageMaps,
908
904
  getMssqlAssessmentResources,
909
905
  checkMssqlConfigMetadata,
@@ -1,4 +1,21 @@
1
1
  import { getOpsCompassClient } from "../../opscompass.js";
2
+ import { readAssessmentSection, printAssessmentHelp } from "./assessment.js";
3
+
4
+ async function getOracleAssessmentSummary(args) {
5
+ return readAssessmentSection(args, "getOracleAssessmentSummary", true);
6
+ }
7
+
8
+ async function getOracleAssessmentEntitlements(args) {
9
+ return readAssessmentSection(args, "getOracleAssessmentEntitlements", true);
10
+ }
11
+
12
+ async function getOracleAssessmentLicenseUsageSummary(args) {
13
+ return readAssessmentSection(args, "getOracleAssessmentLicenseUsageSummary", true);
14
+ }
15
+
16
+ async function getOracleAssessmentDeploymentDetails(args) {
17
+ return readAssessmentSection(args, "getOracleAssessmentDeploymentDetails", true);
18
+ }
2
19
 
3
20
  /**
4
21
  * Guard that the next argument in args at i+1 is present and not another flag.
@@ -440,6 +457,7 @@ async function getOracleOrderItems(args) {
440
457
  }
441
458
 
442
459
  async function printOracleHelp() {
460
+ printAssessmentHelp("oracle");
443
461
  console.log();
444
462
  console.log(
445
463
  "get-oracle-current-entitlements",
@@ -503,6 +521,10 @@ async function printOracleHelp() {
503
521
  }
504
522
 
505
523
  export {
524
+ getOracleAssessmentSummary,
525
+ getOracleAssessmentEntitlements,
526
+ getOracleAssessmentLicenseUsageSummary,
527
+ getOracleAssessmentDeploymentDetails,
506
528
  getOracleCurrentEntitlements,
507
529
  listOracleMetrics,
508
530
  listOracleLimitations,
@@ -22,6 +22,9 @@ import {
22
22
  listMssqlAssessments,
23
23
  getMssqlAssessment,
24
24
  getMssqlAssessmentEntitlements,
25
+ getMssqlAssessmentSummary,
26
+ getMssqlAssessmentLicenseUsageSummary,
27
+ getMssqlAssessmentDeploymentDetails,
25
28
  getMssqlAssessmentLicenseUsageMaps,
26
29
  getMssqlAssessmentResources,
27
30
  checkMssqlConfigMetadata,
@@ -40,6 +43,10 @@ import {
40
43
  // Oracle entitlement read-only functions
41
44
  import {
42
45
  printOracleHelp,
46
+ getOracleAssessmentSummary,
47
+ getOracleAssessmentEntitlements,
48
+ getOracleAssessmentLicenseUsageSummary,
49
+ getOracleAssessmentDeploymentDetails,
43
50
  getOracleCurrentEntitlements,
44
51
  listOracleMetrics,
45
52
  listOracleLimitations,
@@ -1164,6 +1171,26 @@ async function printHelp() {
1164
1171
  }
1165
1172
 
1166
1173
  const licenseManagerModule = (action, ...args) => {
1174
+ // WHY: Legacy standard-argument parsing consumes scope flags before validation.
1175
+ // Assessment reads must reject malformed explicit scope rather than use defaults.
1176
+ switch (action?.toLowerCase()) {
1177
+ case "get-oracle-assessment-summary":
1178
+ return getOracleAssessmentSummary(args);
1179
+ case "get-oracle-assessment-entitlements":
1180
+ return getOracleAssessmentEntitlements(args);
1181
+ case "get-oracle-assessment-license-usage-summary":
1182
+ return getOracleAssessmentLicenseUsageSummary(args);
1183
+ case "get-oracle-assessment-deployment-details":
1184
+ return getOracleAssessmentDeploymentDetails(args);
1185
+ case "get-mssql-assessment-summary":
1186
+ return getMssqlAssessmentSummary(args);
1187
+ case "get-mssql-assessment-entitlements":
1188
+ return getMssqlAssessmentEntitlements(args);
1189
+ case "get-mssql-assessment-license-usage-summary":
1190
+ return getMssqlAssessmentLicenseUsageSummary(args);
1191
+ case "get-mssql-assessment-deployment-details":
1192
+ return getMssqlAssessmentDeploymentDetails(args);
1193
+ }
1167
1194
  if (utils.processStandardArgs(args) === false) return;
1168
1195
  switch (action?.toLowerCase() ?? "") {
1169
1196
  case "create-oracle-shared-credential":
@@ -1194,8 +1221,6 @@ const licenseManagerModule = (action, ...args) => {
1194
1221
  return listMssqlAssessments(args);
1195
1222
  case "get-mssql-assessment":
1196
1223
  return getMssqlAssessment(args);
1197
- case "get-mssql-assessment-entitlements":
1198
- return getMssqlAssessmentEntitlements(args);
1199
1224
  case "get-mssql-assessment-license-usage-maps":
1200
1225
  return getMssqlAssessmentLicenseUsageMaps(args);
1201
1226
  case "get-mssql-assessment-resources":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opscompass/opscompass-cli",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "Calls OpsCompass's APIs",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@opscompass/opscompass-api": "^1.3.7",
32
- "adm-zip": "^0.6.0",
32
+ "adm-zip": "^0.6.1",
33
33
  "axios": "^1.18.1",
34
34
  "better-sqlite3": "12.11.1",
35
35
  "fs-extra": "^10.1.0",