@oneuptime/cli 14.0.55 → 14.0.57
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @oneuptime/cli
|
|
2
2
|
|
|
3
|
-
Command-line interface for managing OneUptime resources. Supports
|
|
3
|
+
Command-line interface for managing OneUptime resources. Supports every MCP-enabled resource (records with full CRUD operations, telemetry with list, create and count), named contexts for multiple environments, and flexible output formats.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -87,7 +87,7 @@ oneuptime context delete old-context
|
|
|
87
87
|
|
|
88
88
|
### Resource Operations
|
|
89
89
|
|
|
90
|
-
Every
|
|
90
|
+
Every resource supports `list`, `create` and `count`. Records (monitors, incidents, teams and the like) also support `get`, `update` and `delete`; telemetry (logs, metrics, spans and the like) does not:
|
|
91
91
|
|
|
92
92
|
| Subcommand | Description |
|
|
93
93
|
| -------------------------------------- | -------------------------------------------- |
|
|
@@ -191,19 +191,30 @@ Output format and list size are not read from this file. Pass `-o` and `--limit`
|
|
|
191
191
|
|
|
192
192
|
## Supported Resources
|
|
193
193
|
|
|
194
|
-
|
|
194
|
+
Every resource is a command: `oneuptime <resource> <subcommand>`. Resources are discovered from the OneUptime models that have MCP enabled, and `oneuptime resources` lists the ones your version has (`--type database` for records, `--type analytics` for telemetry).
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
- **Alert** - Manage alerts
|
|
198
|
-
- **Monitor** - Manage monitors
|
|
199
|
-
- **Monitor Status** - Manage monitor statuses
|
|
200
|
-
- **Incident State** - Manage incident states
|
|
201
|
-
- **Status Page** - Manage status pages
|
|
202
|
-
- **On-Call Policy** - Manage on-call duty policies
|
|
203
|
-
- **Team** - Manage teams
|
|
204
|
-
- **Scheduled Maintenance Event** - Manage scheduled maintenance
|
|
196
|
+
Records take `list`, `get`, `create`, `update`, `delete` and `count`:
|
|
205
197
|
|
|
206
|
-
|
|
198
|
+
| Area | Commands |
|
|
199
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
200
|
+
| Monitoring | `monitor`, `monitor-status`, `monitor-status-event` |
|
|
201
|
+
| Incidents | `incident`, `incident-state`, `incident-severity`, `incident-state-timeline`, `incident-public-note`, `incident-internal-note`, `incident-alert` |
|
|
202
|
+
| Alerts | `alert`, `alert-state`, `alert-severity`, `alert-state-timeline`, `alert-internal-note` |
|
|
203
|
+
| Status pages | `status-page`, `status-page-announcement` |
|
|
204
|
+
| Scheduled maintenance | `scheduled-maintenance-event`, `scheduled-maintenance-state`, `scheduled-maintenance-state-timeline` |
|
|
205
|
+
| Teams and on-call | `team`, `on-call-policy` |
|
|
206
|
+
| Security | `security-case`, `security-case-note`, `security-detection`, `security-playbook` |
|
|
207
|
+
| Labels | `label` |
|
|
208
|
+
|
|
209
|
+
Telemetry takes `list`, `create` and `count`:
|
|
210
|
+
|
|
211
|
+
| Area | Commands |
|
|
212
|
+
| ---------------- | ------------------------------------------------------------ |
|
|
213
|
+
| Observability | `log`, `metric`, `span`, `exception-instance`, `monitor-log` |
|
|
214
|
+
| Security | `security-event`, `threat-intel-indicator` |
|
|
215
|
+
| Changes and cost | `change-event`, `kubernetes-cost-allocation` |
|
|
216
|
+
|
|
217
|
+
As more models are MCP-enabled in OneUptime, they become available in the CLI as well. The [command reference](https://oneuptime.com/docs/cli/command-reference) describes every command and its options.
|
|
207
218
|
|
|
208
219
|
## Development
|
|
209
220
|
|
|
@@ -13,8 +13,14 @@ var ExitCode;
|
|
|
13
13
|
function handleError(error) {
|
|
14
14
|
if (error instanceof Error) {
|
|
15
15
|
const message = error.message;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/*
|
|
17
|
+
* Auth-related errors. The API key is matched in any case: OneUptime
|
|
18
|
+
* refuses a key with "Invalid API Key" and a request without one with
|
|
19
|
+
* "API Key not found in the request header", and a key below its plan
|
|
20
|
+
* with "API keys need the ... plan". Matched only as "API key", the first
|
|
21
|
+
* exited as a general error and the second as "Not found".
|
|
22
|
+
*/
|
|
23
|
+
if (message.toLowerCase().includes("api key") ||
|
|
18
24
|
message.includes("credentials") ||
|
|
19
25
|
message.includes("Unauthorized") ||
|
|
20
26
|
message.includes("401")) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorHandler.js","sourceRoot":"","sources":["../../../Core/ErrorHandler.ts"],"names":[],"mappings":";;;AASA,
|
|
1
|
+
{"version":3,"file":"ErrorHandler.js","sourceRoot":"","sources":["../../../Core/ErrorHandler.ts"],"names":[],"mappings":";;;AASA,kCAuCC;AAhDD,uDAA+C;AAE/C,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,6CAAW,CAAA;IACX,uDAAgB,CAAA;IAChB,iDAAa,CAAA;IACb,+CAAY,CAAA;AACd,CAAC,EALW,QAAQ,wBAAR,QAAQ,QAKnB;AAED,SAAgB,WAAW,CAAC,KAAc;IACxC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAW,KAAK,CAAC,OAAO,CAAC;QAEtC;;;;;;WAMG;QACH,IACE,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;YACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;YAC/B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;YAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EACvB,CAAC;YACD,IAAA,4BAAU,EAAC,yBAAyB,OAAO,EAAE,CAAC,CAAC;YAC/C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACnC,CAAC;QAED,6BAA6B;QAC7B,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC7D,IAAA,4BAAU,EAAC,cAAc,OAAO,EAAE,CAAC,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;QAED,qBAAqB;QACrB,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAClC,IAAA,4BAAU,EAAC,OAAO,CAAC,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACtC,CAAC;QAED,IAAA,4BAAU,EAAC,UAAU,OAAO,EAAE,CAAC,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,IAAA,4BAAU,EAAC,UAAU,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -7,6 +7,7 @@ exports.generateAllFieldsSelect = generateAllFieldsSelect;
|
|
|
7
7
|
const Index_1 = __importDefault(require("Common/Models/DatabaseModels/Index"));
|
|
8
8
|
const Index_2 = __importDefault(require("Common/Models/AnalyticsModels/Index"));
|
|
9
9
|
const TableColumn_1 = require("Common/Types/Database/TableColumn");
|
|
10
|
+
const HeldPermissions_1 = require("Common/Types/HeldPermissions");
|
|
10
11
|
const Permission_1 = __importDefault(require("Common/Types/Permission"));
|
|
11
12
|
function shouldIncludeField(columnName, accessControlForColumns) {
|
|
12
13
|
const accessControl = accessControlForColumns[columnName];
|
|
@@ -63,8 +64,7 @@ function generateAllFieldsSelect(tableName, modelType) {
|
|
|
63
64
|
if (!ModelClass) {
|
|
64
65
|
return getDefaultSelect();
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
return getDefaultSelect();
|
|
67
|
+
return getAnalyticsSelect(new ModelClass());
|
|
68
68
|
}
|
|
69
69
|
return getDefaultSelect();
|
|
70
70
|
}
|
|
@@ -72,6 +72,34 @@ function generateAllFieldsSelect(tableName, modelType) {
|
|
|
72
72
|
return getDefaultSelect();
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
/*
|
|
76
|
+
* The columns of a telemetry table that a list may ask for: those whose
|
|
77
|
+
* read rule names someone (as for database models, a rule of only
|
|
78
|
+
* CurrentUser names nobody a key can be), and, where a column declares no
|
|
79
|
+
* read rule, only the ones every select may name (ALWAYS_SELECTABLE_COLUMNS:
|
|
80
|
+
* the server reads a column with no rule as closed). Never the database
|
|
81
|
+
* default: telemetry tables have no updatedAt, and the analytics API refuses
|
|
82
|
+
* a select that names a column its table does not have, so every telemetry
|
|
83
|
+
* list failed with "Unknown column: updatedAt".
|
|
84
|
+
*/
|
|
85
|
+
function getAnalyticsSelect(model) {
|
|
86
|
+
var _a;
|
|
87
|
+
const selectObject = {};
|
|
88
|
+
for (const column of model.getTableColumns()) {
|
|
89
|
+
const read = (_a = column.accessControl) === null || _a === void 0 ? void 0 : _a.read;
|
|
90
|
+
const readable = read
|
|
91
|
+
? read.length > 0 &&
|
|
92
|
+
!(read.length === 1 && read[0] === Permission_1.default.CurrentUser)
|
|
93
|
+
: HeldPermissions_1.ALWAYS_SELECTABLE_COLUMNS.includes(column.key);
|
|
94
|
+
if (readable) {
|
|
95
|
+
selectObject[column.key] = true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (Object.keys(selectObject).length === 0) {
|
|
99
|
+
return { _id: true };
|
|
100
|
+
}
|
|
101
|
+
return selectObject;
|
|
102
|
+
}
|
|
75
103
|
function getDefaultSelect() {
|
|
76
104
|
return {
|
|
77
105
|
_id: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectFieldGenerator.js","sourceRoot":"","sources":["../../../Utils/SelectFieldGenerator.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"SelectFieldGenerator.js","sourceRoot":"","sources":["../../../Utils/SelectFieldGenerator.ts"],"names":[],"mappings":";;;;;AA+BA,0DA4EC;AA3GD,+EAAgE;AAChE,gFAAkE;AAGlE,mEAAoE;AACpE,kEAAyE;AACzE,yEAA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,QAAQ,GAAY,IAAI;YAC5B,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;gBACf,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,oBAAU,CAAC,WAAW,CAAC;YAC5D,CAAC,CAAC,2CAAyB,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAEnD,IAAI,QAAQ,EAAE,CAAC;YACb,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QAClC,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,gBAAgB;IACvB,OAAO;QACL,GAAG,EAAE,IAAI;QACT,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneuptime/cli",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.57",
|
|
4
4
|
"description": "OneUptime CLI - Command-line interface for managing OneUptime resources",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"chalk": "^4.1.2",
|
|
31
31
|
"cli-table3": "^0.6.5",
|
|
32
32
|
"commander": "^12.1.0",
|
|
33
|
-
"Common": "npm:@oneuptime/common@14.0.
|
|
33
|
+
"Common": "npm:@oneuptime/common@14.0.57",
|
|
34
34
|
"ts-node": "^10.9.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|