@opscompass/opscompass-cli 1.3.7 → 1.3.9
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 +90 -0
- package/lib/aiChatDocuments.js +90 -0
- package/lib/aiChatRuntime.js +51 -0
- package/modules/license-manager/assessment.js +87 -0
- package/modules/license-manager/microsoft.js +101 -23
- package/modules/license-manager/oracle.js +22 -0
- package/modules/license-manager.js +29 -2
- package/package.json +11 -6
package/README.md
CHANGED
|
@@ -104,3 +104,93 @@ 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
|
+
## MSSQL current entitlements
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
opscompass license-manager get-mssql-current-entitlements --company your_company_slug --account your_account_or_cloud_subscription_id
|
|
112
|
+
opscompass license-manager get-mssql-current-entitlements --company your_company_slug --account your_account_or_cloud_subscription_id --limit 100 --offset 0
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
This read-only command returns a **company-scoped** JSON array, not an assessment snapshot or account-scoped inventory. The required account validates membership in the company only. `--company` and `--account` use saved defaults when omitted; `--account-id` and `--accountid` override the selected account. Accounts are nonblank strings (trimmed), preserving exact cloudSubscriptionId selectors and numeric strings without integer coercion.
|
|
116
|
+
|
|
117
|
+
Each group has `quantity`, sorted source `entitlement_ids`, and `mssqlProduct`, `mssqlEdition`, `mssqlVersion`, and `mssqlMetric` objects containing `id`, `displayName`, and `slug`. Groups are identified by the four component IDs. Quantities sum stored records regardless of purchase/support dates, with no termination adjustment; groups contain no record ID, dates, or support fields.
|
|
118
|
+
|
|
119
|
+
Optional `--limit` accepts integers 1–1000 and `--offset` accepts integers 0–10000. Omitted pagination is unbounded; there is no implicit 100-row default. Pagination applies after grouping, ordered by product display name then the four component IDs. The CLI returns one API response without automatic pagination or assessment fallback. This is separate from the unchanged raw `get-mssql-entitlements` command.
|
|
120
|
+
|
|
121
|
+
Unknown `--` flags, invalid argument values, or missing company/account scope produce an error on stderr, leave stdout empty, and exit with status 1 before making an API request.
|
|
122
|
+
Failed current-entitlement requests also report the error on stderr, leave stdout empty, and exit with status 1.
|
|
123
|
+
|
|
124
|
+
## Persisted Oracle and MSSQL assessments
|
|
125
|
+
|
|
126
|
+
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.
|
|
127
|
+
|
|
128
|
+
| UI tab | Oracle command | MSSQL command | JSON section |
|
|
129
|
+
| --- | --- | --- | --- |
|
|
130
|
+
| Compliance | `get-oracle-assessment-summary` | `get-mssql-assessment-summary` | `assessmentSummary` |
|
|
131
|
+
| Entitlements | `get-oracle-assessment-entitlements` | `get-mssql-assessment-entitlements` | `assessmentEntitlements` |
|
|
132
|
+
| License usage map | `get-oracle-assessment-license-usage-summary` | `get-mssql-assessment-license-usage-summary` | `licenseUsageSummary` |
|
|
133
|
+
| Deployment details | `get-oracle-assessment-deployment-details` | `get-mssql-assessment-deployment-details` | `deploymentDetails` |
|
|
134
|
+
|
|
135
|
+
Run each under `license-manager`, for example:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
opscompass license-manager get-oracle-assessment-summary --company acme --account 42 --limit 100 --offset 0
|
|
139
|
+
opscompass license-manager get-oracle-assessment-entitlements --company acme --account 42 --assessment-id 123 --limit 100 --offset 0
|
|
140
|
+
opscompass license-manager get-oracle-assessment-summary --company acme --account 42 --mlss-assessment-id 55
|
|
141
|
+
opscompass license-manager get-mssql-assessment-summary --company acme --account sql-account --limit 100 --offset 0
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- `--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.
|
|
145
|
+
- `--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.
|
|
146
|
+
- 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`.
|
|
147
|
+
- `--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.
|
|
148
|
+
- 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.
|
|
149
|
+
- 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.
|
|
150
|
+
|
|
151
|
+
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.
|
|
152
|
+
|
|
153
|
+
### Breaking release: assessment entitlements
|
|
154
|
+
|
|
155
|
+
`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.
|
|
156
|
+
|
|
157
|
+
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.
|
|
158
|
+
|
|
159
|
+
### Operator rollout order
|
|
160
|
+
|
|
161
|
+
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.
|
|
162
|
+
|
|
163
|
+
## AI Chat Documents host integration
|
|
164
|
+
|
|
165
|
+
The CLI pins the released npm package `@opscompass/harness-core@0.7.1`; a local harness checkout/link is no longer required. Fully restart Studio after adopting the published CLI so its main process loads the new runtime.
|
|
166
|
+
|
|
167
|
+
Only failure to find the top-level `@opscompass/harness-core` package becomes the friendly AI-chat-unavailable error. Missing transitive packages and internal harness modules retain their original loader errors, including when the importer path contains the harness package name.
|
|
168
|
+
|
|
169
|
+
The CLI supplies a trusted per-prompt run budget of **120 tool executions**, **5 identical calls**, and **10 minutes** to `createCliAiChatRuntime`; Studio inherits this through its selected CLI. These values do not alter Harness's library defaults or reset when a skill changes. Shared generic file and Bash calls count toward the same run ceiling; only tools with trusted skill ownership also consume that skill's allowance.
|
|
170
|
+
|
|
171
|
+
Trusted host code may explicitly pass `runBudget: { maxToolCalls, maxIdenticalCalls, maxDurationMs }` alongside `cliInvocation`. An explicit object completely replaces the CLI budget and is forwarded unchanged for Harness validation; omitted fields in that object use Harness's library defaults (20 executions, 5 identical calls, 10 minutes). Model output and renderer input must not supply this configuration. Both the CLI default and explicit budgets require `EXECUTION_POLICY_VERSION === 1`, and embedded invocation independently requires `supportsCliInvocation === true`; either missing capability fails before creating a conversation. No separate numeric Studio override is needed.
|
|
172
|
+
|
|
173
|
+
The CLI lockfile pins published Harness `0.7.1`, which includes public Skills `0.2.3` with shared Resources (60 calls) and Oracle Licensing (40 calls) limits. The bundle routes inventory-only requests to `resources list` and rejects oversized stdout from the shared CLI runner rather than returning clipped JSON; the bulk workflow's separate JSON runner is unchanged. It retains embedded invocation and warning-safe JSON, and bundles Sandbox `0.0.81` with unmodified upstream Forge `1.4.2`. Installation needs no customer patch script or additional registry credentials.
|
|
174
|
+
|
|
175
|
+
The production audit gate accepts only a valid, successful report with zero production vulnerabilities; no advisory exception remains. Regression tests exercise PEM Buffer handling, malformed-signature rejection, and Sandbox certificate/TLS behavior through the actual installed dependencies.
|
|
176
|
+
|
|
177
|
+
Studio can create the local Documents facade from the runtime harness:
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
import { createCliAiChatRuntime } from "./lib/aiChatRuntime.js";
|
|
181
|
+
import { createCliAiChatDocuments } from "./lib/aiChatDocuments.js";
|
|
182
|
+
|
|
183
|
+
const harness = await createCliAiChatRuntime({ workspaceRoot, onEvent });
|
|
184
|
+
const documents = createCliAiChatDocuments({ harness, onChanged });
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The facade provides `list(directory?)`, `mkdir(path)`, `importFile(sourcePath, destinationPath)`, `preview(path)`, `exportFile(path, destinationPath)`, `delete(path)`, and `dispose()`. Import takes the native-dialog absolute source path and a Documents-root-relative destination; export takes a Documents-root-relative source and the native save-dialog absolute destination. Renderer requests contain only relative document paths, with the host consumer supplying dialog paths in main. The host consumer owns the facade lifecycle: call `documents.dispose()` when replacing the runtime; it waits for local operations but does not dispose the harness.
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
The AI Chat adapter exports `supportsCliInvocation` and accepts optional host-owned
|
|
191
|
+
`cliInvocation: { executable, args, env }`. This lets a packaged desktop host run
|
|
192
|
+
its selected JavaScript CLI through its embedded runtime while preserving the
|
|
193
|
+
CLI command identity, defaults home and cancellation. An explicit environment is
|
|
194
|
+
complete, not an ambient overlay. The adapter rejects older Harness versions
|
|
195
|
+
that cannot honor the invocation; the matching public Skills bundle must support
|
|
196
|
+
it too. Standalone callers can omit the option.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const DOCUMENT_ERROR_MESSAGES = {
|
|
2
|
+
DOCUMENTS_INVALID_PATH: "Invalid Documents path.",
|
|
3
|
+
DOCUMENTS_NOT_FOUND: "The requested document was not found.",
|
|
4
|
+
DOCUMENTS_EXISTS: "A file or folder with that name already exists.",
|
|
5
|
+
DOCUMENTS_DIRECTORY_NOT_EMPTY: "The folder is not empty.",
|
|
6
|
+
DOCUMENTS_BUSY: "Documents are in use by another operation.",
|
|
7
|
+
DOCUMENTS_IO_ERROR: "Documents could not be accessed.",
|
|
8
|
+
DOCUMENTS_UNAVAILABLE: "Documents are unavailable in this runtime.",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function documentsError(code) {
|
|
12
|
+
const error = new Error(DOCUMENT_ERROR_MESSAGES[code]);
|
|
13
|
+
error.name = "DocumentsError";
|
|
14
|
+
error.code = code;
|
|
15
|
+
return error;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function normalizeError(error) {
|
|
19
|
+
const code = error?.code;
|
|
20
|
+
return documentsError(Object.hasOwn(DOCUMENT_ERROR_MESSAGES, code) ? code : "DOCUMENTS_IO_ERROR");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const HARNESS_METHODS = [
|
|
24
|
+
"listDocuments",
|
|
25
|
+
"createDocumentDirectory",
|
|
26
|
+
"importDocument",
|
|
27
|
+
"readDocument",
|
|
28
|
+
"exportDocument",
|
|
29
|
+
"deleteDocument",
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
export function createCliAiChatDocuments({ harness, onChanged } = {}) {
|
|
33
|
+
if (!harness || HARNESS_METHODS.some((method) => typeof harness[method] !== "function")) {
|
|
34
|
+
throw documentsError("DOCUMENTS_UNAVAILABLE");
|
|
35
|
+
}
|
|
36
|
+
if (onChanged !== undefined && typeof onChanged !== "function") {
|
|
37
|
+
throw new TypeError("onChanged must be a function.");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let closed = false;
|
|
41
|
+
let disposePromise;
|
|
42
|
+
const inFlight = new Set();
|
|
43
|
+
|
|
44
|
+
function invoke(method, args, changed = false) {
|
|
45
|
+
if (closed) return Promise.reject(documentsError("DOCUMENTS_UNAVAILABLE"));
|
|
46
|
+
|
|
47
|
+
const operation = Promise.resolve()
|
|
48
|
+
.then(() => harness[method](...args))
|
|
49
|
+
.catch((error) => {
|
|
50
|
+
throw normalizeError(error);
|
|
51
|
+
})
|
|
52
|
+
.then((result) => {
|
|
53
|
+
if (changed && !closed && onChanged) {
|
|
54
|
+
try {
|
|
55
|
+
const notification = onChanged();
|
|
56
|
+
if (notification && typeof notification.then === "function") {
|
|
57
|
+
void Promise.resolve(notification).catch(() => {});
|
|
58
|
+
}
|
|
59
|
+
} catch {
|
|
60
|
+
// Invalidation must not turn a completed local mutation into a failure.
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
inFlight.add(operation);
|
|
67
|
+
operation.then(
|
|
68
|
+
() => inFlight.delete(operation),
|
|
69
|
+
() => inFlight.delete(operation),
|
|
70
|
+
);
|
|
71
|
+
return operation;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
list: (directory) => invoke("listDocuments", [directory]),
|
|
76
|
+
mkdir: (path) => invoke("createDocumentDirectory", [path], true),
|
|
77
|
+
importFile: (sourcePath, destinationPath) =>
|
|
78
|
+
invoke("importDocument", [sourcePath, destinationPath], true),
|
|
79
|
+
preview: (path) => invoke("readDocument", [path]),
|
|
80
|
+
exportFile: (path, destinationPath) => invoke("exportDocument", [path, destinationPath]),
|
|
81
|
+
delete: (path) => invoke("deleteDocument", [path], true),
|
|
82
|
+
dispose() {
|
|
83
|
+
if (!disposePromise) {
|
|
84
|
+
closed = true;
|
|
85
|
+
disposePromise = Promise.allSettled([...inFlight]).then(() => undefined);
|
|
86
|
+
}
|
|
87
|
+
return disposePromise;
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { cliCommand, opscompassHome } from "../environment/current.js";
|
|
2
|
+
|
|
3
|
+
// DECISION: the selected CLI package owns this adapter so Studio uses the
|
|
4
|
+
// same CLI home, executable, and packaged harness runtime.
|
|
5
|
+
let harnessCoreLoader = () => import("@opscompass/harness-core");
|
|
6
|
+
|
|
7
|
+
export function __setHarnessCoreLoaderForTesting(loader) {
|
|
8
|
+
harnessCoreLoader = loader;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const supportsCliInvocation = true;
|
|
12
|
+
|
|
13
|
+
// DECISION: The CLI owns the approved run ceiling; Harness library defaults stay compatible.
|
|
14
|
+
/**
|
|
15
|
+
* @param {{workspaceRoot: string, onEvent: Function, cliEntryPoint?: string,
|
|
16
|
+
* cliInvocation?: import('@opscompass/harness-core').CliInvocation,
|
|
17
|
+
* runBudget?: import('@opscompass/harness-core').RunBudgetOptions}} options
|
|
18
|
+
*/
|
|
19
|
+
export async function createCliAiChatRuntime({ workspaceRoot, onEvent, cliEntryPoint = cliCommand, cliInvocation,
|
|
20
|
+
runBudget = { maxToolCalls: 120, maxIdenticalCalls: 5, maxDurationMs: 600_000 } }) {
|
|
21
|
+
let core;
|
|
22
|
+
try {
|
|
23
|
+
core = await harnessCoreLoader();
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (
|
|
26
|
+
error &&
|
|
27
|
+
error.code === "ERR_MODULE_NOT_FOUND" &&
|
|
28
|
+
/^Cannot find package '@opscompass\/harness-core' imported from /.test(error.message)
|
|
29
|
+
) {
|
|
30
|
+
throw new Error("Opscompass AI chat is unavailable because the harness dependency could not be loaded.");
|
|
31
|
+
}
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
if (cliInvocation && core.supportsCliInvocation !== true) {
|
|
35
|
+
throw new Error("Packaged AI chat requires an updated Harness with CLI invocation support.");
|
|
36
|
+
}
|
|
37
|
+
if (core.EXECUTION_POLICY_VERSION !== 1) {
|
|
38
|
+
throw new Error("This AI chat runtime does not support execution budgets. Install a compatible CLI/Harness release.");
|
|
39
|
+
}
|
|
40
|
+
const harnessOptions = {
|
|
41
|
+
workspaceRoot,
|
|
42
|
+
opscompassHome,
|
|
43
|
+
cliExecutable: cliCommand,
|
|
44
|
+
onEvent,
|
|
45
|
+
cliEntryPoint,
|
|
46
|
+
modelAccessSource: "customer",
|
|
47
|
+
...(cliInvocation ? { cliInvocation } : {}),
|
|
48
|
+
runBudget,
|
|
49
|
+
};
|
|
50
|
+
return core.createOpscompassHarness(harnessOptions);
|
|
51
|
+
}
|
|
@@ -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";
|
|
@@ -151,6 +152,77 @@ async function getMssqlEntitlements(args) {
|
|
|
151
152
|
console.log(JSON.stringify(mssqlEntitlements, null, 2));
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
async function getMssqlCurrentEntitlements(args) {
|
|
156
|
+
let companySlug = global.company;
|
|
157
|
+
let accountId = global.account;
|
|
158
|
+
let accountAlias;
|
|
159
|
+
const options = {};
|
|
160
|
+
for (let i = 0; i < args.length; i++) {
|
|
161
|
+
const flag = args[i].toLowerCase();
|
|
162
|
+
if (!["--company", "--account", "--account-id", "--accountid", "--limit", "--offset"].includes(flag)) {
|
|
163
|
+
if (flag.startsWith("--")) {
|
|
164
|
+
console.error(`ERROR: Unknown flag ${args[i]}.`);
|
|
165
|
+
process.exitCode = 1;
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (args[i + 1] === undefined || args[i + 1].startsWith("--")) {
|
|
171
|
+
console.error(`ERROR: ${flag} requires a value.`);
|
|
172
|
+
process.exitCode = 1;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const value = args[++i];
|
|
176
|
+
switch (flag) {
|
|
177
|
+
case "--company":
|
|
178
|
+
companySlug = value;
|
|
179
|
+
break;
|
|
180
|
+
case "--account":
|
|
181
|
+
accountId = value;
|
|
182
|
+
break;
|
|
183
|
+
case "--account-id":
|
|
184
|
+
case "--accountid":
|
|
185
|
+
accountAlias = value;
|
|
186
|
+
break;
|
|
187
|
+
default: {
|
|
188
|
+
const name = flag.slice(2);
|
|
189
|
+
const minimum = name === "limit" ? 1 : 0;
|
|
190
|
+
const maximum = name === "limit" ? 1000 : 10000;
|
|
191
|
+
const number = Number(value);
|
|
192
|
+
if (!/^\d+$/.test(value) || !Number.isSafeInteger(number) || number < minimum || number > maximum) {
|
|
193
|
+
console.error(`ERROR: ${flag} must be an integer from ${minimum} through ${maximum} (got "${value}").`);
|
|
194
|
+
process.exitCode = 1;
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
options[name] = number;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const selectedAccount = String(accountAlias ?? accountId ?? "").trim();
|
|
202
|
+
if (!selectedAccount) {
|
|
203
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
204
|
+
process.exitCode = 1;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (companySlug === undefined || companySlug === null || String(companySlug).trim() === "") {
|
|
208
|
+
console.error("ERROR: --company is required (or set a default company).");
|
|
209
|
+
process.exitCode = 1;
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
const client = await getOpsCompassClient();
|
|
214
|
+
const result = await client.licenseManager.mssql.getMssqlCurrentEntitlements(
|
|
215
|
+
companySlug,
|
|
216
|
+
selectedAccount,
|
|
217
|
+
Object.keys(options).length ? options : undefined,
|
|
218
|
+
);
|
|
219
|
+
console.log(JSON.stringify(result, null, 2));
|
|
220
|
+
} catch (error) {
|
|
221
|
+
process.exitCode = 1;
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
154
226
|
async function getMssqlEntitlementComponents(args) {
|
|
155
227
|
const client = await getOpsCompassClient();
|
|
156
228
|
const entitlementComponents =
|
|
@@ -189,24 +261,19 @@ async function getMssqlAssessment(args) {
|
|
|
189
261
|
}
|
|
190
262
|
|
|
191
263
|
async function getMssqlAssessmentEntitlements(args) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
switch (args[i].toLowerCase()) {
|
|
195
|
-
case "--assessmentId":
|
|
196
|
-
case "--id":
|
|
197
|
-
case "--assessmentid":
|
|
198
|
-
assessmentId = args[++i];
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
264
|
+
return readAssessmentSection(args, "getMssqlAssessmentEntitlements");
|
|
265
|
+
}
|
|
202
266
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
assessmentId,
|
|
207
|
-
);
|
|
267
|
+
async function getMssqlAssessmentSummary(args) {
|
|
268
|
+
return readAssessmentSection(args, "getMssqlAssessmentSummary");
|
|
269
|
+
}
|
|
208
270
|
|
|
209
|
-
|
|
271
|
+
async function getMssqlAssessmentLicenseUsageSummary(args) {
|
|
272
|
+
return readAssessmentSection(args, "getMssqlAssessmentLicenseUsageSummary");
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async function getMssqlAssessmentDeploymentDetails(args) {
|
|
276
|
+
return readAssessmentSection(args, "getMssqlAssessmentDeploymentDetails");
|
|
210
277
|
}
|
|
211
278
|
|
|
212
279
|
async function getMssqlAssessmentLicenseUsageMaps(args) {
|
|
@@ -616,6 +683,16 @@ async function updateMssqlConfigurations(args) {
|
|
|
616
683
|
}
|
|
617
684
|
|
|
618
685
|
async function printMssqlHelp() {
|
|
686
|
+
console.log("get-mssql-current-entitlements", "Read COMPANY-SCOPED current entitlement rollups; account only validates company membership.");
|
|
687
|
+
console.log("Parameters:");
|
|
688
|
+
console.log(`--company [company_slug] (default: ${global.company})`);
|
|
689
|
+
console.log("--account [account-id-or-cloudSubscriptionId] (defaults to current account; required if unset)");
|
|
690
|
+
console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (aliases override account)");
|
|
691
|
+
console.log("--limit [integer 1..1000] --offset [integer 0..10000] (optional; omitted pagination is unbounded)");
|
|
692
|
+
console.log("Returns a JSON array grouped by product, edition, version and metric, with summed quantity and sorted entitlement_ids.");
|
|
693
|
+
console.log("Stored quantities are summed regardless of purchase/support dates; no termination adjustment, dates/support fields, or assessment snapshot.");
|
|
694
|
+
console.log();
|
|
695
|
+
printAssessmentHelp("mssql");
|
|
619
696
|
console.log(
|
|
620
697
|
"create-mssql-shared-credential",
|
|
621
698
|
"Creates MS SQL shared credentials",
|
|
@@ -833,13 +910,6 @@ async function printMssqlHelp() {
|
|
|
833
910
|
console.log("Parameters:");
|
|
834
911
|
console.log("--assessmentId [number] The id of the assessment to retrieve.");
|
|
835
912
|
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
913
|
console.log(
|
|
844
914
|
"(DEPRECATED) get-mssql-assessment-license-usage-maps",
|
|
845
915
|
"Gets LicenseUsageMaps for an MSSQL Assessment",
|
|
@@ -873,10 +943,14 @@ export {
|
|
|
873
943
|
createMssqlEntitlement,
|
|
874
944
|
updateMssqlEntitlement,
|
|
875
945
|
getMssqlEntitlements,
|
|
946
|
+
getMssqlCurrentEntitlements,
|
|
876
947
|
getMssqlEntitlementComponents,
|
|
877
948
|
listMssqlAssessments,
|
|
878
949
|
getMssqlAssessment,
|
|
879
950
|
getMssqlAssessmentEntitlements,
|
|
951
|
+
getMssqlAssessmentSummary,
|
|
952
|
+
getMssqlAssessmentLicenseUsageSummary,
|
|
953
|
+
getMssqlAssessmentDeploymentDetails,
|
|
880
954
|
getMssqlAssessmentLicenseUsageMaps,
|
|
881
955
|
getMssqlAssessmentResources,
|
|
882
956
|
checkMssqlConfigMetadata,
|
|
@@ -900,10 +974,14 @@ const licenseManagerMssqlModule = {
|
|
|
900
974
|
createMssqlEntitlement,
|
|
901
975
|
updateMssqlEntitlement,
|
|
902
976
|
getMssqlEntitlements,
|
|
977
|
+
getMssqlCurrentEntitlements,
|
|
903
978
|
getMssqlEntitlementComponents,
|
|
904
979
|
listMssqlAssessments,
|
|
905
980
|
getMssqlAssessment,
|
|
906
981
|
getMssqlAssessmentEntitlements,
|
|
982
|
+
getMssqlAssessmentSummary,
|
|
983
|
+
getMssqlAssessmentLicenseUsageSummary,
|
|
984
|
+
getMssqlAssessmentDeploymentDetails,
|
|
907
985
|
getMssqlAssessmentLicenseUsageMaps,
|
|
908
986
|
getMssqlAssessmentResources,
|
|
909
987
|
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,
|
|
@@ -18,10 +18,14 @@ import {
|
|
|
18
18
|
createMssqlEntitlement,
|
|
19
19
|
updateMssqlEntitlement,
|
|
20
20
|
getMssqlEntitlements,
|
|
21
|
+
getMssqlCurrentEntitlements,
|
|
21
22
|
getMssqlEntitlementComponents,
|
|
22
23
|
listMssqlAssessments,
|
|
23
24
|
getMssqlAssessment,
|
|
24
25
|
getMssqlAssessmentEntitlements,
|
|
26
|
+
getMssqlAssessmentSummary,
|
|
27
|
+
getMssqlAssessmentLicenseUsageSummary,
|
|
28
|
+
getMssqlAssessmentDeploymentDetails,
|
|
25
29
|
getMssqlAssessmentLicenseUsageMaps,
|
|
26
30
|
getMssqlAssessmentResources,
|
|
27
31
|
checkMssqlConfigMetadata,
|
|
@@ -40,6 +44,10 @@ import {
|
|
|
40
44
|
// Oracle entitlement read-only functions
|
|
41
45
|
import {
|
|
42
46
|
printOracleHelp,
|
|
47
|
+
getOracleAssessmentSummary,
|
|
48
|
+
getOracleAssessmentEntitlements,
|
|
49
|
+
getOracleAssessmentLicenseUsageSummary,
|
|
50
|
+
getOracleAssessmentDeploymentDetails,
|
|
43
51
|
getOracleCurrentEntitlements,
|
|
44
52
|
listOracleMetrics,
|
|
45
53
|
listOracleLimitations,
|
|
@@ -1164,6 +1172,27 @@ async function printHelp() {
|
|
|
1164
1172
|
}
|
|
1165
1173
|
|
|
1166
1174
|
const licenseManagerModule = (action, ...args) => {
|
|
1175
|
+
// Read commands with explicit scope validation bypass legacy argument consumption.
|
|
1176
|
+
switch (action?.toLowerCase()) {
|
|
1177
|
+
case "get-mssql-current-entitlements":
|
|
1178
|
+
return getMssqlCurrentEntitlements(args);
|
|
1179
|
+
case "get-oracle-assessment-summary":
|
|
1180
|
+
return getOracleAssessmentSummary(args);
|
|
1181
|
+
case "get-oracle-assessment-entitlements":
|
|
1182
|
+
return getOracleAssessmentEntitlements(args);
|
|
1183
|
+
case "get-oracle-assessment-license-usage-summary":
|
|
1184
|
+
return getOracleAssessmentLicenseUsageSummary(args);
|
|
1185
|
+
case "get-oracle-assessment-deployment-details":
|
|
1186
|
+
return getOracleAssessmentDeploymentDetails(args);
|
|
1187
|
+
case "get-mssql-assessment-summary":
|
|
1188
|
+
return getMssqlAssessmentSummary(args);
|
|
1189
|
+
case "get-mssql-assessment-entitlements":
|
|
1190
|
+
return getMssqlAssessmentEntitlements(args);
|
|
1191
|
+
case "get-mssql-assessment-license-usage-summary":
|
|
1192
|
+
return getMssqlAssessmentLicenseUsageSummary(args);
|
|
1193
|
+
case "get-mssql-assessment-deployment-details":
|
|
1194
|
+
return getMssqlAssessmentDeploymentDetails(args);
|
|
1195
|
+
}
|
|
1167
1196
|
if (utils.processStandardArgs(args) === false) return;
|
|
1168
1197
|
switch (action?.toLowerCase() ?? "") {
|
|
1169
1198
|
case "create-oracle-shared-credential":
|
|
@@ -1194,8 +1223,6 @@ const licenseManagerModule = (action, ...args) => {
|
|
|
1194
1223
|
return listMssqlAssessments(args);
|
|
1195
1224
|
case "get-mssql-assessment":
|
|
1196
1225
|
return getMssqlAssessment(args);
|
|
1197
|
-
case "get-mssql-assessment-entitlements":
|
|
1198
|
-
return getMssqlAssessmentEntitlements(args);
|
|
1199
1226
|
case "get-mssql-assessment-license-usage-maps":
|
|
1200
1227
|
return getMssqlAssessmentLicenseUsageMaps(args);
|
|
1201
1228
|
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.
|
|
3
|
+
"version": "1.3.9",
|
|
4
4
|
"description": "Calls OpsCompass's APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
"node": "^22.19.0 || ^24.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@opscompass/
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
31
|
+
"@opscompass/harness-core": "0.7.1",
|
|
32
|
+
"@opscompass/opscompass-api": "^1.3.8",
|
|
33
|
+
"adm-zip": "^0.6.1",
|
|
34
|
+
"axios": "^1.20.0",
|
|
35
|
+
"better-sqlite3": "^13.0.1",
|
|
35
36
|
"fs-extra": "^10.1.0",
|
|
36
37
|
"https-proxy-agent": "^5.0.1",
|
|
37
38
|
"open": "^8.2.1",
|
|
@@ -44,7 +45,6 @@
|
|
|
44
45
|
},
|
|
45
46
|
"overrides": {
|
|
46
47
|
"minimatch": "^10.2.3",
|
|
47
|
-
"brace-expansion": "^2.0.2",
|
|
48
48
|
"tar-fs": "^2.1.4"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
@@ -65,5 +65,10 @@
|
|
|
65
65
|
],
|
|
66
66
|
"bin": {
|
|
67
67
|
"opscompass": "index.js"
|
|
68
|
+
},
|
|
69
|
+
"allowScripts": {
|
|
70
|
+
"better-sqlite3": true,
|
|
71
|
+
"fsevents": true,
|
|
72
|
+
"unrs-resolver": true
|
|
68
73
|
}
|
|
69
74
|
}
|