@observeone/cli 1.0.3 → 1.2.0
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 +51 -58
- package/dist/README.md +51 -58
- package/dist/commands/ai-check.d.ts.map +1 -1
- package/dist/commands/ai-check.js +35 -28
- package/dist/commands/ai-check.js.map +1 -1
- package/dist/commands/apply.d.ts.map +1 -1
- package/dist/commands/apply.js +30 -21
- package/dist/commands/apply.js.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +30 -225
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +3 -3
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/heartbeat.d.ts +1 -1
- package/dist/commands/heartbeat.d.ts.map +1 -1
- package/dist/commands/heartbeat.js +39 -234
- package/dist/commands/heartbeat.js.map +1 -1
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +68 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +10 -58
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/monitor.d.ts +1 -1
- package/dist/commands/monitor.d.ts.map +1 -1
- package/dist/commands/monitor.js +32 -235
- package/dist/commands/monitor.js.map +1 -1
- package/dist/commands/resource-command.factory.d.ts +31 -0
- package/dist/commands/resource-command.factory.d.ts.map +1 -0
- package/dist/commands/resource-command.factory.js +208 -0
- package/dist/commands/resource-command.factory.js.map +1 -0
- package/dist/commands/signup.d.ts +9 -0
- package/dist/commands/signup.d.ts.map +1 -0
- package/dist/commands/signup.js +54 -0
- package/dist/commands/signup.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/api-client.interface.d.ts +9 -6
- package/dist/interfaces/api-client.interface.d.ts.map +1 -1
- package/dist/interfaces/config.interface.d.ts +5 -10
- package/dist/interfaces/config.interface.d.ts.map +1 -1
- package/dist/interfaces/output.interface.d.ts +20 -3
- package/dist/interfaces/output.interface.d.ts.map +1 -1
- package/dist/interfaces/sse-client.interface.d.ts +3 -3
- package/dist/interfaces/sse-client.interface.d.ts.map +1 -1
- package/dist/package.json +1 -1
- package/dist/services/api-client.service.d.ts +7 -4
- package/dist/services/api-client.service.d.ts.map +1 -1
- package/dist/services/api-client.service.js +46 -20
- package/dist/services/api-client.service.js.map +1 -1
- package/dist/services/config.service.d.ts +7 -12
- package/dist/services/config.service.d.ts.map +1 -1
- package/dist/services/config.service.js +47 -18
- package/dist/services/config.service.js.map +1 -1
- package/dist/services/output.service.d.ts +20 -3
- package/dist/services/output.service.d.ts.map +1 -1
- package/dist/services/output.service.js +11 -10
- package/dist/services/output.service.js.map +1 -1
- package/dist/services/sse-client.service.d.ts +1 -1
- package/dist/services/sse-client.service.d.ts.map +1 -1
- package/dist/services/sse-client.service.js +2 -1
- package/dist/services/sse-client.service.js.map +1 -1
- package/dist/services/update.service.d.ts +13 -0
- package/dist/services/update.service.d.ts.map +1 -0
- package/dist/services/update.service.js +57 -0
- package/dist/services/update.service.js.map +1 -0
- package/dist/types/index.d.ts +37 -35
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/deep-equal.d.ts +2 -2
- package/dist/utils/deep-equal.d.ts.map +1 -1
- package/dist/utils/deep-equal.js +6 -4
- package/dist/utils/deep-equal.js.map +1 -1
- package/dist/utils/live-progress.d.ts +10 -1
- package/dist/utils/live-progress.d.ts.map +1 -1
- package/dist/utils/live-progress.js +5 -5
- package/dist/utils/live-progress.js.map +1 -1
- package/dist/utils/log-writer.d.ts +15 -2
- package/dist/utils/log-writer.d.ts.map +1 -1
- package/dist/utils/log-writer.js +1 -1
- package/dist/utils/log-writer.js.map +1 -1
- package/package.json +1 -1
package/dist/commands/login.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import inquirer from 'inquirer';
|
|
3
2
|
import chalk from 'chalk';
|
|
4
|
-
import { existsSync, writeFileSync } from 'fs';
|
|
5
3
|
import open from 'open';
|
|
6
4
|
/**
|
|
7
5
|
* Factory function to create login command with direct service injection
|
|
@@ -13,6 +11,7 @@ export function createLoginCommand(configService, apiClient, outputService) {
|
|
|
13
11
|
.option('--api-url <url>', 'Override API URL')
|
|
14
12
|
.option('--skip-setup', 'Skip project configuration setup')
|
|
15
13
|
.option('--headless', 'Authenticate headlessly using OBS_EMAIL and OBS_PASSWORD environment variables')
|
|
14
|
+
.option('--json', 'Output in JSON format')
|
|
16
15
|
.action(async (options) => {
|
|
17
16
|
try {
|
|
18
17
|
// Handle API URL override first, before other operations
|
|
@@ -33,7 +32,7 @@ export function createLoginCommand(configService, apiClient, outputService) {
|
|
|
33
32
|
configService.setApiKey(api_key);
|
|
34
33
|
configService.setApiUrl(configService.getApiUrl());
|
|
35
34
|
apiClient.setApiKey(api_key);
|
|
36
|
-
if (process.env.OBS_JSON_OUTPUT === 'true' || options.json) {
|
|
35
|
+
if (process.env.OBS_JSON_OUTPUT === 'true' || options.json === true) {
|
|
37
36
|
outputService.formatJsonOutput({ authenticated: true });
|
|
38
37
|
}
|
|
39
38
|
else {
|
|
@@ -45,7 +44,8 @@ export function createLoginCommand(configService, apiClient, outputService) {
|
|
|
45
44
|
process.exit(0);
|
|
46
45
|
}
|
|
47
46
|
catch (error) {
|
|
48
|
-
|
|
47
|
+
const err = error;
|
|
48
|
+
outputService.error(`Headless authentication failed: ${err.message || 'Unknown error'}`);
|
|
49
49
|
process.exit(1);
|
|
50
50
|
}
|
|
51
51
|
return;
|
|
@@ -55,15 +55,11 @@ export function createLoginCommand(configService, apiClient, outputService) {
|
|
|
55
55
|
configService.setApiKey(options.apiKey);
|
|
56
56
|
}
|
|
57
57
|
const apiKey = configService.getApiKey();
|
|
58
|
-
if (!apiKey) {
|
|
59
|
-
outputService.error('Not authenticated. Please run "obs login" first.');
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
58
|
// Check for API key in command option first (highest priority)
|
|
63
59
|
let apiKeyToUse = options.apiKey;
|
|
64
60
|
// If no explicit command option but global option was set, use that
|
|
65
61
|
if (!apiKeyToUse) {
|
|
66
|
-
apiKeyToUse =
|
|
62
|
+
apiKeyToUse = apiKey;
|
|
67
63
|
}
|
|
68
64
|
// If an API key is available (from either source), try to authenticate
|
|
69
65
|
if (apiKeyToUse) {
|
|
@@ -74,10 +70,7 @@ export function createLoginCommand(configService, apiClient, outputService) {
|
|
|
74
70
|
const isValid = await apiClient.validateToken();
|
|
75
71
|
if (isValid) {
|
|
76
72
|
outputService.success('Successfully authenticated with provided API key');
|
|
77
|
-
//
|
|
78
|
-
if (!options.skipSetup) {
|
|
79
|
-
await setupProjectConfig(configService, outputService);
|
|
80
|
-
}
|
|
73
|
+
// Project configuration setup is now separated to "obs init"
|
|
81
74
|
process.exit(0);
|
|
82
75
|
return;
|
|
83
76
|
}
|
|
@@ -102,7 +95,7 @@ export function createLoginCommand(configService, apiClient, outputService) {
|
|
|
102
95
|
try {
|
|
103
96
|
await open(auth_url);
|
|
104
97
|
}
|
|
105
|
-
catch (
|
|
98
|
+
catch (_error) {
|
|
106
99
|
// Ignore open errors, user can copy link
|
|
107
100
|
}
|
|
108
101
|
// Poll for status
|
|
@@ -117,8 +110,8 @@ export function createLoginCommand(configService, apiClient, outputService) {
|
|
|
117
110
|
configService.setApiUrl(configService.getApiUrl());
|
|
118
111
|
apiClient.setApiKey(status.api_key);
|
|
119
112
|
outputService.success('Successfully authenticated!');
|
|
120
|
-
//
|
|
121
|
-
|
|
113
|
+
// Project configuration setup is now separated to "obs init"
|
|
114
|
+
console.log(chalk.yellow('\n💡 Run "obs init" to create local project configuration!'));
|
|
122
115
|
console.log('');
|
|
123
116
|
console.log(chalk.bold('Next steps:'));
|
|
124
117
|
console.log(chalk.gray('1. Run "obs ai-check list" to see available tests'));
|
|
@@ -133,7 +126,7 @@ export function createLoginCommand(configService, apiClient, outputService) {
|
|
|
133
126
|
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
134
127
|
attempts++;
|
|
135
128
|
}
|
|
136
|
-
catch (
|
|
129
|
+
catch (_error) {
|
|
137
130
|
// If 404 or other error, might be expired or invalid
|
|
138
131
|
attempts++;
|
|
139
132
|
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
@@ -148,45 +141,4 @@ export function createLoginCommand(configService, apiClient, outputService) {
|
|
|
148
141
|
}
|
|
149
142
|
});
|
|
150
143
|
}
|
|
151
|
-
/**
|
|
152
|
-
* Helper function for project configuration setup
|
|
153
|
-
*/
|
|
154
|
-
async function setupProjectConfig(configService, outputService) {
|
|
155
|
-
const configPath = '.obs.config.json';
|
|
156
|
-
if (!existsSync(configPath)) {
|
|
157
|
-
console.log(chalk.bold('\n🚀 Setting up project configuration...'));
|
|
158
|
-
const projectAnswers = await inquirer.prompt([
|
|
159
|
-
{
|
|
160
|
-
type: 'input',
|
|
161
|
-
name: 'projectName',
|
|
162
|
-
message: 'Project name:',
|
|
163
|
-
default: process.cwd().split(/[/\\]/).pop() || 'My Project',
|
|
164
|
-
validate: (input) => (input.trim() ? true : 'Project name is required'),
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
type: 'input',
|
|
168
|
-
name: 'projectDescription',
|
|
169
|
-
message: 'Project description:',
|
|
170
|
-
default: 'AI-powered test automation project',
|
|
171
|
-
},
|
|
172
|
-
]);
|
|
173
|
-
const projectConfig = {
|
|
174
|
-
project: {
|
|
175
|
-
name: projectAnswers.projectName,
|
|
176
|
-
description: projectAnswers.projectDescription,
|
|
177
|
-
},
|
|
178
|
-
defaultOptions: {
|
|
179
|
-
timeout: 600000,
|
|
180
|
-
retries: 3,
|
|
181
|
-
verbose: false,
|
|
182
|
-
pollIntervalMs: 2000,
|
|
183
|
-
maxAttempts: 300,
|
|
184
|
-
},
|
|
185
|
-
};
|
|
186
|
-
writeFileSync(configPath, JSON.stringify(projectConfig, null, 2));
|
|
187
|
-
configService.setProjectConfig(projectConfig.project);
|
|
188
|
-
configService.setDefaultOptions(projectConfig.defaultOptions);
|
|
189
|
-
outputService.success('Project configuration created!');
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
144
|
//# sourceMappingURL=login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,aAA6B,EAC7B,SAAqB,EACrB,aAA6B;IAE7B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;SACxB,WAAW,CAAC,uCAAuC,CAAC;SACpD,MAAM,CAAC,qBAAqB,EAAE,mCAAmC,CAAC;SAClE,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC;SAC7C,MAAM,CAAC,cAAc,EAAE,kCAAkC,CAAC;SAC1D,MAAM,CACL,YAAY,EACZ,gFAAgF,CACjF;SACA,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC;SACzC,MAAM,CAAC,KAAK,EAAE,OAAgC,EAAE,EAAE;QACjD,IAAI,CAAC;YACH,yDAAyD;YACzD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnB,aAAa,CAAC,oBAAoB,CAAC,OAAO,CAAC,MAAgB,CAAC,CAAC;YAC/D,CAAC;YAED,kCAAkC;YAClC,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACrB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAA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YACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { IConfigService } from '../interfaces/config.interface.js';
|
|
|
3
3
|
import { IApiClient } from '../interfaces/api-client.interface.js';
|
|
4
4
|
import { IOutputService } from '../interfaces/output.interface.js';
|
|
5
5
|
/**
|
|
6
|
-
* Factory function to create monitor command
|
|
6
|
+
* Factory function to create monitor command using the generic resource factory
|
|
7
7
|
*/
|
|
8
8
|
export declare function createMonitorCommand(configService: IConfigService, apiClient: IApiClient, outputService: IOutputService): Command;
|
|
9
9
|
//# sourceMappingURL=monitor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../src/commands/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../src/commands/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAInE;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,cAAc,EAC7B,SAAS,EAAE,UAAU,EACrB,aAAa,EAAE,cAAc,GAC5B,OAAO,CAuFT"}
|
package/dist/commands/monitor.js
CHANGED
|
@@ -1,97 +1,29 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
1
|
import inquirer from 'inquirer';
|
|
2
|
+
import { createResourceCommand } from './resource-command.factory.js';
|
|
3
3
|
/**
|
|
4
|
-
* Factory function to create monitor command
|
|
4
|
+
* Factory function to create monitor command using the generic resource factory
|
|
5
5
|
*/
|
|
6
6
|
export function createMonitorCommand(configService, apiClient, outputService) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
outputService.formatMonitorList(monitors, process.env.OBS_VERBOSE === 'true');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
outputService.error(outputService.formatError(error));
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
// GET
|
|
38
|
-
monitor
|
|
39
|
-
.command('get <id>')
|
|
40
|
-
.description('Get details of a URL monitor')
|
|
41
|
-
.option('-j, --json', 'Output in JSON format')
|
|
42
|
-
.action(async (id, options) => {
|
|
43
|
-
if (process.env.OBS_JSON_OUTPUT === 'true' || options.json) {
|
|
44
|
-
outputService.enableJsonMode();
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
const apiKey = configService.getApiKey();
|
|
48
|
-
if (!apiKey) {
|
|
49
|
-
outputService.error('Not authenticated. Please run "obs login" first.');
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
const monitorId = parseInt(id);
|
|
53
|
-
if (isNaN(monitorId)) {
|
|
54
|
-
outputService.error('Invalid monitor ID.');
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
if (process.env.OBS_JSON_OUTPUT === 'true') {
|
|
58
|
-
outputService.enableJsonMode();
|
|
59
|
-
}
|
|
60
|
-
outputService.progress(`Fetching monitor ${monitorId}...`);
|
|
61
|
-
const monitorData = await apiClient.getUrlMonitor(monitorId);
|
|
62
|
-
if (process.env.OBS_JSON_OUTPUT === 'true') {
|
|
63
|
-
outputService.formatJsonOutput(monitorData);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
outputService.formatMonitorList([monitorData], true);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
outputService.error(outputService.formatError(error));
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
// CREATE
|
|
75
|
-
monitor
|
|
76
|
-
.command('create')
|
|
77
|
-
.description('Create a new URL monitor')
|
|
78
|
-
.option('-n, --name <name>', 'Monitor name')
|
|
79
|
-
.option('-u, --url <url>', 'URL to monitor')
|
|
80
|
-
.option('-i, --interval <cron>', "Cron expression for interval (e.g. '*/5 * * * *')")
|
|
81
|
-
.option('--no-alerts', 'Disable alerts on failure')
|
|
82
|
-
.option('-j, --json', 'Output in JSON format')
|
|
83
|
-
.action(async (options) => {
|
|
84
|
-
if (process.env.OBS_JSON_OUTPUT === 'true' || options.json) {
|
|
85
|
-
outputService.enableJsonMode();
|
|
86
|
-
}
|
|
87
|
-
try {
|
|
88
|
-
const apiKey = configService.getApiKey();
|
|
89
|
-
if (!apiKey) {
|
|
90
|
-
outputService.error('Not authenticated. Please run "obs login" first.');
|
|
91
|
-
process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
let { name, url, interval, alerts } = options;
|
|
94
|
-
// Interactive prompts if missing critical fields
|
|
7
|
+
return createResourceCommand(configService, apiClient, outputService, {
|
|
8
|
+
resourceName: 'monitor',
|
|
9
|
+
pluralName: 'URL monitors',
|
|
10
|
+
description: 'Manage URL monitors',
|
|
11
|
+
apiMethods: {
|
|
12
|
+
list: () => apiClient.getUrlMonitors(),
|
|
13
|
+
get: (id) => apiClient.getUrlMonitor(id),
|
|
14
|
+
create: (data) => apiClient.createUrlMonitor(data),
|
|
15
|
+
update: (id, data) => apiClient.updateUrlMonitor(id, data),
|
|
16
|
+
delete: (id) => apiClient.deleteUrlMonitor(id),
|
|
17
|
+
toggle: (id) => apiClient.toggleUrlMonitor(id),
|
|
18
|
+
},
|
|
19
|
+
formatters: {
|
|
20
|
+
list: (items, verbose) => outputService.formatMonitorList(items, verbose),
|
|
21
|
+
},
|
|
22
|
+
createPrompts: async (options) => {
|
|
23
|
+
let name = options.name;
|
|
24
|
+
let url = options.url;
|
|
25
|
+
let interval = options.interval;
|
|
26
|
+
const alerts = options.alerts;
|
|
95
27
|
if (!name || !url) {
|
|
96
28
|
const answers = await inquirer.prompt([
|
|
97
29
|
{
|
|
@@ -128,165 +60,30 @@ export function createMonitorCommand(configService, apiClient, outputService) {
|
|
|
128
60
|
url = url || answers.url;
|
|
129
61
|
interval = interval || answers.interval;
|
|
130
62
|
}
|
|
131
|
-
|
|
132
|
-
const newMonitor = await apiClient.createUrlMonitor({
|
|
63
|
+
return {
|
|
133
64
|
name,
|
|
134
65
|
url,
|
|
135
66
|
cron_expression: interval || '*/5 * * * *',
|
|
136
67
|
alert_on_failure: alerts !== false,
|
|
137
68
|
timeout_ms: 30000,
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
outputService.error(outputService.formatError(error));
|
|
148
|
-
process.exit(1);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
// DELETE
|
|
152
|
-
monitor
|
|
153
|
-
.command('delete <id>')
|
|
154
|
-
.description('Delete a URL monitor')
|
|
155
|
-
.option('-y, --yes', 'Skip confirmation prompt')
|
|
156
|
-
.option('-j, --json', 'Output in JSON format')
|
|
157
|
-
.action(async (id, options) => {
|
|
158
|
-
if (process.env.OBS_JSON_OUTPUT === 'true' || options.json) {
|
|
159
|
-
outputService.enableJsonMode();
|
|
160
|
-
}
|
|
161
|
-
try {
|
|
162
|
-
const apiKey = configService.getApiKey();
|
|
163
|
-
if (!apiKey) {
|
|
164
|
-
outputService.error('Not authenticated. Please run "obs login" first.');
|
|
165
|
-
process.exit(1);
|
|
166
|
-
}
|
|
167
|
-
const monitorId = parseInt(id);
|
|
168
|
-
if (isNaN(monitorId)) {
|
|
169
|
-
outputService.error('Invalid monitor ID.');
|
|
170
|
-
process.exit(1);
|
|
171
|
-
}
|
|
172
|
-
if (!options.yes) {
|
|
173
|
-
const { confirm } = await inquirer.prompt([
|
|
174
|
-
{
|
|
175
|
-
type: 'confirm',
|
|
176
|
-
name: 'confirm',
|
|
177
|
-
message: `Are you sure you want to delete monitor ${monitorId}?`,
|
|
178
|
-
default: false,
|
|
179
|
-
},
|
|
180
|
-
]);
|
|
181
|
-
if (!confirm) {
|
|
182
|
-
outputService.info('Deletion cancelled.');
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
outputService.progress(`Deleting monitor ${monitorId}...`);
|
|
187
|
-
await apiClient.deleteUrlMonitor(monitorId);
|
|
188
|
-
if (process.env.OBS_JSON_OUTPUT === 'true') {
|
|
189
|
-
outputService.formatJsonOutput({ success: true, id: monitorId });
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
outputService.success(`Monitor ${monitorId} deleted successfully.`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
catch (error) {
|
|
196
|
-
outputService.error(outputService.formatError(error));
|
|
197
|
-
process.exit(1);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
// UPDATE
|
|
201
|
-
monitor
|
|
202
|
-
.command('update <id>')
|
|
203
|
-
.description('Update a URL monitor')
|
|
204
|
-
.option('-n, --name <name>', 'New monitor name')
|
|
205
|
-
.option('-u, --url <url>', 'New URL')
|
|
206
|
-
.option('-i, --interval <cron>', 'New cron interval')
|
|
207
|
-
.option('-j, --json', 'Output in JSON format')
|
|
208
|
-
.action(async (id, options) => {
|
|
209
|
-
if (process.env.OBS_JSON_OUTPUT === 'true' || options.json) {
|
|
210
|
-
outputService.enableJsonMode();
|
|
211
|
-
}
|
|
212
|
-
try {
|
|
213
|
-
const apiKey = configService.getApiKey();
|
|
214
|
-
if (!apiKey) {
|
|
215
|
-
outputService.error('Not authenticated. Please run "obs login" first.');
|
|
216
|
-
process.exit(1);
|
|
217
|
-
}
|
|
218
|
-
const monitorId = parseInt(id);
|
|
219
|
-
if (isNaN(monitorId)) {
|
|
220
|
-
outputService.error('Invalid monitor ID.');
|
|
221
|
-
process.exit(1);
|
|
222
|
-
}
|
|
223
|
-
const { name, url, interval } = options;
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
updatePrompts: async (id, options, existing) => {
|
|
72
|
+
const name = options.name;
|
|
73
|
+
const url = options.url;
|
|
74
|
+
const interval = options.interval;
|
|
224
75
|
if (!name && !url && !interval) {
|
|
225
76
|
outputService.error('Please provide at least one field to update (--name, --url, or --interval).');
|
|
226
77
|
process.exit(1);
|
|
227
78
|
}
|
|
228
|
-
|
|
229
|
-
const existing = await apiClient.getUrlMonitor(monitorId);
|
|
230
|
-
const payload = {
|
|
79
|
+
return {
|
|
231
80
|
name: name || existing.name,
|
|
232
81
|
url: url || existing.url,
|
|
233
82
|
timeout_ms: existing.timeout_ms || 30000,
|
|
234
|
-
cron_expression: interval || existing.
|
|
83
|
+
cron_expression: (interval || existing.cron_expression),
|
|
235
84
|
alert_on_failure: existing.alert_on_failure ?? true,
|
|
236
85
|
};
|
|
237
|
-
|
|
238
|
-
if (process.env.OBS_JSON_OUTPUT === 'true') {
|
|
239
|
-
outputService.formatJsonOutput(updatedMonitor);
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
outputService.success(`Monitor ${monitorId} updated successfully.`);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
catch (error) {
|
|
246
|
-
outputService.error(outputService.formatError(error));
|
|
247
|
-
process.exit(1);
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
// TOGGLE
|
|
251
|
-
monitor
|
|
252
|
-
.command('toggle <id>')
|
|
253
|
-
.description('Pause or resume a URL monitor')
|
|
254
|
-
.option('-j, --json', 'Output in JSON format')
|
|
255
|
-
.action(async (id, options) => {
|
|
256
|
-
if (process.env.OBS_JSON_OUTPUT === 'true' || options.json) {
|
|
257
|
-
outputService.enableJsonMode();
|
|
258
|
-
}
|
|
259
|
-
try {
|
|
260
|
-
const apiKey = configService.getApiKey();
|
|
261
|
-
if (!apiKey) {
|
|
262
|
-
outputService.error('Not authenticated. Please run "obs login" first.');
|
|
263
|
-
process.exit(1);
|
|
264
|
-
}
|
|
265
|
-
const monitorId = parseInt(id);
|
|
266
|
-
if (isNaN(monitorId)) {
|
|
267
|
-
outputService.error('Invalid monitor ID.');
|
|
268
|
-
process.exit(1);
|
|
269
|
-
}
|
|
270
|
-
if (process.env.OBS_JSON_OUTPUT === 'true') {
|
|
271
|
-
outputService.enableJsonMode();
|
|
272
|
-
}
|
|
273
|
-
outputService.progress(`Toggling monitor ${monitorId}...`);
|
|
274
|
-
const isActive = await apiClient.toggleUrlMonitor(monitorId);
|
|
275
|
-
if (process.env.OBS_JSON_OUTPUT === 'true') {
|
|
276
|
-
outputService.formatJsonOutput({
|
|
277
|
-
id: monitorId,
|
|
278
|
-
is_active: isActive,
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
outputService.success(`Monitor ${monitorId} is now ${isActive ? 'ACTIVE' : 'PAUSED'}.`);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
catch (error) {
|
|
286
|
-
outputService.error(outputService.formatError(error));
|
|
287
|
-
process.exit(1);
|
|
288
|
-
}
|
|
86
|
+
},
|
|
289
87
|
});
|
|
290
|
-
return monitor;
|
|
291
88
|
}
|
|
292
89
|
//# sourceMappingURL=monitor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../src/commands/monitor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../src/commands/monitor.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAIhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,aAA6B,EAC7B,SAAqB,EACrB,aAA6B;IAE7B,OAAO,qBAAqB,CAAa,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE;QAChF,YAAY,EAAE,SAAS;QACvB,UAAU,EAAE,cAAc;QAC1B,WAAW,EAAE,qBAAqB;QAClC,UAAU,EAAE;YACV,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE;YACtC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,CAAC;YACxC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAClD,MAAM,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC;YAC1D,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC9C,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC;SAC/C;QACD,UAAU,EAAE;YACV,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC;SAC1E;QACD,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC/B,IAAI,IAAI,GAAG,OAAO,CAAC,IA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,GAAG;gBACH,eAAe,EAAE,QAAQ,IAAI,aAAa;gBAC1C,gBAAgB,EAAE,MAAM,KAAK,KAAK;gBAClC,UAAU,EAAE,KAAK;aAClB,CAAC;QACJ,CAAC;QACD,aAAa,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;YAC7C,MAAM,IAAI,GAAG,OAAO,CAAC,IAA0B,CAAC;YAChD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAyB,CAAC;YAC9C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAA8B,CAAC;YAExD,IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC/B,aAAa,CAAC,KAAK,CACjB,6EAA6E,CAC9E,CAAC;gBACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,IAAI,IAAI,QAAQ,CAAC,IAAI;gBAC3B,GAAG,EAAE,GAAG,IAAI,QAAQ,CAAC,GAAG;gBACxB,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,KAAK;gBACxC,eAAe,EAAE,CAAC,QAAQ,IAAI,QAAQ,CAAC,eAAe,CAAuB;gBAC7E,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB,IAAI,IAAI;aACpD,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { IConfigService } from '../interfaces/config.interface.js';
|
|
3
|
+
import { IApiClient } from '../interfaces/api-client.interface.js';
|
|
4
|
+
import { IOutputService } from '../interfaces/output.interface.js';
|
|
5
|
+
export interface ResourceFactoryOptions<T> {
|
|
6
|
+
resourceName: string;
|
|
7
|
+
pluralName: string;
|
|
8
|
+
description: string;
|
|
9
|
+
apiMethods: {
|
|
10
|
+
list: () => Promise<T[]>;
|
|
11
|
+
get: (id: number) => Promise<T>;
|
|
12
|
+
create: (data: Partial<T>) => Promise<T>;
|
|
13
|
+
update: (id: number, data: Partial<T>) => Promise<T>;
|
|
14
|
+
delete: (id: number) => Promise<void>;
|
|
15
|
+
toggle?: (id: number) => Promise<boolean>;
|
|
16
|
+
};
|
|
17
|
+
formatters: {
|
|
18
|
+
list: (items: T[], verbose: boolean) => void;
|
|
19
|
+
};
|
|
20
|
+
createPrompts?: (options: Record<string, unknown>) => Promise<Partial<T>>;
|
|
21
|
+
updatePrompts?: (id: number, options: Record<string, unknown>, existing: T) => Promise<Partial<T>>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Factory to generate standardized CRUD subcommands for any resource.
|
|
25
|
+
* This ensures consistent JSON mode detection, error handling, and auth checks.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createResourceCommand<T extends {
|
|
28
|
+
id: number;
|
|
29
|
+
name: string;
|
|
30
|
+
}>(configService: IConfigService, apiClient: IApiClient, outputService: IOutputService, options: ResourceFactoryOptions<T>): Command;
|
|
31
|
+
//# sourceMappingURL=resource-command.factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-command.factory.d.ts","sourceRoot":"","sources":["../../src/commands/resource-command.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE;QACV,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;QACzB,GAAG,EAAE,CAAC,EAA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