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.
@@ -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;
@@ -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.FluxService = void 0;
13
13
  const client_1 = require("../client");
14
+ const command_structure_1 = require("../constants/command-structure");
15
+ /**
16
+ * Service for managing Flux CD
17
+ * Command group: flux
18
+ */
14
19
  class FluxService {
15
20
  constructor() {
16
21
  this.client = (0, client_1.createAuthenticatedClient)();
@@ -21,17 +26,29 @@ class FluxService {
21
26
  }
22
27
  return FluxService.instance;
23
28
  }
24
- // This endpoint is not available in the API
25
- installFlux(options) {
29
+ /**
30
+ * Install Flux CD
31
+ * Command: berget flux install
32
+ * This endpoint is not available in the API
33
+ */
34
+ install(options) {
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
- bootstrapFlux(options) {
39
+ /**
40
+ * Bootstrap Flux CD
41
+ * Command: berget flux bootstrap
42
+ * This endpoint is not available in the API
43
+ */
44
+ bootstrap(options) {
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.FluxService = FluxService;
51
+ // Command group name for this service
52
+ FluxService.COMMAND_GROUP = command_structure_1.COMMAND_GROUPS.FLUX;
53
+ // Subcommands for this service
54
+ FluxService.COMMANDS = command_structure_1.SUBCOMMANDS.FLUX;
@@ -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.HelmService = void 0;
13
13
  const client_1 = require("../client");
14
+ const command_structure_1 = require("../constants/command-structure");
15
+ /**
16
+ * Service for managing Helm charts
17
+ * Command group: helm
18
+ */
14
19
  class HelmService {
15
20
  constructor() {
16
21
  this.client = (0, client_1.createAuthenticatedClient)();
@@ -21,17 +26,29 @@ class HelmService {
21
26
  }
22
27
  return HelmService.instance;
23
28
  }
24
- // This endpoint is not available in the API
29
+ /**
30
+ * Add a Helm repository
31
+ * Command: berget helm add-repo
32
+ * This endpoint is not available in the API
33
+ */
25
34
  addRepo(options) {
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
- installChart(options) {
39
+ /**
40
+ * Install a Helm chart
41
+ * Command: berget helm install
42
+ * This endpoint is not available in the API
43
+ */
44
+ install(options) {
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.HelmService = HelmService;
51
+ // Command group name for this service
52
+ HelmService.COMMAND_GROUP = command_structure_1.COMMAND_GROUPS.HELM;
53
+ // Subcommands for this service
54
+ HelmService.COMMANDS = command_structure_1.SUBCOMMANDS.HELM;
@@ -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.KubectlService = void 0;
13
13
  const client_1 = require("../client");
14
+ const command_structure_1 = require("../constants/command-structure");
15
+ /**
16
+ * Service for managing Kubernetes resources
17
+ * Command group: kubectl
18
+ */
14
19
  class KubectlService {
15
20
  constructor() {
16
21
  this.client = (0, client_1.createAuthenticatedClient)();
@@ -21,23 +26,39 @@ class KubectlService {
21
26
  }
22
27
  return KubectlService.instance;
23
28
  }
24
- // This endpoint is not available in the API
29
+ /**
30
+ * Create a Kubernetes namespace
31
+ * Command: berget kubectl create-namespace
32
+ * This endpoint is not available in the API
33
+ */
25
34
  createNamespace(name) {
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
- applyConfiguration(filename) {
39
+ /**
40
+ * Apply a Kubernetes configuration
41
+ * Command: berget kubectl apply
42
+ * This endpoint is not available in the API
43
+ */
44
+ apply(filename) {
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
- // This endpoint is not available in the API
37
- getResources(resource, namespace) {
49
+ /**
50
+ * Get Kubernetes resources
51
+ * Command: berget kubectl get
52
+ * This endpoint is not available in the API
53
+ */
54
+ get(resource, namespace) {
38
55
  return __awaiter(this, void 0, void 0, function* () {
39
56
  throw new Error('This functionality is not available in the API');
40
57
  });
41
58
  }
42
59
  }
43
60
  exports.KubectlService = KubectlService;
61
+ // Command group name for this service
62
+ KubectlService.COMMAND_GROUP = command_structure_1.COMMAND_GROUPS.KUBECTL;
63
+ // Subcommands for this service
64
+ KubectlService.COMMANDS = command_structure_1.SUBCOMMANDS.KUBECTL;
package/index.ts CHANGED
@@ -6,6 +6,7 @@ import * as path from 'path'
6
6
  import { createAuthenticatedClient } from './src/client'
7
7
  import { handleError } from './src/utils/error-handler'
8
8
  import chalk from 'chalk'
9
+ import { COMMAND_GROUPS, SUBCOMMANDS } from './src/constants/command-structure'
9
10
 
10
11
  // Set version and description
11
12
  program
@@ -29,16 +30,20 @@ import { ApiKeyService, ApiKey } from './src/services/api-key-service'
29
30
  import { ClusterService, Cluster } from './src/services/cluster-service'
30
31
 
31
32
  // Auth commands
32
- program
33
- .command('login')
33
+ const auth = program
34
+ .command(AuthService.COMMAND_GROUP)
35
+ .description('Manage authentication and authorization')
36
+
37
+ auth
38
+ .command(AuthService.COMMANDS.LOGIN)
34
39
  .description('Log in to Berget')
35
40
  .action(async () => {
36
41
  const authService = AuthService.getInstance()
37
42
  await authService.login()
38
43
  })
39
44
 
40
- program
41
- .command('logout')
45
+ auth
46
+ .command(AuthService.COMMANDS.LOGOUT)
42
47
  .description('Log out from Berget')
43
48
  .action(() => {
44
49
  const { clearAuthToken } = require('./src/client')
@@ -46,13 +51,13 @@ program
46
51
  console.log(chalk.green('You have been logged out from Berget'))
47
52
  })
48
53
 
49
- program
50
- .command('whoami')
54
+ auth
55
+ .command(AuthService.COMMANDS.WHOAMI)
51
56
  .description('Show information about the logged in user')
52
57
  .action(async () => {
53
58
  try {
54
59
  const authService = AuthService.getInstance()
55
- const profile = await authService.getUserProfile()
60
+ const profile = await authService.whoami()
56
61
 
57
62
  if (profile) {
58
63
  console.log(
@@ -75,15 +80,17 @@ program
75
80
  })
76
81
 
77
82
  // API Key commands
78
- const apiKey = program.command('api-key').description('Manage API keys')
83
+ const apiKey = program
84
+ .command(ApiKeyService.COMMAND_GROUP)
85
+ .description('Manage API keys')
79
86
 
80
87
  apiKey
81
- .command('list')
88
+ .command(ApiKeyService.COMMANDS.LIST)
82
89
  .description('List all API keys')
83
90
  .action(async () => {
84
91
  try {
85
92
  const apiKeyService = ApiKeyService.getInstance()
86
- const keys = await apiKeyService.listApiKeys()
93
+ const keys = await apiKeyService.list()
87
94
 
88
95
  if (keys.length === 0) {
89
96
  console.log(
@@ -143,7 +150,7 @@ apiKey
143
150
  })
144
151
 
145
152
  apiKey
146
- .command('create')
153
+ .command(ApiKeyService.COMMANDS.CREATE)
147
154
  .description('Create a new API key')
148
155
  .option('--name <name>', 'Name of the API key')
149
156
  .option('--description <description>', 'Description of the API key')
@@ -161,7 +168,7 @@ apiKey
161
168
  console.log(chalk.blue('Creating API key...'))
162
169
 
163
170
  const apiKeyService = ApiKeyService.getInstance()
164
- const result = await apiKeyService.createApiKey({
171
+ const result = await apiKeyService.create({
165
172
  name: options.name,
166
173
  description: options.description,
167
174
  })
@@ -202,7 +209,7 @@ apiKey
202
209
  })
203
210
 
204
211
  apiKey
205
- .command('delete')
212
+ .command(ApiKeyService.COMMANDS.DELETE)
206
213
  .description('Delete an API key')
207
214
  .argument('<id>', 'ID of the API key to delete')
208
215
  .action(async (id) => {
@@ -210,7 +217,7 @@ apiKey
210
217
  console.log(chalk.blue(`Deleting API key ${id}...`))
211
218
 
212
219
  const apiKeyService = ApiKeyService.getInstance()
213
- await apiKeyService.deleteApiKey(id)
220
+ await apiKeyService.delete(id)
214
221
 
215
222
  console.log(chalk.green(`✓ API key ${id} has been deleted`))
216
223
  console.log('')
@@ -228,7 +235,7 @@ apiKey
228
235
  })
229
236
 
230
237
  apiKey
231
- .command('rotate')
238
+ .command(ApiKeyService.COMMANDS.ROTATE)
232
239
  .description(
233
240
  'Rotate an API key (creates a new one and invalidates the old one)'
234
241
  )
@@ -241,7 +248,7 @@ apiKey
241
248
  )
242
249
 
243
250
  const apiKeyService = ApiKeyService.getInstance()
244
- const result = await apiKeyService.rotateApiKey(id)
251
+ const result = await apiKeyService.rotate(id)
245
252
 
246
253
  console.log('')
247
254
  console.log(chalk.green('✓ API key rotated'))
@@ -279,7 +286,7 @@ apiKey
279
286
  })
280
287
 
281
288
  apiKey
282
- .command('usage')
289
+ .command(ApiKeyService.COMMANDS.DESCRIBE)
283
290
  .description('Show usage statistics for an API key')
284
291
  .argument('<id>', 'ID of the API key')
285
292
  .option('--start <date>', 'Start date (YYYY-MM-DD)')
@@ -289,7 +296,7 @@ apiKey
289
296
  console.log(chalk.blue(`Fetching usage statistics for API key ${id}...`))
290
297
 
291
298
  const apiKeyService = ApiKeyService.getInstance()
292
- const usage = await apiKeyService.getApiKeyUsage(id)
299
+ const usage = await apiKeyService.describe(id)
293
300
 
294
301
  console.log('')
295
302
  console.log(
@@ -367,17 +374,19 @@ apiKey
367
374
  })
368
375
 
369
376
  // Cluster commands
370
- const cluster = program.command('cluster').description('Manage Berget clusters')
377
+ const cluster = program
378
+ .command(ClusterService.COMMAND_GROUP)
379
+ .description('Manage Berget clusters')
371
380
 
372
381
  // Removed cluster create command as it's not available in the API
373
382
 
374
383
  cluster
375
- .command('list')
384
+ .command(ClusterService.COMMANDS.LIST)
376
385
  .description('List all Berget clusters')
377
386
  .action(async () => {
378
387
  try {
379
388
  const clusterService = ClusterService.getInstance()
380
- const clusters = await clusterService.listClusters()
389
+ const clusters = await clusterService.list()
381
390
 
382
391
  console.log('NAME STATUS NODES CREATED')
383
392
  clusters.forEach((cluster: Cluster) => {
@@ -393,13 +402,13 @@ cluster
393
402
  })
394
403
 
395
404
  cluster
396
- .command('usage')
405
+ .command(ClusterService.COMMANDS.GET_USAGE)
397
406
  .description('Get usage metrics for a specific cluster')
398
407
  .argument('<clusterId>', 'Cluster ID')
399
408
  .action(async (clusterId) => {
400
409
  try {
401
410
  const clusterService = ClusterService.getInstance()
402
- const usage = await clusterService.getClusterUsage(clusterId)
411
+ const usage = await clusterService.getUsage(clusterId)
403
412
 
404
413
  console.log('Cluster Usage:')
405
414
  console.log(JSON.stringify(usage, null, 2))
@@ -408,6 +417,22 @@ cluster
408
417
  }
409
418
  })
410
419
 
420
+ cluster
421
+ .command(ClusterService.COMMANDS.DESCRIBE)
422
+ .description('Get detailed information about a cluster')
423
+ .argument('<clusterId>', 'Cluster ID')
424
+ .action(async (clusterId) => {
425
+ try {
426
+ const clusterService = ClusterService.getInstance()
427
+ const clusterInfo = await clusterService.describe(clusterId)
428
+
429
+ console.log('Cluster Details:')
430
+ console.log(JSON.stringify(clusterInfo, null, 2))
431
+ } catch (error) {
432
+ handleError('Failed to describe cluster', error)
433
+ }
434
+ })
435
+
411
436
  // Autocomplete command
412
437
  program
413
438
  .command('autocomplete')
@@ -430,8 +455,12 @@ program
430
455
  // Removed kubernetes-like commands as they're not available in the API
431
456
 
432
457
  // Add token usage command
433
- program
434
- .command('token-usage')
458
+ const billing = program
459
+ .command(COMMAND_GROUPS.BILLING)
460
+ .description('Manage billing and usage')
461
+
462
+ billing
463
+ .command(SUBCOMMANDS.BILLING.GET_USAGE)
435
464
  .description('Get token usage statistics')
436
465
  .option('--model <modelId>', 'Get usage for a specific model')
437
466
  .action(async (options) => {
@@ -459,8 +488,12 @@ program
459
488
  })
460
489
 
461
490
  // Add models command
462
- program
463
- .command('models')
491
+ const models = program
492
+ .command(COMMAND_GROUPS.MODELS)
493
+ .description('Manage AI models')
494
+
495
+ models
496
+ .command(SUBCOMMANDS.MODELS.LIST)
464
497
  .description('List available AI models')
465
498
  .option('--id <modelId>', 'Get details for a specific model')
466
499
  .action(async (options) => {
@@ -506,9 +539,13 @@ program
506
539
  })
507
540
 
508
541
  // Add team command
509
- program
510
- .command('team')
511
- .description('Manage team members')
542
+ const users = program
543
+ .command(COMMAND_GROUPS.USERS)
544
+ .description('Manage users')
545
+
546
+ users
547
+ .command(SUBCOMMANDS.USERS.LIST)
548
+ .description('List team members')
512
549
  .action(async () => {
513
550
  try {
514
551
  const client = createAuthenticatedClient()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "berget",
3
- "version": "0.0.4",
3
+ "version": "1.0.0",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "berget": "dist/index.js"