berget 0.0.4 → 1.0.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/dist/index.js +62 -30
- package/dist/src/client.js +15 -13
- package/dist/src/constants/command-structure.js +150 -0
- package/dist/src/services/api-key-service.js +34 -5
- package/dist/src/services/auth-service.js +50 -12
- package/dist/src/services/cluster-service.js +37 -2
- package/dist/src/services/collaborator-service.js +21 -4
- package/dist/src/services/flux-service.js +21 -4
- package/dist/src/services/helm-service.js +20 -3
- package/dist/src/services/kubectl-service.js +26 -5
- package/index.ts +67 -30
- package/package.json +1 -1
- package/src/client.ts +68 -58
- package/src/constants/command-structure.ts +168 -0
- package/src/services/api-key-service.ts +36 -5
- package/src/services/auth-service.ts +111 -47
- package/src/services/cluster-service.ts +37 -2
- package/src/services/collaborator-service.ts +23 -4
- package/src/services/flux-service.ts +23 -4
- package/src/services/helm-service.ts +22 -3
- package/src/services/kubectl-service.ts +28 -5
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ const path = __importStar(require("path"));
|
|
|
42
42
|
const client_1 = require("./src/client");
|
|
43
43
|
const error_handler_1 = require("./src/utils/error-handler");
|
|
44
44
|
const chalk_1 = __importDefault(require("chalk"));
|
|
45
|
+
const command_structure_1 = require("./src/constants/command-structure");
|
|
45
46
|
// Set version and description
|
|
46
47
|
commander_1.program
|
|
47
48
|
.name('berget')
|
|
@@ -60,28 +61,31 @@ const auth_service_1 = require("./src/services/auth-service");
|
|
|
60
61
|
const api_key_service_1 = require("./src/services/api-key-service");
|
|
61
62
|
const cluster_service_1 = require("./src/services/cluster-service");
|
|
62
63
|
// Auth commands
|
|
63
|
-
commander_1.program
|
|
64
|
-
.command(
|
|
64
|
+
const auth = commander_1.program
|
|
65
|
+
.command(auth_service_1.AuthService.COMMAND_GROUP)
|
|
66
|
+
.description('Manage authentication and authorization');
|
|
67
|
+
auth
|
|
68
|
+
.command(auth_service_1.AuthService.COMMANDS.LOGIN)
|
|
65
69
|
.description('Log in to Berget')
|
|
66
70
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
71
|
const authService = auth_service_1.AuthService.getInstance();
|
|
68
72
|
yield authService.login();
|
|
69
73
|
}));
|
|
70
|
-
|
|
71
|
-
.command(
|
|
74
|
+
auth
|
|
75
|
+
.command(auth_service_1.AuthService.COMMANDS.LOGOUT)
|
|
72
76
|
.description('Log out from Berget')
|
|
73
77
|
.action(() => {
|
|
74
78
|
const { clearAuthToken } = require('./src/client');
|
|
75
79
|
clearAuthToken();
|
|
76
80
|
console.log(chalk_1.default.green('You have been logged out from Berget'));
|
|
77
81
|
});
|
|
78
|
-
|
|
79
|
-
.command(
|
|
82
|
+
auth
|
|
83
|
+
.command(auth_service_1.AuthService.COMMANDS.WHOAMI)
|
|
80
84
|
.description('Show information about the logged in user')
|
|
81
85
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
86
|
try {
|
|
83
87
|
const authService = auth_service_1.AuthService.getInstance();
|
|
84
|
-
const profile = yield authService.
|
|
88
|
+
const profile = yield authService.whoami();
|
|
85
89
|
if (profile) {
|
|
86
90
|
console.log(chalk_1.default.bold(`Logged in as: ${profile.name || profile.login}`));
|
|
87
91
|
console.log(`Email: ${chalk_1.default.cyan(profile.email || 'Not available')}`);
|
|
@@ -99,14 +103,16 @@ commander_1.program
|
|
|
99
103
|
}
|
|
100
104
|
}));
|
|
101
105
|
// API Key commands
|
|
102
|
-
const apiKey = commander_1.program
|
|
106
|
+
const apiKey = commander_1.program
|
|
107
|
+
.command(api_key_service_1.ApiKeyService.COMMAND_GROUP)
|
|
108
|
+
.description('Manage API keys');
|
|
103
109
|
apiKey
|
|
104
|
-
.command(
|
|
110
|
+
.command(api_key_service_1.ApiKeyService.COMMANDS.LIST)
|
|
105
111
|
.description('List all API keys')
|
|
106
112
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
107
113
|
try {
|
|
108
114
|
const apiKeyService = api_key_service_1.ApiKeyService.getInstance();
|
|
109
|
-
const keys = yield apiKeyService.
|
|
115
|
+
const keys = yield apiKeyService.list();
|
|
110
116
|
if (keys.length === 0) {
|
|
111
117
|
console.log(chalk_1.default.yellow('No API keys found. Create one with `berget api-key create --name <name>`'));
|
|
112
118
|
return;
|
|
@@ -143,7 +149,7 @@ apiKey
|
|
|
143
149
|
}
|
|
144
150
|
}));
|
|
145
151
|
apiKey
|
|
146
|
-
.command(
|
|
152
|
+
.command(api_key_service_1.ApiKeyService.COMMANDS.CREATE)
|
|
147
153
|
.description('Create a new API key')
|
|
148
154
|
.option('--name <name>', 'Name of the API key')
|
|
149
155
|
.option('--description <description>', 'Description of the API key')
|
|
@@ -157,7 +163,7 @@ apiKey
|
|
|
157
163
|
}
|
|
158
164
|
console.log(chalk_1.default.blue('Creating API key...'));
|
|
159
165
|
const apiKeyService = api_key_service_1.ApiKeyService.getInstance();
|
|
160
|
-
const result = yield apiKeyService.
|
|
166
|
+
const result = yield apiKeyService.create({
|
|
161
167
|
name: options.name,
|
|
162
168
|
description: options.description,
|
|
163
169
|
});
|
|
@@ -186,14 +192,14 @@ apiKey
|
|
|
186
192
|
}
|
|
187
193
|
}));
|
|
188
194
|
apiKey
|
|
189
|
-
.command(
|
|
195
|
+
.command(api_key_service_1.ApiKeyService.COMMANDS.DELETE)
|
|
190
196
|
.description('Delete an API key')
|
|
191
197
|
.argument('<id>', 'ID of the API key to delete')
|
|
192
198
|
.action((id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
193
199
|
try {
|
|
194
200
|
console.log(chalk_1.default.blue(`Deleting API key ${id}...`));
|
|
195
201
|
const apiKeyService = api_key_service_1.ApiKeyService.getInstance();
|
|
196
|
-
yield apiKeyService.
|
|
202
|
+
yield apiKeyService.delete(id);
|
|
197
203
|
console.log(chalk_1.default.green(`✓ API key ${id} has been deleted`));
|
|
198
204
|
console.log('');
|
|
199
205
|
console.log(chalk_1.default.dim('Applications using this key will no longer be able to authenticate.'));
|
|
@@ -204,7 +210,7 @@ apiKey
|
|
|
204
210
|
}
|
|
205
211
|
}));
|
|
206
212
|
apiKey
|
|
207
|
-
.command(
|
|
213
|
+
.command(api_key_service_1.ApiKeyService.COMMANDS.ROTATE)
|
|
208
214
|
.description('Rotate an API key (creates a new one and invalidates the old one)')
|
|
209
215
|
.argument('<id>', 'ID of the API key to rotate')
|
|
210
216
|
.action((id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -212,7 +218,7 @@ apiKey
|
|
|
212
218
|
console.log(chalk_1.default.blue(`Rotating API key ${id}...`));
|
|
213
219
|
console.log(chalk_1.default.dim('This will invalidate the old key and generate a new one.'));
|
|
214
220
|
const apiKeyService = api_key_service_1.ApiKeyService.getInstance();
|
|
215
|
-
const result = yield apiKeyService.
|
|
221
|
+
const result = yield apiKeyService.rotate(id);
|
|
216
222
|
console.log('');
|
|
217
223
|
console.log(chalk_1.default.green('✓ API key rotated'));
|
|
218
224
|
console.log('');
|
|
@@ -237,7 +243,7 @@ apiKey
|
|
|
237
243
|
}
|
|
238
244
|
}));
|
|
239
245
|
apiKey
|
|
240
|
-
.command(
|
|
246
|
+
.command(api_key_service_1.ApiKeyService.COMMANDS.DESCRIBE)
|
|
241
247
|
.description('Show usage statistics for an API key')
|
|
242
248
|
.argument('<id>', 'ID of the API key')
|
|
243
249
|
.option('--start <date>', 'Start date (YYYY-MM-DD)')
|
|
@@ -246,7 +252,7 @@ apiKey
|
|
|
246
252
|
try {
|
|
247
253
|
console.log(chalk_1.default.blue(`Fetching usage statistics for API key ${id}...`));
|
|
248
254
|
const apiKeyService = api_key_service_1.ApiKeyService.getInstance();
|
|
249
|
-
const usage = yield apiKeyService.
|
|
255
|
+
const usage = yield apiKeyService.describe(id);
|
|
250
256
|
console.log('');
|
|
251
257
|
console.log(chalk_1.default.bold(`Usage statistics for API key: ${usage.name} (${id})`));
|
|
252
258
|
console.log('');
|
|
@@ -292,15 +298,17 @@ apiKey
|
|
|
292
298
|
}
|
|
293
299
|
}));
|
|
294
300
|
// Cluster commands
|
|
295
|
-
const cluster = commander_1.program
|
|
301
|
+
const cluster = commander_1.program
|
|
302
|
+
.command(cluster_service_1.ClusterService.COMMAND_GROUP)
|
|
303
|
+
.description('Manage Berget clusters');
|
|
296
304
|
// Removed cluster create command as it's not available in the API
|
|
297
305
|
cluster
|
|
298
|
-
.command(
|
|
306
|
+
.command(cluster_service_1.ClusterService.COMMANDS.LIST)
|
|
299
307
|
.description('List all Berget clusters')
|
|
300
308
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
301
309
|
try {
|
|
302
310
|
const clusterService = cluster_service_1.ClusterService.getInstance();
|
|
303
|
-
const clusters = yield clusterService.
|
|
311
|
+
const clusters = yield clusterService.list();
|
|
304
312
|
console.log('NAME STATUS NODES CREATED');
|
|
305
313
|
clusters.forEach((cluster) => {
|
|
306
314
|
console.log(`${cluster.name.padEnd(22)} ${cluster.status.padEnd(9)} ${String(cluster.nodes).padEnd(8)} ${cluster.created}`);
|
|
@@ -311,13 +319,13 @@ cluster
|
|
|
311
319
|
}
|
|
312
320
|
}));
|
|
313
321
|
cluster
|
|
314
|
-
.command(
|
|
322
|
+
.command(cluster_service_1.ClusterService.COMMANDS.GET_USAGE)
|
|
315
323
|
.description('Get usage metrics for a specific cluster')
|
|
316
324
|
.argument('<clusterId>', 'Cluster ID')
|
|
317
325
|
.action((clusterId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
318
326
|
try {
|
|
319
327
|
const clusterService = cluster_service_1.ClusterService.getInstance();
|
|
320
|
-
const usage = yield clusterService.
|
|
328
|
+
const usage = yield clusterService.getUsage(clusterId);
|
|
321
329
|
console.log('Cluster Usage:');
|
|
322
330
|
console.log(JSON.stringify(usage, null, 2));
|
|
323
331
|
}
|
|
@@ -325,6 +333,21 @@ cluster
|
|
|
325
333
|
(0, error_handler_1.handleError)('Failed to get cluster usage', error);
|
|
326
334
|
}
|
|
327
335
|
}));
|
|
336
|
+
cluster
|
|
337
|
+
.command(cluster_service_1.ClusterService.COMMANDS.DESCRIBE)
|
|
338
|
+
.description('Get detailed information about a cluster')
|
|
339
|
+
.argument('<clusterId>', 'Cluster ID')
|
|
340
|
+
.action((clusterId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
341
|
+
try {
|
|
342
|
+
const clusterService = cluster_service_1.ClusterService.getInstance();
|
|
343
|
+
const clusterInfo = yield clusterService.describe(clusterId);
|
|
344
|
+
console.log('Cluster Details:');
|
|
345
|
+
console.log(JSON.stringify(clusterInfo, null, 2));
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
(0, error_handler_1.handleError)('Failed to describe cluster', error);
|
|
349
|
+
}
|
|
350
|
+
}));
|
|
328
351
|
// Autocomplete command
|
|
329
352
|
commander_1.program
|
|
330
353
|
.command('autocomplete')
|
|
@@ -342,8 +365,11 @@ commander_1.program
|
|
|
342
365
|
// Removed helm commands as they're not available in the API
|
|
343
366
|
// Removed kubernetes-like commands as they're not available in the API
|
|
344
367
|
// Add token usage command
|
|
345
|
-
commander_1.program
|
|
346
|
-
.command(
|
|
368
|
+
const billing = commander_1.program
|
|
369
|
+
.command(command_structure_1.COMMAND_GROUPS.BILLING)
|
|
370
|
+
.description('Manage billing and usage');
|
|
371
|
+
billing
|
|
372
|
+
.command(command_structure_1.SUBCOMMANDS.BILLING.GET_USAGE)
|
|
347
373
|
.description('Get token usage statistics')
|
|
348
374
|
.option('--model <modelId>', 'Get usage for a specific model')
|
|
349
375
|
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -372,8 +398,11 @@ commander_1.program
|
|
|
372
398
|
}
|
|
373
399
|
}));
|
|
374
400
|
// Add models command
|
|
375
|
-
commander_1.program
|
|
376
|
-
.command(
|
|
401
|
+
const models = commander_1.program
|
|
402
|
+
.command(command_structure_1.COMMAND_GROUPS.MODELS)
|
|
403
|
+
.description('Manage AI models');
|
|
404
|
+
models
|
|
405
|
+
.command(command_structure_1.SUBCOMMANDS.MODELS.LIST)
|
|
377
406
|
.description('List available AI models')
|
|
378
407
|
.option('--id <modelId>', 'Get details for a specific model')
|
|
379
408
|
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -414,9 +443,12 @@ commander_1.program
|
|
|
414
443
|
}
|
|
415
444
|
}));
|
|
416
445
|
// Add team command
|
|
417
|
-
commander_1.program
|
|
418
|
-
.command(
|
|
419
|
-
.description('Manage
|
|
446
|
+
const users = commander_1.program
|
|
447
|
+
.command(command_structure_1.COMMAND_GROUPS.USERS)
|
|
448
|
+
.description('Manage users');
|
|
449
|
+
users
|
|
450
|
+
.command(command_structure_1.SUBCOMMANDS.USERS.LIST)
|
|
451
|
+
.description('List team members')
|
|
420
452
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
421
453
|
try {
|
|
422
454
|
const client = (0, client_1.createAuthenticatedClient)();
|
package/dist/src/client.js
CHANGED
|
@@ -48,8 +48,8 @@ exports.apiClient = (0, openapi_fetch_1.default)({
|
|
|
48
48
|
baseUrl: API_BASE_URL,
|
|
49
49
|
headers: {
|
|
50
50
|
'Content-Type': 'application/json',
|
|
51
|
-
|
|
52
|
-
}
|
|
51
|
+
Accept: 'application/json',
|
|
52
|
+
},
|
|
53
53
|
});
|
|
54
54
|
// Authentication functions
|
|
55
55
|
const getAuthToken = () => {
|
|
@@ -72,7 +72,7 @@ const isTokenExpired = (token) => {
|
|
|
72
72
|
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
73
73
|
const jsonPayload = decodeURIComponent(atob(base64)
|
|
74
74
|
.split('')
|
|
75
|
-
.map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2))
|
|
75
|
+
.map((c) => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2))
|
|
76
76
|
.join(''));
|
|
77
77
|
const payload = JSON.parse(jsonPayload);
|
|
78
78
|
// Check if token has expired
|
|
@@ -127,20 +127,22 @@ const createAuthenticatedClient = () => {
|
|
|
127
127
|
baseUrl: API_BASE_URL,
|
|
128
128
|
headers: {
|
|
129
129
|
'Content-Type': 'application/json',
|
|
130
|
-
|
|
131
|
-
}
|
|
130
|
+
Accept: 'application/json',
|
|
131
|
+
},
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
return (0, openapi_fetch_1.default)({
|
|
135
135
|
baseUrl: API_BASE_URL,
|
|
136
|
-
headers: token
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
headers: token
|
|
137
|
+
? {
|
|
138
|
+
Authorization: `Bearer ${token}`,
|
|
139
|
+
'Content-Type': 'application/json',
|
|
140
|
+
Accept: 'application/json',
|
|
141
|
+
}
|
|
142
|
+
: {
|
|
143
|
+
'Content-Type': 'application/json',
|
|
144
|
+
Accept: 'application/json',
|
|
145
|
+
},
|
|
144
146
|
});
|
|
145
147
|
};
|
|
146
148
|
exports.createAuthenticatedClient = createAuthenticatedClient;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Command structure constants for the CLI
|
|
4
|
+
* Following patterns from AWS CLI and Google Cloud CLI
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.COMMAND_DESCRIPTIONS = exports.SUBCOMMANDS = exports.COMMAND_GROUPS = void 0;
|
|
8
|
+
// Main command groups
|
|
9
|
+
exports.COMMAND_GROUPS = {
|
|
10
|
+
AUTH: 'auth',
|
|
11
|
+
API_KEYS: 'api-keys',
|
|
12
|
+
CLUSTERS: 'clusters',
|
|
13
|
+
APPS: 'apps',
|
|
14
|
+
MODELS: 'models',
|
|
15
|
+
HELM: 'helm',
|
|
16
|
+
KUBECTL: 'kubectl',
|
|
17
|
+
FLUX: 'flux',
|
|
18
|
+
USERS: 'users',
|
|
19
|
+
BILLING: 'billing',
|
|
20
|
+
};
|
|
21
|
+
// Subcommands for each group
|
|
22
|
+
exports.SUBCOMMANDS = {
|
|
23
|
+
// Auth commands
|
|
24
|
+
AUTH: {
|
|
25
|
+
LOGIN: 'login',
|
|
26
|
+
LOGOUT: 'logout',
|
|
27
|
+
WHOAMI: 'whoami',
|
|
28
|
+
},
|
|
29
|
+
// API Keys commands
|
|
30
|
+
API_KEYS: {
|
|
31
|
+
LIST: 'list',
|
|
32
|
+
CREATE: 'create',
|
|
33
|
+
DELETE: 'delete',
|
|
34
|
+
ROTATE: 'rotate',
|
|
35
|
+
DESCRIBE: 'describe',
|
|
36
|
+
},
|
|
37
|
+
// Clusters commands
|
|
38
|
+
CLUSTERS: {
|
|
39
|
+
LIST: 'list',
|
|
40
|
+
DESCRIBE: 'describe',
|
|
41
|
+
GET_USAGE: 'get-usage',
|
|
42
|
+
},
|
|
43
|
+
// Apps commands
|
|
44
|
+
APPS: {
|
|
45
|
+
LIST_TEMPLATES: 'list-templates',
|
|
46
|
+
DESCRIBE_TEMPLATE: 'describe-template',
|
|
47
|
+
LIST_INSTALLATIONS: 'list-installations',
|
|
48
|
+
INSTALL: 'install',
|
|
49
|
+
UNINSTALL: 'uninstall',
|
|
50
|
+
DESCRIBE_INSTALLATION: 'describe-installation',
|
|
51
|
+
},
|
|
52
|
+
// Models commands
|
|
53
|
+
MODELS: {
|
|
54
|
+
LIST: 'list',
|
|
55
|
+
DESCRIBE: 'describe',
|
|
56
|
+
},
|
|
57
|
+
// Helm commands
|
|
58
|
+
HELM: {
|
|
59
|
+
ADD_REPO: 'add-repo',
|
|
60
|
+
INSTALL: 'install',
|
|
61
|
+
},
|
|
62
|
+
// Kubectl commands
|
|
63
|
+
KUBECTL: {
|
|
64
|
+
CREATE_NAMESPACE: 'create-namespace',
|
|
65
|
+
APPLY: 'apply',
|
|
66
|
+
GET: 'get',
|
|
67
|
+
},
|
|
68
|
+
// Flux commands
|
|
69
|
+
FLUX: {
|
|
70
|
+
INSTALL: 'install',
|
|
71
|
+
BOOTSTRAP: 'bootstrap',
|
|
72
|
+
},
|
|
73
|
+
// Users commands
|
|
74
|
+
USERS: {
|
|
75
|
+
LIST: 'list',
|
|
76
|
+
DESCRIBE: 'describe',
|
|
77
|
+
UPDATE: 'update',
|
|
78
|
+
INVITE: 'invite',
|
|
79
|
+
},
|
|
80
|
+
// Billing commands
|
|
81
|
+
BILLING: {
|
|
82
|
+
GET_USAGE: 'get-usage',
|
|
83
|
+
LIST_INVOICES: 'list-invoices',
|
|
84
|
+
DESCRIBE_INVOICE: 'describe-invoice',
|
|
85
|
+
LIST_PAYMENT_METHODS: 'list-payment-methods',
|
|
86
|
+
ADD_PAYMENT_METHOD: 'add-payment-method',
|
|
87
|
+
REMOVE_PAYMENT_METHOD: 'remove-payment-method',
|
|
88
|
+
UPDATE_SUBSCRIPTION: 'update-subscription',
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
// Command descriptions
|
|
92
|
+
exports.COMMAND_DESCRIPTIONS = {
|
|
93
|
+
// Auth group
|
|
94
|
+
[exports.COMMAND_GROUPS.AUTH]: 'Manage authentication and authorization',
|
|
95
|
+
[`${exports.COMMAND_GROUPS.AUTH} ${exports.SUBCOMMANDS.AUTH.LOGIN}`]: 'Log in to Berget AI',
|
|
96
|
+
[`${exports.COMMAND_GROUPS.AUTH} ${exports.SUBCOMMANDS.AUTH.LOGOUT}`]: 'Log out from Berget AI',
|
|
97
|
+
[`${exports.COMMAND_GROUPS.AUTH} ${exports.SUBCOMMANDS.AUTH.WHOAMI}`]: 'Display current user information',
|
|
98
|
+
// API Keys group
|
|
99
|
+
[exports.COMMAND_GROUPS.API_KEYS]: 'Manage API keys',
|
|
100
|
+
[`${exports.COMMAND_GROUPS.API_KEYS} ${exports.SUBCOMMANDS.API_KEYS.LIST}`]: 'List all API keys',
|
|
101
|
+
[`${exports.COMMAND_GROUPS.API_KEYS} ${exports.SUBCOMMANDS.API_KEYS.CREATE}`]: 'Create a new API key',
|
|
102
|
+
[`${exports.COMMAND_GROUPS.API_KEYS} ${exports.SUBCOMMANDS.API_KEYS.DELETE}`]: 'Delete an API key',
|
|
103
|
+
[`${exports.COMMAND_GROUPS.API_KEYS} ${exports.SUBCOMMANDS.API_KEYS.ROTATE}`]: 'Rotate an API key',
|
|
104
|
+
[`${exports.COMMAND_GROUPS.API_KEYS} ${exports.SUBCOMMANDS.API_KEYS.DESCRIBE}`]: 'Get usage statistics for an API key',
|
|
105
|
+
// Clusters group
|
|
106
|
+
[exports.COMMAND_GROUPS.CLUSTERS]: 'Manage Kubernetes clusters',
|
|
107
|
+
[`${exports.COMMAND_GROUPS.CLUSTERS} ${exports.SUBCOMMANDS.CLUSTERS.LIST}`]: 'List all clusters',
|
|
108
|
+
[`${exports.COMMAND_GROUPS.CLUSTERS} ${exports.SUBCOMMANDS.CLUSTERS.DESCRIBE}`]: 'Get detailed information about a cluster',
|
|
109
|
+
[`${exports.COMMAND_GROUPS.CLUSTERS} ${exports.SUBCOMMANDS.CLUSTERS.GET_USAGE}`]: 'Get resource usage for a cluster',
|
|
110
|
+
// Apps group
|
|
111
|
+
[exports.COMMAND_GROUPS.APPS]: 'Manage applications',
|
|
112
|
+
[`${exports.COMMAND_GROUPS.APPS} ${exports.SUBCOMMANDS.APPS.LIST_TEMPLATES}`]: 'List available application templates',
|
|
113
|
+
[`${exports.COMMAND_GROUPS.APPS} ${exports.SUBCOMMANDS.APPS.DESCRIBE_TEMPLATE}`]: 'Get detailed information about an application template',
|
|
114
|
+
[`${exports.COMMAND_GROUPS.APPS} ${exports.SUBCOMMANDS.APPS.LIST_INSTALLATIONS}`]: 'List installed applications',
|
|
115
|
+
[`${exports.COMMAND_GROUPS.APPS} ${exports.SUBCOMMANDS.APPS.INSTALL}`]: 'Install an application',
|
|
116
|
+
[`${exports.COMMAND_GROUPS.APPS} ${exports.SUBCOMMANDS.APPS.UNINSTALL}`]: 'Uninstall an application',
|
|
117
|
+
[`${exports.COMMAND_GROUPS.APPS} ${exports.SUBCOMMANDS.APPS.DESCRIBE_INSTALLATION}`]: 'Get detailed information about an installed application',
|
|
118
|
+
// Models group
|
|
119
|
+
[exports.COMMAND_GROUPS.MODELS]: 'Manage AI models',
|
|
120
|
+
[`${exports.COMMAND_GROUPS.MODELS} ${exports.SUBCOMMANDS.MODELS.LIST}`]: 'List available AI models',
|
|
121
|
+
[`${exports.COMMAND_GROUPS.MODELS} ${exports.SUBCOMMANDS.MODELS.DESCRIBE}`]: 'Get detailed information about an AI model',
|
|
122
|
+
// Helm group
|
|
123
|
+
[exports.COMMAND_GROUPS.HELM]: 'Manage Helm charts',
|
|
124
|
+
[`${exports.COMMAND_GROUPS.HELM} ${exports.SUBCOMMANDS.HELM.ADD_REPO}`]: 'Add a Helm repository',
|
|
125
|
+
[`${exports.COMMAND_GROUPS.HELM} ${exports.SUBCOMMANDS.HELM.INSTALL}`]: 'Install a Helm chart',
|
|
126
|
+
// Kubectl group
|
|
127
|
+
[exports.COMMAND_GROUPS.KUBECTL]: 'Manage Kubernetes resources',
|
|
128
|
+
[`${exports.COMMAND_GROUPS.KUBECTL} ${exports.SUBCOMMANDS.KUBECTL.CREATE_NAMESPACE}`]: 'Create a Kubernetes namespace',
|
|
129
|
+
[`${exports.COMMAND_GROUPS.KUBECTL} ${exports.SUBCOMMANDS.KUBECTL.APPLY}`]: 'Apply a Kubernetes configuration',
|
|
130
|
+
[`${exports.COMMAND_GROUPS.KUBECTL} ${exports.SUBCOMMANDS.KUBECTL.GET}`]: 'Get Kubernetes resources',
|
|
131
|
+
// Flux group
|
|
132
|
+
[exports.COMMAND_GROUPS.FLUX]: 'Manage Flux CD',
|
|
133
|
+
[`${exports.COMMAND_GROUPS.FLUX} ${exports.SUBCOMMANDS.FLUX.INSTALL}`]: 'Install Flux CD',
|
|
134
|
+
[`${exports.COMMAND_GROUPS.FLUX} ${exports.SUBCOMMANDS.FLUX.BOOTSTRAP}`]: 'Bootstrap Flux CD',
|
|
135
|
+
// Users group
|
|
136
|
+
[exports.COMMAND_GROUPS.USERS]: 'Manage users',
|
|
137
|
+
[`${exports.COMMAND_GROUPS.USERS} ${exports.SUBCOMMANDS.USERS.LIST}`]: 'List all users in your organization',
|
|
138
|
+
[`${exports.COMMAND_GROUPS.USERS} ${exports.SUBCOMMANDS.USERS.DESCRIBE}`]: 'Get detailed information about a user',
|
|
139
|
+
[`${exports.COMMAND_GROUPS.USERS} ${exports.SUBCOMMANDS.USERS.UPDATE}`]: 'Update user information',
|
|
140
|
+
[`${exports.COMMAND_GROUPS.USERS} ${exports.SUBCOMMANDS.USERS.INVITE}`]: 'Invite a new user to your organization',
|
|
141
|
+
// Billing group
|
|
142
|
+
[exports.COMMAND_GROUPS.BILLING]: 'Manage billing and usage',
|
|
143
|
+
[`${exports.COMMAND_GROUPS.BILLING} ${exports.SUBCOMMANDS.BILLING.GET_USAGE}`]: 'Get current usage metrics',
|
|
144
|
+
[`${exports.COMMAND_GROUPS.BILLING} ${exports.SUBCOMMANDS.BILLING.LIST_INVOICES}`]: 'List all invoices',
|
|
145
|
+
[`${exports.COMMAND_GROUPS.BILLING} ${exports.SUBCOMMANDS.BILLING.DESCRIBE_INVOICE}`]: 'Get detailed information about an invoice',
|
|
146
|
+
[`${exports.COMMAND_GROUPS.BILLING} ${exports.SUBCOMMANDS.BILLING.LIST_PAYMENT_METHODS}`]: 'List all payment methods',
|
|
147
|
+
[`${exports.COMMAND_GROUPS.BILLING} ${exports.SUBCOMMANDS.BILLING.ADD_PAYMENT_METHOD}`]: 'Add a new payment method',
|
|
148
|
+
[`${exports.COMMAND_GROUPS.BILLING} ${exports.SUBCOMMANDS.BILLING.REMOVE_PAYMENT_METHOD}`]: 'Remove a payment method',
|
|
149
|
+
[`${exports.COMMAND_GROUPS.BILLING} ${exports.SUBCOMMANDS.BILLING.UPDATE_SUBSCRIPTION}`]: 'Update subscription plan',
|
|
150
|
+
};
|
|
@@ -12,6 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ApiKeyService = void 0;
|
|
13
13
|
const client_1 = require("../client");
|
|
14
14
|
const error_handler_1 = require("../utils/error-handler");
|
|
15
|
+
const command_structure_1 = require("../constants/command-structure");
|
|
16
|
+
/**
|
|
17
|
+
* Service for managing API keys
|
|
18
|
+
* Command group: api-keys
|
|
19
|
+
*/
|
|
15
20
|
class ApiKeyService {
|
|
16
21
|
constructor() {
|
|
17
22
|
this.client = (0, client_1.createAuthenticatedClient)();
|
|
@@ -22,7 +27,11 @@ class ApiKeyService {
|
|
|
22
27
|
}
|
|
23
28
|
return ApiKeyService.instance;
|
|
24
29
|
}
|
|
25
|
-
|
|
30
|
+
/**
|
|
31
|
+
* List all API keys
|
|
32
|
+
* Command: berget api-keys list
|
|
33
|
+
*/
|
|
34
|
+
list() {
|
|
26
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
36
|
try {
|
|
28
37
|
const { data, error } = yield this.client.GET('/v1/api-keys');
|
|
@@ -46,7 +55,11 @@ class ApiKeyService {
|
|
|
46
55
|
}
|
|
47
56
|
});
|
|
48
57
|
}
|
|
49
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Create a new API key
|
|
60
|
+
* Command: berget api-keys create
|
|
61
|
+
*/
|
|
62
|
+
create(options) {
|
|
50
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
64
|
try {
|
|
52
65
|
const { data, error } = yield this.client.POST('/v1/api-keys', {
|
|
@@ -62,7 +75,11 @@ class ApiKeyService {
|
|
|
62
75
|
}
|
|
63
76
|
});
|
|
64
77
|
}
|
|
65
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Delete an API key
|
|
80
|
+
* Command: berget api-keys delete
|
|
81
|
+
*/
|
|
82
|
+
delete(id) {
|
|
66
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
84
|
try {
|
|
68
85
|
const { error } = yield this.client.DELETE('/v1/api-keys/{id}', {
|
|
@@ -78,7 +95,11 @@ class ApiKeyService {
|
|
|
78
95
|
}
|
|
79
96
|
});
|
|
80
97
|
}
|
|
81
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Rotate an API key
|
|
100
|
+
* Command: berget api-keys rotate
|
|
101
|
+
*/
|
|
102
|
+
rotate(id) {
|
|
82
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
104
|
try {
|
|
84
105
|
const { data, error } = yield this.client.PUT('/v1/api-keys/{id}/rotate', {
|
|
@@ -94,7 +115,11 @@ class ApiKeyService {
|
|
|
94
115
|
}
|
|
95
116
|
});
|
|
96
117
|
}
|
|
97
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Get usage statistics for an API key
|
|
120
|
+
* Command: berget api-keys describe
|
|
121
|
+
*/
|
|
122
|
+
describe(id) {
|
|
98
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
124
|
try {
|
|
100
125
|
const { data, error } = yield this.client.GET('/v1/api-keys/{id}/usage', {
|
|
@@ -112,3 +137,7 @@ class ApiKeyService {
|
|
|
112
137
|
}
|
|
113
138
|
}
|
|
114
139
|
exports.ApiKeyService = ApiKeyService;
|
|
140
|
+
// Command group name for this service
|
|
141
|
+
ApiKeyService.COMMAND_GROUP = command_structure_1.COMMAND_GROUPS.API_KEYS;
|
|
142
|
+
// Subcommands for this service
|
|
143
|
+
ApiKeyService.COMMANDS = command_structure_1.SUBCOMMANDS.API_KEYS;
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -14,9 +37,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
38
|
exports.AuthService = void 0;
|
|
16
39
|
const client_1 = require("../client");
|
|
17
|
-
|
|
40
|
+
// We'll use dynamic import for 'open' to support ESM modules in CommonJS
|
|
18
41
|
const chalk_1 = __importDefault(require("chalk"));
|
|
19
42
|
const error_handler_1 = require("../utils/error-handler");
|
|
43
|
+
const command_structure_1 = require("../constants/command-structure");
|
|
44
|
+
/**
|
|
45
|
+
* Service for authentication operations
|
|
46
|
+
* Command group: auth
|
|
47
|
+
*/
|
|
20
48
|
class AuthService {
|
|
21
49
|
constructor() {
|
|
22
50
|
this.client = (0, client_1.createAuthenticatedClient)();
|
|
@@ -36,7 +64,9 @@ class AuthService {
|
|
|
36
64
|
// Step 1: Initiate device authorization
|
|
37
65
|
const { data: deviceData, error: deviceError } = yield client_1.apiClient.POST('/v1/auth/device', {});
|
|
38
66
|
if (deviceError || !deviceData) {
|
|
39
|
-
throw new Error(deviceError
|
|
67
|
+
throw new Error(deviceError
|
|
68
|
+
? JSON.stringify(deviceError)
|
|
69
|
+
: 'Failed to get device authorization data');
|
|
40
70
|
}
|
|
41
71
|
// Display information to user
|
|
42
72
|
console.log(chalk_1.default.cyan('\nTo complete login:'));
|
|
@@ -45,8 +75,10 @@ class AuthService {
|
|
|
45
75
|
// Try to open browser automatically
|
|
46
76
|
try {
|
|
47
77
|
if (deviceData.verification_url) {
|
|
48
|
-
|
|
49
|
-
|
|
78
|
+
// Use dynamic import for the 'open' package
|
|
79
|
+
const open = yield Promise.resolve().then(() => __importStar(require('open'))).then(m => m.default);
|
|
80
|
+
yield open(deviceData.verification_url);
|
|
81
|
+
console.log(chalk_1.default.dim("Browser opened automatically. If it didn't open, please use the URL above."));
|
|
50
82
|
}
|
|
51
83
|
}
|
|
52
84
|
catch (error) {
|
|
@@ -56,13 +88,13 @@ class AuthService {
|
|
|
56
88
|
// Step 2: Poll for completion
|
|
57
89
|
const startTime = Date.now();
|
|
58
90
|
const expiresIn = deviceData.expires_in !== undefined ? deviceData.expires_in : 900;
|
|
59
|
-
const expiresAt = startTime +
|
|
91
|
+
const expiresAt = startTime + expiresIn * 1000;
|
|
60
92
|
let pollInterval = (deviceData.interval || 5) * 1000;
|
|
61
93
|
const spinner = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
62
94
|
let spinnerIdx = 0;
|
|
63
95
|
while (Date.now() < expiresAt) {
|
|
64
96
|
// Wait for the polling interval
|
|
65
|
-
yield new Promise(resolve => setTimeout(resolve, pollInterval));
|
|
97
|
+
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
66
98
|
// Update spinner
|
|
67
99
|
process.stdout.write(`\r${chalk_1.default.blue(spinner[spinnerIdx])} Waiting for authentication...`);
|
|
68
100
|
spinnerIdx = (spinnerIdx + 1) % spinner.length;
|
|
@@ -70,14 +102,12 @@ class AuthService {
|
|
|
70
102
|
const deviceCode = deviceData.device_code || '';
|
|
71
103
|
const { data: tokenData, error: tokenError } = yield client_1.apiClient.POST('/v1/auth/device/token', {
|
|
72
104
|
body: {
|
|
73
|
-
device_code: deviceCode
|
|
74
|
-
}
|
|
105
|
+
device_code: deviceCode,
|
|
106
|
+
},
|
|
75
107
|
});
|
|
76
108
|
if (tokenError) {
|
|
77
109
|
// Parse the error to get status and other details
|
|
78
|
-
const errorObj = typeof tokenError === 'string'
|
|
79
|
-
? JSON.parse(tokenError)
|
|
80
|
-
: tokenError;
|
|
110
|
+
const errorObj = typeof tokenError === 'string' ? JSON.parse(tokenError) : tokenError;
|
|
81
111
|
const status = errorObj.status || 0;
|
|
82
112
|
const errorCode = errorObj.code || '';
|
|
83
113
|
if (status === 401 || errorCode === 'AUTHORIZATION_PENDING') {
|
|
@@ -150,7 +180,11 @@ class AuthService {
|
|
|
150
180
|
}
|
|
151
181
|
});
|
|
152
182
|
}
|
|
153
|
-
|
|
183
|
+
/**
|
|
184
|
+
* Get current user profile
|
|
185
|
+
* Command: berget auth whoami
|
|
186
|
+
*/
|
|
187
|
+
whoami() {
|
|
154
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
189
|
try {
|
|
156
190
|
const { data, error } = yield this.client.GET('/v1/users/me');
|
|
@@ -166,3 +200,7 @@ class AuthService {
|
|
|
166
200
|
}
|
|
167
201
|
}
|
|
168
202
|
exports.AuthService = AuthService;
|
|
203
|
+
// Command group name for this service
|
|
204
|
+
AuthService.COMMAND_GROUP = command_structure_1.COMMAND_GROUPS.AUTH;
|
|
205
|
+
// Subcommands for this service
|
|
206
|
+
AuthService.COMMANDS = command_structure_1.SUBCOMMANDS.AUTH;
|