@agentuity/cli 0.0.58 → 0.0.60
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/cli.d.ts.map +1 -1
- package/dist/cli.js +14 -1
- package/dist/cli.js.map +1 -1
- package/dist/cmd/ai/capabilities/show.d.ts.map +1 -1
- package/dist/cmd/ai/capabilities/show.js +11 -4
- package/dist/cmd/ai/capabilities/show.js.map +1 -1
- package/dist/cmd/build/bundler.d.ts +1 -1
- package/dist/cmd/cloud/agent/get.d.ts +2 -0
- package/dist/cmd/cloud/agent/get.d.ts.map +1 -0
- package/dist/cmd/cloud/agent/get.js +97 -0
- package/dist/cmd/cloud/agent/get.js.map +1 -0
- package/dist/cmd/cloud/agent/index.d.ts +2 -0
- package/dist/cmd/cloud/agent/index.d.ts.map +1 -0
- package/dist/cmd/cloud/agent/index.js +11 -0
- package/dist/cmd/cloud/agent/index.js.map +1 -0
- package/dist/cmd/cloud/agent/list.d.ts.map +1 -0
- package/dist/cmd/cloud/agent/list.js +101 -0
- package/dist/cmd/cloud/agent/list.js.map +1 -0
- package/dist/cmd/cloud/agent/schema.d.ts +4 -0
- package/dist/cmd/cloud/agent/schema.d.ts.map +1 -0
- package/dist/cmd/cloud/agent/schema.js +22 -0
- package/dist/cmd/cloud/agent/schema.js.map +1 -0
- package/dist/cmd/cloud/apikey/create.d.ts +2 -0
- package/dist/cmd/cloud/apikey/create.d.ts.map +1 -0
- package/dist/cmd/cloud/apikey/create.js +100 -0
- package/dist/cmd/cloud/apikey/create.js.map +1 -0
- package/dist/cmd/cloud/apikey/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/apikey/delete.js +55 -0
- package/dist/cmd/cloud/apikey/delete.js.map +1 -0
- package/dist/cmd/cloud/apikey/get.d.ts +2 -0
- package/dist/cmd/cloud/apikey/get.d.ts.map +1 -0
- package/dist/cmd/cloud/apikey/get.js +57 -0
- package/dist/cmd/cloud/apikey/get.js.map +1 -0
- package/dist/cmd/cloud/apikey/index.d.ts.map +1 -0
- package/dist/cmd/cloud/apikey/index.js +13 -0
- package/dist/cmd/cloud/apikey/index.js.map +1 -0
- package/dist/cmd/cloud/apikey/list.d.ts +2 -0
- package/dist/cmd/cloud/apikey/list.d.ts.map +1 -0
- package/dist/cmd/cloud/apikey/list.js +53 -0
- package/dist/cmd/cloud/apikey/list.js.map +1 -0
- package/dist/cmd/cloud/db/create.d.ts +2 -0
- package/dist/cmd/cloud/db/create.d.ts.map +1 -0
- package/dist/cmd/cloud/db/create.js +68 -0
- package/dist/cmd/cloud/db/create.js.map +1 -0
- package/dist/cmd/cloud/db/delete.d.ts +2 -0
- package/dist/cmd/cloud/db/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/db/delete.js +106 -0
- package/dist/cmd/cloud/db/delete.js.map +1 -0
- package/dist/cmd/cloud/db/get.d.ts +2 -0
- package/dist/cmd/cloud/db/get.d.ts.map +1 -0
- package/dist/cmd/cloud/db/get.js +66 -0
- package/dist/cmd/cloud/db/get.js.map +1 -0
- package/dist/cmd/cloud/db/index.d.ts +2 -0
- package/dist/cmd/cloud/db/index.d.ts.map +1 -0
- package/dist/cmd/cloud/db/index.js +14 -0
- package/dist/cmd/cloud/db/index.js.map +1 -0
- package/dist/cmd/cloud/db/list.d.ts +2 -0
- package/dist/cmd/cloud/db/list.d.ts.map +1 -0
- package/dist/cmd/cloud/db/list.js +75 -0
- package/dist/cmd/cloud/db/list.js.map +1 -0
- package/dist/cmd/cloud/db/sql.d.ts +2 -0
- package/dist/cmd/cloud/db/sql.d.ts.map +1 -0
- package/dist/cmd/cloud/db/sql.js +102 -0
- package/dist/cmd/cloud/db/sql.js.map +1 -0
- package/dist/cmd/cloud/deployment/index.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/index.js +2 -0
- package/dist/cmd/cloud/deployment/index.js.map +1 -1
- package/dist/cmd/cloud/deployment/logs.d.ts +2 -0
- package/dist/cmd/cloud/deployment/logs.d.ts.map +1 -0
- package/dist/cmd/cloud/deployment/logs.js +70 -0
- package/dist/cmd/cloud/deployment/logs.js.map +1 -0
- package/dist/cmd/cloud/env/get.d.ts.map +1 -1
- package/dist/cmd/cloud/env/get.js +2 -3
- package/dist/cmd/cloud/env/get.js.map +1 -1
- package/dist/cmd/cloud/env/list.d.ts.map +1 -1
- package/dist/cmd/cloud/env/list.js +1 -2
- package/dist/cmd/cloud/env/list.js.map +1 -1
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/index.js +12 -4
- package/dist/cmd/cloud/index.js.map +1 -1
- package/dist/cmd/cloud/secret/get.d.ts.map +1 -1
- package/dist/cmd/cloud/secret/get.js +2 -3
- package/dist/cmd/cloud/secret/get.js.map +1 -1
- package/dist/cmd/cloud/secret/list.d.ts.map +1 -1
- package/dist/cmd/cloud/secret/list.js +1 -2
- package/dist/cmd/cloud/secret/list.js.map +1 -1
- package/dist/cmd/cloud/session/logs.d.ts.map +1 -1
- package/dist/cmd/cloud/session/logs.js +12 -9
- package/dist/cmd/cloud/session/logs.js.map +1 -1
- package/dist/cmd/cloud/storage/create.d.ts +2 -0
- package/dist/cmd/cloud/storage/create.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/create.js +61 -0
- package/dist/cmd/cloud/storage/create.js.map +1 -0
- package/dist/cmd/cloud/storage/delete.d.ts +2 -0
- package/dist/cmd/cloud/storage/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/delete.js +167 -0
- package/dist/cmd/cloud/storage/delete.js.map +1 -0
- package/dist/cmd/cloud/storage/download.d.ts +2 -0
- package/dist/cmd/cloud/storage/download.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/download.js +131 -0
- package/dist/cmd/cloud/storage/download.js.map +1 -0
- package/dist/cmd/cloud/storage/get.d.ts +2 -0
- package/dist/cmd/cloud/storage/get.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/get.js +86 -0
- package/dist/cmd/cloud/storage/get.js.map +1 -0
- package/dist/cmd/cloud/storage/index.d.ts +2 -0
- package/dist/cmd/cloud/storage/index.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/index.js +22 -0
- package/dist/cmd/cloud/storage/index.js.map +1 -0
- package/dist/cmd/cloud/storage/list.d.ts +2 -0
- package/dist/cmd/cloud/storage/list.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/list.js +170 -0
- package/dist/cmd/cloud/storage/list.js.map +1 -0
- package/dist/cmd/cloud/storage/upload.d.ts +2 -0
- package/dist/cmd/cloud/storage/upload.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/upload.js +133 -0
- package/dist/cmd/cloud/storage/upload.js.map +1 -0
- package/dist/cmd/cloud/storage/utils.d.ts +18 -0
- package/dist/cmd/cloud/storage/utils.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/utils.js +21 -0
- package/dist/cmd/cloud/storage/utils.js.map +1 -0
- package/dist/cmd/cloud/stream/delete.d.ts +3 -0
- package/dist/cmd/cloud/stream/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/delete.js +42 -0
- package/dist/cmd/cloud/stream/delete.js.map +1 -0
- package/dist/cmd/cloud/stream/get.d.ts +3 -0
- package/dist/cmd/cloud/stream/get.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/get.js +110 -0
- package/dist/cmd/cloud/stream/get.js.map +1 -0
- package/dist/cmd/cloud/stream/index.d.ts +3 -0
- package/dist/cmd/cloud/stream/index.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/index.js +13 -0
- package/dist/cmd/cloud/stream/index.js.map +1 -0
- package/dist/cmd/cloud/stream/list.d.ts +3 -0
- package/dist/cmd/cloud/stream/list.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/list.js +131 -0
- package/dist/cmd/cloud/stream/list.js.map +1 -0
- package/dist/cmd/cloud/stream/util.d.ts +8 -0
- package/dist/cmd/cloud/stream/util.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/util.js +19 -0
- package/dist/cmd/cloud/stream/util.js.map +1 -0
- package/dist/cmd/cloud/vector/delete.d.ts +3 -0
- package/dist/cmd/cloud/vector/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/delete.js +90 -0
- package/dist/cmd/cloud/vector/delete.js.map +1 -0
- package/dist/cmd/cloud/vector/get.d.ts +3 -0
- package/dist/cmd/cloud/vector/get.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/get.js +80 -0
- package/dist/cmd/cloud/vector/get.js.map +1 -0
- package/dist/cmd/cloud/vector/index.d.ts +3 -0
- package/dist/cmd/cloud/vector/index.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/index.js +14 -0
- package/dist/cmd/cloud/vector/index.js.map +1 -0
- package/dist/cmd/cloud/vector/search.d.ts +3 -0
- package/dist/cmd/cloud/vector/search.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/search.js +136 -0
- package/dist/cmd/cloud/vector/search.js.map +1 -0
- package/dist/cmd/cloud/vector/util.d.ts +8 -0
- package/dist/cmd/cloud/vector/util.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/util.js +18 -0
- package/dist/cmd/cloud/vector/util.js.map +1 -0
- package/dist/cmd/dev/agents.d.ts.map +1 -1
- package/dist/cmd/dev/agents.js +3 -2
- package/dist/cmd/dev/agents.js.map +1 -1
- package/dist/cmd/dev/index.js +3 -3
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/index.js +38 -42
- package/dist/cmd/index.js.map +1 -1
- package/dist/schema-parser.d.ts.map +1 -1
- package/dist/schema-parser.js +3 -1
- package/dist/schema-parser.js.map +1 -1
- package/dist/tui.d.ts +12 -2
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +61 -31
- package/dist/tui.js.map +1 -1
- package/dist/utils/date.d.ts +14 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +51 -0
- package/dist/utils/date.js.map +1 -0
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +6 -6
- package/src/cli.ts +15 -1
- package/src/cmd/ai/capabilities/show.ts +11 -4
- package/src/cmd/cloud/agent/get.ts +105 -0
- package/src/cmd/cloud/agent/index.ts +11 -0
- package/src/cmd/cloud/agent/list.ts +107 -0
- package/src/cmd/cloud/agent/schema.ts +25 -0
- package/src/cmd/cloud/apikey/create.ts +114 -0
- package/src/cmd/cloud/apikey/delete.ts +66 -0
- package/src/cmd/cloud/apikey/get.ts +62 -0
- package/src/cmd/cloud/apikey/index.ts +13 -0
- package/src/cmd/cloud/apikey/list.ts +58 -0
- package/src/cmd/cloud/db/create.ts +72 -0
- package/src/cmd/cloud/db/delete.ts +118 -0
- package/src/cmd/cloud/db/get.ts +75 -0
- package/src/cmd/cloud/db/index.ts +14 -0
- package/src/cmd/cloud/db/list.ts +83 -0
- package/src/cmd/cloud/db/sql.ts +125 -0
- package/src/cmd/cloud/deployment/index.ts +2 -0
- package/src/cmd/cloud/deployment/logs.ts +75 -0
- package/src/cmd/cloud/env/get.ts +2 -3
- package/src/cmd/cloud/env/list.ts +1 -2
- package/src/cmd/cloud/index.ts +13 -4
- package/src/cmd/cloud/secret/get.ts +2 -3
- package/src/cmd/cloud/secret/list.ts +1 -2
- package/src/cmd/cloud/session/logs.ts +12 -11
- package/src/cmd/cloud/storage/create.ts +65 -0
- package/src/cmd/cloud/storage/delete.ts +195 -0
- package/src/cmd/cloud/storage/download.ts +154 -0
- package/src/cmd/cloud/storage/get.ts +97 -0
- package/src/cmd/cloud/storage/index.ts +22 -0
- package/src/cmd/cloud/storage/list.ts +197 -0
- package/src/cmd/cloud/storage/upload.ts +150 -0
- package/src/cmd/cloud/storage/utils.ts +26 -0
- package/src/cmd/cloud/stream/delete.ts +49 -0
- package/src/cmd/cloud/stream/get.ts +118 -0
- package/src/cmd/cloud/stream/index.ts +14 -0
- package/src/cmd/cloud/stream/list.ts +146 -0
- package/src/cmd/cloud/stream/util.ts +32 -0
- package/src/cmd/cloud/vector/delete.ts +105 -0
- package/src/cmd/cloud/vector/get.ts +94 -0
- package/src/cmd/cloud/vector/index.ts +15 -0
- package/src/cmd/cloud/vector/search.ts +156 -0
- package/src/cmd/cloud/vector/util.ts +28 -0
- package/src/cmd/dev/agents.ts +4 -3
- package/src/cmd/dev/index.ts +3 -3
- package/src/cmd/index.ts +38 -42
- package/src/schema-parser.ts +3 -1
- package/src/tui.ts +73 -36
- package/src/utils/date.ts +57 -0
- package/src/version.ts +1 -1
- package/dist/cmd/cloud/agents/index.d.ts.map +0 -1
- package/dist/cmd/cloud/agents/index.js +0 -133
- package/dist/cmd/cloud/agents/index.js.map +0 -1
- package/dist/cmd/cloud/resource/add.d.ts +0 -2
- package/dist/cmd/cloud/resource/add.d.ts.map +0 -1
- package/dist/cmd/cloud/resource/add.js +0 -70
- package/dist/cmd/cloud/resource/add.js.map +0 -1
- package/dist/cmd/cloud/resource/delete.d.ts.map +0 -1
- package/dist/cmd/cloud/resource/delete.js +0 -126
- package/dist/cmd/cloud/resource/delete.js.map +0 -1
- package/dist/cmd/cloud/resource/index.d.ts +0 -2
- package/dist/cmd/cloud/resource/index.d.ts.map +0 -1
- package/dist/cmd/cloud/resource/index.js +0 -12
- package/dist/cmd/cloud/resource/index.js.map +0 -1
- package/dist/cmd/cloud/resource/list.d.ts.map +0 -1
- package/dist/cmd/cloud/resource/list.js +0 -100
- package/dist/cmd/cloud/resource/list.js.map +0 -1
- package/src/cmd/cloud/agents/index.ts +0 -148
- package/src/cmd/cloud/resource/add.ts +0 -75
- package/src/cmd/cloud/resource/delete.ts +0 -141
- package/src/cmd/cloud/resource/index.ts +0 -12
- package/src/cmd/cloud/resource/list.ts +0 -105
- /package/dist/cmd/cloud/{resource → agent}/list.d.ts +0 -0
- /package/dist/cmd/cloud/{resource → apikey}/delete.d.ts +0 -0
- /package/dist/cmd/cloud/{agents → apikey}/index.d.ts +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand as createSubcommandHelper } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { apikeyCreate } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { parseExpiresAt } from '../../../utils/date';
|
|
7
|
+
|
|
8
|
+
const APIKeyCreateResponseSchema = z.object({
|
|
9
|
+
id: z.string().describe('the API key id'),
|
|
10
|
+
value: z.string().describe('the API key value'),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const createSubcommand = createSubcommandHelper({
|
|
14
|
+
name: 'create',
|
|
15
|
+
aliases: ['new'],
|
|
16
|
+
description: 'Create a new API key',
|
|
17
|
+
tags: ['destructive', 'creates-resource', 'slow', 'requires-auth'],
|
|
18
|
+
examples: [
|
|
19
|
+
getCommand('cloud apikey create --name "My API Key" --expires-at 1y'),
|
|
20
|
+
getCommand('cloud apikey create --name "Short-lived Key" --expires-at 30d'),
|
|
21
|
+
getCommand(
|
|
22
|
+
'cloud apikey create --name "Production Key" --expires-at 2026-01-01T00:00:00Z --confirm'
|
|
23
|
+
),
|
|
24
|
+
],
|
|
25
|
+
requires: { auth: true, apiClient: true, org: true },
|
|
26
|
+
optional: { project: true },
|
|
27
|
+
idempotent: false,
|
|
28
|
+
schema: {
|
|
29
|
+
options: z.object({
|
|
30
|
+
name: z.string().describe('the name for the API key'),
|
|
31
|
+
'expires-at': z
|
|
32
|
+
.string()
|
|
33
|
+
.describe(
|
|
34
|
+
'expiration date as ISO 8601 (2025-12-31T23:59:59Z) or duration (1h, 2d, 30d, 1y)'
|
|
35
|
+
),
|
|
36
|
+
confirm: z
|
|
37
|
+
.boolean()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe('Skip confirmation prompts (required for non-TTY)'),
|
|
40
|
+
}),
|
|
41
|
+
response: APIKeyCreateResponseSchema,
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
async handler(ctx) {
|
|
45
|
+
const { opts, apiClient, project, orgId, options } = ctx;
|
|
46
|
+
|
|
47
|
+
const skipConfirm = opts?.confirm === true;
|
|
48
|
+
|
|
49
|
+
const projectId = project?.projectId ?? null;
|
|
50
|
+
|
|
51
|
+
// Parse expires-at (duration or ISO date)
|
|
52
|
+
let expiresAt: string;
|
|
53
|
+
try {
|
|
54
|
+
expiresAt = parseExpiresAt(opts['expires-at']);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error instanceof Error) {
|
|
57
|
+
tui.fatal(error.message);
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Require --confirm flag when not in a TTY
|
|
63
|
+
if (!process.stdout.isTTY && !skipConfirm) {
|
|
64
|
+
tui.fatal('--confirm is required in non-interactive mode');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Confirm creation in interactive mode
|
|
68
|
+
if (!skipConfirm) {
|
|
69
|
+
const scope = projectId ? `project ${projectId}` : `organization ${orgId}`;
|
|
70
|
+
const confirmed = await tui.confirm(`Create API key "${opts.name}" for ${scope}?`);
|
|
71
|
+
if (!confirmed) {
|
|
72
|
+
tui.fatal('Operation cancelled');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let result: Awaited<ReturnType<typeof apikeyCreate>>;
|
|
77
|
+
try {
|
|
78
|
+
result = await tui.spinner('Creating API key', () => {
|
|
79
|
+
return apikeyCreate(apiClient, {
|
|
80
|
+
name: opts.name,
|
|
81
|
+
expiresAt: expiresAt,
|
|
82
|
+
projectId: projectId,
|
|
83
|
+
orgId: orgId,
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (error instanceof Error) {
|
|
88
|
+
tui.fatal(error.message);
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!options.json) {
|
|
94
|
+
tui.newline();
|
|
95
|
+
tui.success('API key created successfully!');
|
|
96
|
+
tui.newline();
|
|
97
|
+
tui.warn('Make sure to copy the API key value now. You will not be able to see it again.');
|
|
98
|
+
tui.newline();
|
|
99
|
+
|
|
100
|
+
const rows = [
|
|
101
|
+
{
|
|
102
|
+
ID: result.id,
|
|
103
|
+
Name: opts.name,
|
|
104
|
+
Value: result.value,
|
|
105
|
+
'Expires At': expiresAt,
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
tui.table(rows);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return result;
|
|
113
|
+
},
|
|
114
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { apikeyDelete } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { ErrorCode } from '../../../errors';
|
|
7
|
+
|
|
8
|
+
const APIKeyDeleteResponseSchema = z.object({
|
|
9
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
10
|
+
id: z.string().describe('API key id that was deleted'),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const deleteSubcommand = createSubcommand({
|
|
14
|
+
name: 'delete',
|
|
15
|
+
aliases: ['del', 'rm'],
|
|
16
|
+
description: 'Delete an API key (soft delete)',
|
|
17
|
+
tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth'],
|
|
18
|
+
idempotent: true,
|
|
19
|
+
examples: [
|
|
20
|
+
getCommand('cloud apikey delete <id>'),
|
|
21
|
+
getCommand('cloud apikey del <id>'),
|
|
22
|
+
getCommand('cloud apikey rm <id>'),
|
|
23
|
+
],
|
|
24
|
+
requires: { auth: true, apiClient: true },
|
|
25
|
+
schema: {
|
|
26
|
+
args: z.object({
|
|
27
|
+
id: z.string().describe('the API key id to delete'),
|
|
28
|
+
}),
|
|
29
|
+
response: APIKeyDeleteResponseSchema,
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
async handler(ctx) {
|
|
33
|
+
const { args, apiClient, options } = ctx;
|
|
34
|
+
|
|
35
|
+
let rowsAffected: Awaited<ReturnType<typeof apikeyDelete>>;
|
|
36
|
+
try {
|
|
37
|
+
rowsAffected = await tui.spinner('Deleting API key', () => {
|
|
38
|
+
return apikeyDelete(apiClient, args.id);
|
|
39
|
+
});
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error instanceof Error && error.message.includes('not found')) {
|
|
42
|
+
tui.fatal(
|
|
43
|
+
`API key '${args.id}' not found or is not a custom key`,
|
|
44
|
+
ErrorCode.RESOURCE_NOT_FOUND
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (rowsAffected === 0) {
|
|
51
|
+
tui.fatal(
|
|
52
|
+
`API key '${args.id}' not found or is not a custom key`,
|
|
53
|
+
ErrorCode.RESOURCE_NOT_FOUND
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!options.json) {
|
|
58
|
+
tui.success(`API key '${args.id}' deleted successfully`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
success: true,
|
|
63
|
+
id: args.id,
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { apikeyGet } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { ErrorCode } from '../../../errors';
|
|
7
|
+
|
|
8
|
+
export const getSubcommand = createSubcommand({
|
|
9
|
+
name: 'get',
|
|
10
|
+
description: 'Get a specific API key by id',
|
|
11
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
12
|
+
examples: [getCommand('cloud apikey get <id>')],
|
|
13
|
+
requires: { auth: true, apiClient: true },
|
|
14
|
+
idempotent: true,
|
|
15
|
+
schema: {
|
|
16
|
+
args: z.object({
|
|
17
|
+
id: z.string().describe('the API key id'),
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
async handler(ctx) {
|
|
22
|
+
const { args, apiClient, options } = ctx;
|
|
23
|
+
|
|
24
|
+
let apiKey: Awaited<ReturnType<typeof apikeyGet>>;
|
|
25
|
+
try {
|
|
26
|
+
apiKey = await tui.spinner('Fetching API key', () => {
|
|
27
|
+
return apikeyGet(apiClient, args.id);
|
|
28
|
+
});
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error instanceof Error && error.message.includes('not found')) {
|
|
31
|
+
tui.fatal(`API key '${args.id}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!options.json) {
|
|
37
|
+
if (process.stdout.isTTY) {
|
|
38
|
+
tui.newline();
|
|
39
|
+
tui.success('API Key Details:');
|
|
40
|
+
tui.newline();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const rows = [
|
|
44
|
+
{
|
|
45
|
+
ID: apiKey.id,
|
|
46
|
+
Name: apiKey.name,
|
|
47
|
+
Type: apiKey.type,
|
|
48
|
+
'Organization ID': apiKey.orgId,
|
|
49
|
+
Project: apiKey.project?.name ?? '-',
|
|
50
|
+
'Project ID': apiKey.project?.id ?? '-',
|
|
51
|
+
'Last Used': apiKey.lastUsedAt || 'Never',
|
|
52
|
+
'Expires At': apiKey.expiresAt ?? 'Never',
|
|
53
|
+
'Created At': apiKey.createdAt,
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
tui.table(rows);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return apiKey;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createCommand } from '../../../types';
|
|
2
|
+
import { createSubcommand } from './create';
|
|
3
|
+
import { listSubcommand } from './list';
|
|
4
|
+
import { getSubcommand } from './get';
|
|
5
|
+
import { deleteSubcommand } from './delete';
|
|
6
|
+
|
|
7
|
+
export const command = createCommand({
|
|
8
|
+
name: 'apikey',
|
|
9
|
+
description: 'Manage API keys',
|
|
10
|
+
tags: ['fast', 'requires-auth'],
|
|
11
|
+
subcommands: [createSubcommand, listSubcommand, getSubcommand, deleteSubcommand],
|
|
12
|
+
});
|
|
13
|
+
export default command;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { apikeyList } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
|
|
7
|
+
export const listSubcommand = createSubcommand({
|
|
8
|
+
name: 'list',
|
|
9
|
+
aliases: ['ls'],
|
|
10
|
+
description: 'List all API keys',
|
|
11
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
12
|
+
examples: [getCommand('cloud apikey list'), getCommand('cloud apikey ls')],
|
|
13
|
+
requires: { auth: true, apiClient: true },
|
|
14
|
+
idempotent: true,
|
|
15
|
+
schema: {
|
|
16
|
+
options: z.object({
|
|
17
|
+
orgId: z.string().optional().describe('filter by organization id'),
|
|
18
|
+
projectId: z.string().optional().describe('filter by project id'),
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
async handler(ctx) {
|
|
23
|
+
const { opts, apiClient, options } = ctx;
|
|
24
|
+
|
|
25
|
+
const apiKeys = await tui.spinner('Fetching API keys', () => {
|
|
26
|
+
return apikeyList(apiClient, {
|
|
27
|
+
orgId: opts?.orgId,
|
|
28
|
+
projectId: opts?.projectId,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (!options.json) {
|
|
33
|
+
if (apiKeys.length === 0) {
|
|
34
|
+
tui.info('No API keys found');
|
|
35
|
+
} else {
|
|
36
|
+
if (process.stdout.isTTY) {
|
|
37
|
+
tui.newline();
|
|
38
|
+
tui.success(`API Keys (${apiKeys.length}):`);
|
|
39
|
+
tui.newline();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const rows = apiKeys.map((key) => ({
|
|
43
|
+
ID: key.id,
|
|
44
|
+
Name: key.name,
|
|
45
|
+
Type: key.type,
|
|
46
|
+
Project: key.project?.name ?? '-',
|
|
47
|
+
'Last Used': key.lastUsedAt || 'Never',
|
|
48
|
+
'Expires At': key.expiresAt ?? 'Never',
|
|
49
|
+
'Created At': key.createdAt,
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
tui.table(rows);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return apiKeys;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createResources } from '@agentuity/server';
|
|
3
|
+
import { createSubcommand as defineSubcommand } from '../../../types';
|
|
4
|
+
import * as tui from '../../../tui';
|
|
5
|
+
import { getCatalystAPIClient } from '../../../config';
|
|
6
|
+
import { getCommand } from '../../../command-prefix';
|
|
7
|
+
import { isDryRunMode, outputDryRun } from '../../../explain';
|
|
8
|
+
|
|
9
|
+
export const createSubcommand = defineSubcommand({
|
|
10
|
+
name: 'create',
|
|
11
|
+
aliases: ['new'],
|
|
12
|
+
description: 'Create a new database resource',
|
|
13
|
+
tags: ['mutating', 'creates-resource', 'slow', 'requires-auth', 'requires-deployment'],
|
|
14
|
+
idempotent: false,
|
|
15
|
+
requires: { auth: true, org: true, region: true },
|
|
16
|
+
examples: [
|
|
17
|
+
getCommand('cloud db create'),
|
|
18
|
+
getCommand('cloud db new'),
|
|
19
|
+
getCommand('--dry-run cloud db create'),
|
|
20
|
+
],
|
|
21
|
+
schema: {
|
|
22
|
+
options: z.object({
|
|
23
|
+
name: z.string().optional().describe('Custom database name (optional)'),
|
|
24
|
+
}),
|
|
25
|
+
response: z.object({
|
|
26
|
+
success: z.boolean().describe('Whether creation succeeded'),
|
|
27
|
+
name: z.string().describe('Created database name'),
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
async handler(ctx) {
|
|
32
|
+
const { logger, opts, orgId, region, config, auth, options } = ctx;
|
|
33
|
+
|
|
34
|
+
// Handle dry-run mode
|
|
35
|
+
if (isDryRunMode(options)) {
|
|
36
|
+
const message = opts.name
|
|
37
|
+
? `Would create database with name: ${opts.name} in region: ${region}`
|
|
38
|
+
: `Would create database in region: ${region}`;
|
|
39
|
+
outputDryRun(message, options);
|
|
40
|
+
if (!options.json) {
|
|
41
|
+
tui.newline();
|
|
42
|
+
tui.info('[DRY RUN] Database creation skipped');
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
name: opts.name || 'dry-run-db',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const catalystClient = getCatalystAPIClient(config, logger, auth);
|
|
51
|
+
|
|
52
|
+
const created = await tui.spinner({
|
|
53
|
+
message: `Creating database in ${region}`,
|
|
54
|
+
clearOnSuccess: true,
|
|
55
|
+
callback: async () => {
|
|
56
|
+
return createResources(catalystClient, orgId, region!, [
|
|
57
|
+
{ type: 'db', name: opts.name },
|
|
58
|
+
]);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (created.length > 0) {
|
|
63
|
+
tui.success(`Created database: ${tui.bold(created[0].name)}`);
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
66
|
+
name: created[0].name,
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
tui.fatal('Failed to create database');
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listResources, deleteResources } from '@agentuity/server';
|
|
3
|
+
import enquirer from 'enquirer';
|
|
4
|
+
import { createSubcommand } from '../../../types';
|
|
5
|
+
import * as tui from '../../../tui';
|
|
6
|
+
import { getCatalystAPIClient } from '../../../config';
|
|
7
|
+
import { getCommand } from '../../../command-prefix';
|
|
8
|
+
import { isDryRunMode, outputDryRun } from '../../../explain';
|
|
9
|
+
|
|
10
|
+
export const deleteSubcommand = createSubcommand({
|
|
11
|
+
name: 'delete',
|
|
12
|
+
aliases: ['rm', 'del'],
|
|
13
|
+
description: 'Delete a database resource',
|
|
14
|
+
tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth', 'requires-deployment'],
|
|
15
|
+
idempotent: false,
|
|
16
|
+
requires: { auth: true, org: true, region: true },
|
|
17
|
+
examples: [
|
|
18
|
+
getCommand('cloud db delete my-database'),
|
|
19
|
+
getCommand('cloud db rm my-database'),
|
|
20
|
+
getCommand('cloud db delete'),
|
|
21
|
+
getCommand('--dry-run cloud db delete my-database'),
|
|
22
|
+
],
|
|
23
|
+
schema: {
|
|
24
|
+
args: z.object({
|
|
25
|
+
name: z.string().optional().describe('Database name to delete'),
|
|
26
|
+
}),
|
|
27
|
+
options: z.object({
|
|
28
|
+
confirm: z.boolean().optional().describe('Skip confirmation prompts'),
|
|
29
|
+
}),
|
|
30
|
+
response: z.object({
|
|
31
|
+
success: z.boolean().describe('Whether deletion succeeded'),
|
|
32
|
+
name: z.string().describe('Deleted database name'),
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
async handler(ctx) {
|
|
37
|
+
const { logger, args, opts, config, orgId, region, auth, options } = ctx;
|
|
38
|
+
|
|
39
|
+
const catalystClient = getCatalystAPIClient(config, logger, auth);
|
|
40
|
+
|
|
41
|
+
let dbName = args.name;
|
|
42
|
+
|
|
43
|
+
if (!dbName) {
|
|
44
|
+
const resources = await tui.spinner({
|
|
45
|
+
message: `Fetching databases for ${orgId} in ${region}`,
|
|
46
|
+
clearOnSuccess: true,
|
|
47
|
+
callback: async () => {
|
|
48
|
+
return listResources(catalystClient, orgId, region!);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (resources.db.length === 0) {
|
|
53
|
+
tui.info('No databases found to delete');
|
|
54
|
+
return { success: false, name: '' };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const response = await enquirer.prompt<{ db: string }>({
|
|
58
|
+
type: 'select',
|
|
59
|
+
name: 'db',
|
|
60
|
+
message: 'Select database to delete:',
|
|
61
|
+
choices: resources.db.map((db) => ({
|
|
62
|
+
name: db.name,
|
|
63
|
+
message: db.name,
|
|
64
|
+
})),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
dbName = response.db;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Handle dry-run mode
|
|
71
|
+
if (isDryRunMode(options)) {
|
|
72
|
+
outputDryRun(`Would delete database: ${dbName}`, options);
|
|
73
|
+
if (!options.json) {
|
|
74
|
+
tui.newline();
|
|
75
|
+
tui.info('[DRY RUN] Database deletion skipped');
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
success: false,
|
|
79
|
+
name: dbName,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!opts.confirm) {
|
|
84
|
+
tui.warning(`You are about to delete database: ${tui.bold(dbName)}`);
|
|
85
|
+
|
|
86
|
+
const confirm = await enquirer.prompt<{ confirm: boolean }>({
|
|
87
|
+
type: 'confirm',
|
|
88
|
+
name: 'confirm',
|
|
89
|
+
message: 'Are you sure you want to delete this database?',
|
|
90
|
+
initial: false,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (!confirm.confirm) {
|
|
94
|
+
tui.info('Deletion cancelled');
|
|
95
|
+
return { success: false, name: dbName };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const deleted = await tui.spinner({
|
|
100
|
+
message: `Deleting database ${dbName}`,
|
|
101
|
+
clearOnSuccess: true,
|
|
102
|
+
callback: async () => {
|
|
103
|
+
return deleteResources(catalystClient, orgId, region!, [{ type: 'db', name: dbName }]);
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
if (deleted.length > 0) {
|
|
108
|
+
tui.success(`Deleted database: ${tui.bold(deleted[0])}`);
|
|
109
|
+
return {
|
|
110
|
+
success: true,
|
|
111
|
+
name: deleted[0],
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
tui.error('Failed to delete database');
|
|
115
|
+
return { success: false, name: dbName };
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listResources } from '@agentuity/server';
|
|
3
|
+
import { createSubcommand } from '../../../types';
|
|
4
|
+
import * as tui from '../../../tui';
|
|
5
|
+
import { getCatalystAPIClient } from '../../../config';
|
|
6
|
+
import { getCommand } from '../../../command-prefix';
|
|
7
|
+
import { ErrorCode } from '../../../errors';
|
|
8
|
+
|
|
9
|
+
const DBGetResponseSchema = z.object({
|
|
10
|
+
name: z.string().describe('Database name'),
|
|
11
|
+
url: z.string().optional().describe('Database connection URL'),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const getSubcommand = createSubcommand({
|
|
15
|
+
name: 'get',
|
|
16
|
+
aliases: ['show'],
|
|
17
|
+
description: 'Show details about a specific database',
|
|
18
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
19
|
+
requires: { auth: true, org: true, region: true },
|
|
20
|
+
idempotent: true,
|
|
21
|
+
examples: [
|
|
22
|
+
`${getCommand('cloud db get')} my-database`,
|
|
23
|
+
`${getCommand('cloud db show')} my-database`,
|
|
24
|
+
`${getCommand('cloud db get')} my-database --show-credentials`,
|
|
25
|
+
],
|
|
26
|
+
schema: {
|
|
27
|
+
args: z.object({
|
|
28
|
+
name: z.string().describe('Database name'),
|
|
29
|
+
}),
|
|
30
|
+
options: z.object({
|
|
31
|
+
showCredentials: z
|
|
32
|
+
.boolean()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe('Show credentials in plain text (default: masked in terminal, unmasked in JSON)'),
|
|
35
|
+
}),
|
|
36
|
+
response: DBGetResponseSchema,
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
async handler(ctx) {
|
|
40
|
+
const { logger, args, opts, options, orgId, region, config, auth } = ctx;
|
|
41
|
+
|
|
42
|
+
const catalystClient = getCatalystAPIClient(config, logger, auth);
|
|
43
|
+
|
|
44
|
+
const resources = await tui.spinner({
|
|
45
|
+
message: `Fetching database ${args.name}`,
|
|
46
|
+
clearOnSuccess: true,
|
|
47
|
+
callback: async () => {
|
|
48
|
+
return listResources(catalystClient, orgId, region);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const db = resources.db.find((d) => d.name === args.name);
|
|
53
|
+
|
|
54
|
+
if (!db) {
|
|
55
|
+
tui.fatal(`Database '${args.name}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Mask credentials in terminal output by default, unless --show-credentials is passed
|
|
59
|
+
const shouldShowCredentials = opts.showCredentials === true;
|
|
60
|
+
const shouldMask = !options.json && !shouldShowCredentials;
|
|
61
|
+
|
|
62
|
+
if (!options.json) {
|
|
63
|
+
console.log(tui.bold('Name: ') + db.name);
|
|
64
|
+
if (db.url) {
|
|
65
|
+
const displayUrl = shouldMask ? tui.maskSecret(db.url) : db.url;
|
|
66
|
+
console.log(tui.bold('URL: ') + displayUrl);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
name: db.name,
|
|
72
|
+
url: db.url ?? undefined,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createCommand } from '../../../types';
|
|
2
|
+
import { createSubcommand } from './create';
|
|
3
|
+
import { listSubcommand } from './list';
|
|
4
|
+
import { deleteSubcommand } from './delete';
|
|
5
|
+
import { getSubcommand } from './get';
|
|
6
|
+
import { sqlSubcommand } from './sql';
|
|
7
|
+
|
|
8
|
+
export const dbCommand = createCommand({
|
|
9
|
+
name: 'db',
|
|
10
|
+
aliases: ['database'],
|
|
11
|
+
description: 'Manage database resources',
|
|
12
|
+
tags: ['slow', 'requires-auth', 'requires-deployment'],
|
|
13
|
+
subcommands: [createSubcommand, listSubcommand, getSubcommand, deleteSubcommand, sqlSubcommand],
|
|
14
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listResources } from '@agentuity/server';
|
|
3
|
+
import { createSubcommand } from '../../../types';
|
|
4
|
+
import * as tui from '../../../tui';
|
|
5
|
+
import { getCatalystAPIClient } from '../../../config';
|
|
6
|
+
import { getCommand } from '../../../command-prefix';
|
|
7
|
+
|
|
8
|
+
const DBListResponseSchema = z.object({
|
|
9
|
+
databases: z
|
|
10
|
+
.array(
|
|
11
|
+
z.object({
|
|
12
|
+
name: z.string().describe('Database name'),
|
|
13
|
+
url: z.string().optional().describe('Database connection URL'),
|
|
14
|
+
})
|
|
15
|
+
)
|
|
16
|
+
.describe('List of database resources'),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const listSubcommand = createSubcommand({
|
|
20
|
+
name: 'list',
|
|
21
|
+
aliases: ['ls'],
|
|
22
|
+
description: 'List database resources',
|
|
23
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
24
|
+
requires: { auth: true, org: true, region: true },
|
|
25
|
+
idempotent: true,
|
|
26
|
+
examples: [
|
|
27
|
+
getCommand('cloud db list'),
|
|
28
|
+
getCommand('--json cloud db list'),
|
|
29
|
+
getCommand('cloud db ls'),
|
|
30
|
+
getCommand('cloud db list --show-credentials'),
|
|
31
|
+
],
|
|
32
|
+
schema: {
|
|
33
|
+
options: z.object({
|
|
34
|
+
showCredentials: z
|
|
35
|
+
.boolean()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe('Show credentials in plain text (default: masked in terminal, unmasked in JSON)'),
|
|
38
|
+
}),
|
|
39
|
+
response: DBListResponseSchema,
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
async handler(ctx) {
|
|
43
|
+
const { logger, opts, options, orgId, region, config, auth } = ctx;
|
|
44
|
+
|
|
45
|
+
const catalystClient = getCatalystAPIClient(config, logger, auth);
|
|
46
|
+
|
|
47
|
+
const resources = await tui.spinner({
|
|
48
|
+
message: `Fetching databases for ${orgId} in ${region}`,
|
|
49
|
+
clearOnSuccess: true,
|
|
50
|
+
callback: async () => {
|
|
51
|
+
return listResources(catalystClient, orgId, region);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Mask credentials in terminal output by default, unless --show-credentials is passed
|
|
56
|
+
const shouldShowCredentials = opts.showCredentials === true;
|
|
57
|
+
const shouldMask = !options.json && !shouldShowCredentials;
|
|
58
|
+
|
|
59
|
+
if (!options.json) {
|
|
60
|
+
if (resources.db.length === 0) {
|
|
61
|
+
tui.info('No databases found');
|
|
62
|
+
} else {
|
|
63
|
+
tui.info(tui.bold('Databases'));
|
|
64
|
+
tui.newline();
|
|
65
|
+
for (const db of resources.db) {
|
|
66
|
+
console.log(tui.bold(db.name));
|
|
67
|
+
if (db.url) {
|
|
68
|
+
const displayUrl = shouldMask ? tui.maskSecret(db.url) : db.url;
|
|
69
|
+
console.log(` URL: ${tui.muted(displayUrl)}`);
|
|
70
|
+
}
|
|
71
|
+
tui.newline();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
databases: resources.db.map((db) => ({
|
|
78
|
+
name: db.name,
|
|
79
|
+
url: db.url ?? undefined,
|
|
80
|
+
})),
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
});
|