berget 0.1.0 → 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 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('login')
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
- commander_1.program
71
- .command('logout')
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
- commander_1.program
79
- .command('whoami')
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.getUserProfile();
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.command('api-key').description('Manage API keys');
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('list')
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.listApiKeys();
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('create')
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.createApiKey({
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('delete')
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.deleteApiKey(id);
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('rotate')
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.rotateApiKey(id);
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('usage')
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.getApiKeyUsage(id);
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.command('cluster').description('Manage Berget clusters');
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('list')
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.listClusters();
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('usage')
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.getClusterUsage(clusterId);
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('token-usage')
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('models')
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('team')
419
- .description('Manage team members')
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)();
@@ -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
- listApiKeys() {
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
- createApiKey(options) {
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
- deleteApiKey(id) {
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
- rotateApiKey(id) {
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
- getApiKeyUsage(id) {
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
- const open_1 = __importDefault(require("open"));
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)();
@@ -47,7 +75,9 @@ class AuthService {
47
75
  // Try to open browser automatically
48
76
  try {
49
77
  if (deviceData.verification_url) {
50
- yield (0, open_1.default)(deviceData.verification_url);
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);
51
81
  console.log(chalk_1.default.dim("Browser opened automatically. If it didn't open, please use the URL above."));
52
82
  }
53
83
  }
@@ -150,7 +180,11 @@ class AuthService {
150
180
  }
151
181
  });
152
182
  }
153
- getUserProfile() {
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;
@@ -11,6 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ClusterService = void 0;
13
13
  const client_1 = require("../client");
14
+ const command_structure_1 = require("../constants/command-structure");
15
+ /**
16
+ * Service for managing Kubernetes clusters
17
+ * Command group: clusters
18
+ */
14
19
  class ClusterService {
15
20
  constructor() {
16
21
  this.client = (0, client_1.createAuthenticatedClient)();
@@ -21,7 +26,11 @@ class ClusterService {
21
26
  }
22
27
  return ClusterService.instance;
23
28
  }
24
- getClusterUsage(clusterId) {
29
+ /**
30
+ * Get resource usage for a cluster
31
+ * Command: berget clusters get-usage
32
+ */
33
+ getUsage(clusterId) {
25
34
  return __awaiter(this, void 0, void 0, function* () {
26
35
  try {
27
36
  const { data, error } = yield this.client.GET('/v1/clusters/{clusterId}/usage', {
@@ -37,7 +46,11 @@ class ClusterService {
37
46
  }
38
47
  });
39
48
  }
40
- listClusters() {
49
+ /**
50
+ * List all clusters
51
+ * Command: berget clusters list
52
+ */
53
+ list() {
41
54
  return __awaiter(this, void 0, void 0, function* () {
42
55
  try {
43
56
  const { data, error } = yield this.client.GET('/v1/clusters');
@@ -51,5 +64,27 @@ class ClusterService {
51
64
  }
52
65
  });
53
66
  }
67
+ /**
68
+ * Get detailed information about a cluster
69
+ * Command: berget clusters describe
70
+ */
71
+ describe(clusterId) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ try {
74
+ // This is a placeholder since the API doesn't have a specific endpoint
75
+ // In a real implementation, this would call a specific endpoint
76
+ const clusters = yield this.list();
77
+ return clusters.find(cluster => cluster.id === clusterId) || null;
78
+ }
79
+ catch (error) {
80
+ console.error('Failed to describe cluster:', error);
81
+ throw error;
82
+ }
83
+ });
84
+ }
54
85
  }
55
86
  exports.ClusterService = ClusterService;
87
+ // Command group name for this service
88
+ ClusterService.COMMAND_GROUP = command_structure_1.COMMAND_GROUPS.CLUSTERS;
89
+ // Subcommands for this service
90
+ ClusterService.COMMANDS = command_structure_1.SUBCOMMANDS.CLUSTERS;
@@ -11,6 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CollaboratorService = void 0;
13
13
  const client_1 = require("../client");
14
+ const command_structure_1 = require("../constants/command-structure");
15
+ /**
16
+ * Service for managing collaborators
17
+ * Command group: users
18
+ */
14
19
  class CollaboratorService {
15
20
  constructor() {
16
21
  this.client = (0, client_1.createAuthenticatedClient)();
@@ -21,17 +26,29 @@ class CollaboratorService {
21
26
  }
22
27
  return CollaboratorService.instance;
23
28
  }
24
- // This endpoint is not available in the API
25
- addCollaborator(clusterId, githubUsername) {
29
+ /**
30
+ * Invite a new collaborator
31
+ * Command: berget users invite
32
+ * This endpoint is not available in the API
33
+ */
34
+ invite(clusterId, githubUsername) {
26
35
  return __awaiter(this, void 0, void 0, function* () {
27
36
  throw new Error('This functionality is not available in the API');
28
37
  });
29
38
  }
30
- // This endpoint is not available in the API
31
- listCollaborators(clusterId) {
39
+ /**
40
+ * List all collaborators
41
+ * Command: berget users list
42
+ * This endpoint is not available in the API
43
+ */
44
+ list(clusterId) {
32
45
  return __awaiter(this, void 0, void 0, function* () {
33
46
  throw new Error('This functionality is not available in the API');
34
47
  });
35
48
  }
36
49
  }
37
50
  exports.CollaboratorService = CollaboratorService;
51
+ // Command group name for this service
52
+ CollaboratorService.COMMAND_GROUP = command_structure_1.COMMAND_GROUPS.USERS;
53
+ // Subcommands for this service
54
+ CollaboratorService.COMMANDS = command_structure_1.SUBCOMMANDS.USERS;