@timbrix/cli 0.1.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.
Files changed (104) hide show
  1. package/README.md +319 -0
  2. package/bin/run.js +5 -0
  3. package/dist/commands/api-keys/create.d.ts +12 -0
  4. package/dist/commands/api-keys/create.d.ts.map +1 -0
  5. package/dist/commands/api-keys/create.js +65 -0
  6. package/dist/commands/api-keys/delete.d.ts +14 -0
  7. package/dist/commands/api-keys/delete.d.ts.map +1 -0
  8. package/dist/commands/api-keys/delete.js +55 -0
  9. package/dist/commands/api-keys/get.d.ts +13 -0
  10. package/dist/commands/api-keys/get.d.ts.map +1 -0
  11. package/dist/commands/api-keys/get.js +46 -0
  12. package/dist/commands/api-keys/list.d.ts +10 -0
  13. package/dist/commands/api-keys/list.d.ts.map +1 -0
  14. package/dist/commands/api-keys/list.js +61 -0
  15. package/dist/commands/login.d.ts +11 -0
  16. package/dist/commands/login.d.ts.map +1 -0
  17. package/dist/commands/login.js +67 -0
  18. package/dist/commands/logout.d.ts +7 -0
  19. package/dist/commands/logout.d.ts.map +1 -0
  20. package/dist/commands/logout.js +19 -0
  21. package/dist/commands/oauth-apps/create.d.ts +12 -0
  22. package/dist/commands/oauth-apps/create.d.ts.map +1 -0
  23. package/dist/commands/oauth-apps/create.js +96 -0
  24. package/dist/commands/oauth-apps/delete.d.ts +13 -0
  25. package/dist/commands/oauth-apps/delete.d.ts.map +1 -0
  26. package/dist/commands/oauth-apps/delete.js +49 -0
  27. package/dist/commands/oauth-apps/get.d.ts +10 -0
  28. package/dist/commands/oauth-apps/get.d.ts.map +1 -0
  29. package/dist/commands/oauth-apps/get.js +41 -0
  30. package/dist/commands/oauth-apps/list.d.ts +10 -0
  31. package/dist/commands/oauth-apps/list.d.ts.map +1 -0
  32. package/dist/commands/oauth-apps/list.js +55 -0
  33. package/dist/commands/organizations/create.d.ts +11 -0
  34. package/dist/commands/organizations/create.d.ts.map +1 -0
  35. package/dist/commands/organizations/create.js +69 -0
  36. package/dist/commands/organizations/delete.d.ts +13 -0
  37. package/dist/commands/organizations/delete.d.ts.map +1 -0
  38. package/dist/commands/organizations/delete.js +50 -0
  39. package/dist/commands/organizations/get.d.ts +10 -0
  40. package/dist/commands/organizations/get.d.ts.map +1 -0
  41. package/dist/commands/organizations/get.js +46 -0
  42. package/dist/commands/organizations/list.d.ts +7 -0
  43. package/dist/commands/organizations/list.d.ts.map +1 -0
  44. package/dist/commands/organizations/list.js +40 -0
  45. package/dist/commands/products/create.d.ts +17 -0
  46. package/dist/commands/products/create.d.ts.map +1 -0
  47. package/dist/commands/products/create.js +112 -0
  48. package/dist/commands/products/delete.d.ts +12 -0
  49. package/dist/commands/products/delete.d.ts.map +1 -0
  50. package/dist/commands/products/delete.js +52 -0
  51. package/dist/commands/products/get.d.ts +11 -0
  52. package/dist/commands/products/get.d.ts.map +1 -0
  53. package/dist/commands/products/get.js +54 -0
  54. package/dist/commands/products/list.d.ts +13 -0
  55. package/dist/commands/products/list.d.ts.map +1 -0
  56. package/dist/commands/products/list.js +75 -0
  57. package/dist/commands/products/update.d.ts +18 -0
  58. package/dist/commands/products/update.d.ts.map +1 -0
  59. package/dist/commands/products/update.js +86 -0
  60. package/dist/commands/update.d.ts +16 -0
  61. package/dist/commands/update.d.ts.map +1 -0
  62. package/dist/commands/update.js +91 -0
  63. package/dist/commands/webhooks/create.d.ts +11 -0
  64. package/dist/commands/webhooks/create.d.ts.map +1 -0
  65. package/dist/commands/webhooks/create.js +120 -0
  66. package/dist/commands/webhooks/delete.d.ts +14 -0
  67. package/dist/commands/webhooks/delete.d.ts.map +1 -0
  68. package/dist/commands/webhooks/delete.js +55 -0
  69. package/dist/commands/webhooks/get.d.ts +13 -0
  70. package/dist/commands/webhooks/get.d.ts.map +1 -0
  71. package/dist/commands/webhooks/get.js +45 -0
  72. package/dist/commands/webhooks/list.d.ts +10 -0
  73. package/dist/commands/webhooks/list.d.ts.map +1 -0
  74. package/dist/commands/webhooks/list.js +49 -0
  75. package/dist/config/auth.d.ts +31 -0
  76. package/dist/config/auth.d.ts.map +1 -0
  77. package/dist/config/auth.js +57 -0
  78. package/dist/help.d.ts +16 -0
  79. package/dist/help.d.ts.map +1 -0
  80. package/dist/help.js +22 -0
  81. package/dist/hooks/init/update-check.d.ts +8 -0
  82. package/dist/hooks/init/update-check.d.ts.map +1 -0
  83. package/dist/hooks/init/update-check.js +9 -0
  84. package/dist/index.d.ts +2 -0
  85. package/dist/index.d.ts.map +1 -0
  86. package/dist/index.js +1 -0
  87. package/dist/utils/client.d.ts +6 -0
  88. package/dist/utils/client.d.ts.map +1 -0
  89. package/dist/utils/client.js +18 -0
  90. package/dist/utils/error.d.ts +6 -0
  91. package/dist/utils/error.d.ts.map +1 -0
  92. package/dist/utils/error.js +15 -0
  93. package/dist/utils/logo.d.ts +14 -0
  94. package/dist/utils/logo.d.ts.map +1 -0
  95. package/dist/utils/logo.js +27 -0
  96. package/dist/utils/table.d.ts +6 -0
  97. package/dist/utils/table.d.ts.map +1 -0
  98. package/dist/utils/table.js +30 -0
  99. package/dist/utils/update-notifier.d.ts +13 -0
  100. package/dist/utils/update-notifier.d.ts.map +1 -0
  101. package/dist/utils/update-notifier.js +19 -0
  102. package/oclif.manifest.json +1054 -0
  103. package/package.json +71 -0
  104. package/theme.json +27 -0
package/README.md ADDED
@@ -0,0 +1,319 @@
1
+ # @timbrix/cli
2
+
3
+ ```
4
+ _____ _ _ _
5
+ |_ _(_)_ __ ___ | |__ _ __(_)_ __
6
+ | | | | '_ ` _ \| '_ \| '__| \ \/ /
7
+ | | | | | | | | | |_) | | | |> <
8
+ |_| |_|_| |_| |_|_.__/|_| |_/_/\_\
9
+ ```
10
+
11
+ Official CLI tool for the Timbrix API.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install -g @timbrix/cli
17
+ # or
18
+ pnpm add -g @timbrix/cli
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ # Login to your Timbrix account
25
+ timbrix login
26
+
27
+ # List your organizations
28
+ timbrix organizations list
29
+
30
+ # Create a webhook
31
+ timbrix webhooks create --org <organization-id>
32
+
33
+ # Logout
34
+ timbrix logout
35
+ ```
36
+
37
+ ## Authentication
38
+
39
+ ### Login
40
+
41
+ ```bash
42
+ timbrix login
43
+ # Or provide email directly
44
+ timbrix login --email user@example.com
45
+ ```
46
+
47
+ Credentials are saved to `~/.timbrix/config.json`
48
+
49
+ ### Logout
50
+
51
+ ```bash
52
+ timbrix logout
53
+ ```
54
+
55
+ ## Commands
56
+
57
+ ### Organizations
58
+
59
+ ```bash
60
+ # List all organizations
61
+ timbrix organizations list
62
+
63
+ # Get organization details
64
+ timbrix organizations get <slug>
65
+
66
+ # Create organization
67
+ timbrix organizations create
68
+ timbrix organizations create --name "Acme Corp" --slug acme-corp
69
+
70
+ # Delete organization (PERMANENT)
71
+ timbrix organizations delete <slug>
72
+ timbrix organizations delete <slug> --force # Skip confirmation
73
+ ```
74
+
75
+ ### Webhooks
76
+
77
+ ```bash
78
+ # List webhooks
79
+ timbrix webhooks list --org <organization-id>
80
+
81
+ # Get webhook details
82
+ timbrix webhooks get <webhook-id> --org <organization-id>
83
+
84
+ # Create webhook
85
+ timbrix webhooks create --org <organization-id>
86
+ timbrix webhooks create --org <organization-id> --url https://example.com/webhook
87
+
88
+ # Delete webhook (PERMANENT)
89
+ timbrix webhooks delete <webhook-id> --org <organization-id>
90
+ timbrix webhooks delete <webhook-id> --org <organization-id> --force
91
+ ```
92
+
93
+ ### API Keys
94
+
95
+ ```bash
96
+ # List API keys
97
+ timbrix api-keys list --org <organization-id>
98
+
99
+ # Get API key details
100
+ timbrix api-keys get <api-key-id> --org <organization-id>
101
+
102
+ # Create API key
103
+ timbrix api-keys create --org <organization-id>
104
+ timbrix api-keys create --org <organization-id> --name "Production Key"
105
+ timbrix api-keys create --org <organization-id> --name "Staging Key" --expires 2025-12-31T23:59:59Z
106
+
107
+ # Revoke API key (PERMANENT)
108
+ timbrix api-keys delete <api-key-id> --org <organization-id>
109
+ timbrix api-keys delete <api-key-id> --org <organization-id> --force
110
+ ```
111
+
112
+ ## Global Commands
113
+
114
+ ```bash
115
+ # Show help for any command
116
+ timbrix --help
117
+ timbrix <command> --help
118
+
119
+ # Show CLI version
120
+ timbrix --version
121
+
122
+ # Update to latest version
123
+ timbrix update
124
+ ```
125
+
126
+ ## Examples
127
+
128
+ ### Complete Workflow
129
+
130
+ ```bash
131
+ # 1. Login
132
+ timbrix login
133
+
134
+ # 2. Create organization
135
+ timbrix organizations create --name "My Company" --slug my-company
136
+
137
+ # 3. Get organization ID
138
+ timbrix organizations get my-company
139
+ # Copy the ID from output
140
+
141
+ # 4. Create webhook
142
+ timbrix webhooks create --org <org-id> --url https://api.mycompany.com/webhooks
143
+
144
+ # 5. Create API key for external services
145
+ timbrix api-keys create --org <org-id> --name "Production API Key"
146
+
147
+ # 6. List all resources
148
+ timbrix organizations list
149
+ timbrix webhooks list --org <org-id>
150
+ timbrix api-keys list --org <org-id>
151
+ ```
152
+
153
+ ### Using in CI/CD
154
+
155
+ ```bash
156
+ # Set credentials as environment variable in CI
157
+ export TIMBRIX_TOKEN="your-token"
158
+
159
+ # Or login programmatically (if your API supports it)
160
+ echo "password" | timbrix login --email ci@example.com
161
+
162
+ # Create API key for deployment
163
+ timbrix api-keys create --org $ORG_ID --name "CI/CD Key"
164
+ ```
165
+
166
+ ## Configuration
167
+
168
+ Configuration is stored in `~/.timbrix/config.json`:
169
+
170
+ ```json
171
+ {
172
+ "bearerToken": "eyJhbGc...",
173
+ "email": "user@example.com",
174
+ "baseUrl": "http://localhost:3001/api"
175
+ }
176
+ ```
177
+
178
+ To use a different API URL:
179
+
180
+ ```bash
181
+ timbrix login --base-url https://api.timbrix.com
182
+ ```
183
+
184
+ ### Theme Customization
185
+
186
+ The CLI comes with a modern color theme. Users can customize it by creating a `theme.json` file in `~/.timbrix/`:
187
+
188
+ ```json
189
+ {
190
+ "bin": "cyan",
191
+ "command": "greenBright",
192
+ "flag": "blueBright",
193
+ "flagRequired": "redBright"
194
+ }
195
+ ```
196
+
197
+ To disable the theme:
198
+
199
+ ```bash
200
+ TIMBRIX_DISABLE_THEME=1 timbrix --help
201
+ ```
202
+
203
+ ### Update Notifications
204
+
205
+ The CLI automatically checks for updates once per week and notifies you when a new version is available.
206
+
207
+ **Update manually:**
208
+
209
+ ```bash
210
+ # Check and update to latest version
211
+ timbrix update
212
+
213
+ # The update command will:
214
+ # - Check for new versions
215
+ # - Detect your package manager (pnpm, yarn, or npm)
216
+ # - Update automatically to the latest version
217
+ ```
218
+
219
+ **Disable notifications:**
220
+
221
+ ```bash
222
+ NO_UPDATE_NOTIFIER=1 timbrix login
223
+ ```
224
+
225
+ ## Features
226
+
227
+ ### 🎨 Modern UI
228
+
229
+ - **ASCII Logo**: Beautiful Timbrix logo displayed on help and login commands
230
+ - **Custom Theme**: Vibrant color scheme with cyan, green, and blue highlights
231
+ - **Syntax Highlighting**: Color-coded JSON output for better readability
232
+
233
+ ### 🔔 Update Notifications
234
+
235
+ The CLI automatically checks for new versions once per week and notifies you when an update is available. Checks are non-blocking and respect CI environments.
236
+
237
+ ### 🛠️ Built with
238
+
239
+ - **oclif**: Modern CLI framework
240
+ - **TypeScript**: Type-safe development
241
+ - **chalk**: Terminal colors
242
+ - **inquirer**: Interactive prompts
243
+ - **ora**: Elegant spinners
244
+ - **cli-table3**: Beautiful tables
245
+
246
+ ## Architecture
247
+
248
+ ```
249
+ src/
250
+ ├── commands/ # CLI commands
251
+ │ ├── login.ts # Authentication
252
+ │ ├── logout.ts
253
+ │ ├── organizations/ # Organization management
254
+ │ ├── webhooks/ # Webhook management
255
+ │ └── api-keys/ # API key management
256
+ ├── config/
257
+ │ └── auth.ts # Auth configuration manager
258
+ ├── utils/
259
+ │ ├── logo.ts # ASCII logo
260
+ │ ├── table.ts # Table formatting
261
+ │ ├── client.ts # API client
262
+ │ └── update-notifier.ts
263
+ ├── hooks/
264
+ │ └── init/
265
+ │ └── update-check.ts # Update check hook
266
+ └── help.ts # Custom help class
267
+ ```
268
+
269
+ ## Development
270
+
271
+ ```bash
272
+ # Install dependencies
273
+ pnpm install
274
+
275
+ # Build
276
+ pnpm build
277
+
278
+ # Run locally with hot-reload
279
+ pnpm dev
280
+
281
+ # Link for local testing
282
+ pnpm link --global
283
+
284
+ # Type check
285
+ pnpm check-types
286
+
287
+ # Lint
288
+ pnpm lint
289
+ ```
290
+
291
+ ## Troubleshooting
292
+
293
+ ### Authentication Error
294
+
295
+ ```bash
296
+ Error: Not authenticated. Please run 'timbrix login' first.
297
+ ```
298
+
299
+ **Solution**: Run `timbrix login` to authenticate.
300
+
301
+ ### API Connection Error
302
+
303
+ ```bash
304
+ Failed to fetch organizations: connect ECONNREFUSED
305
+ ```
306
+
307
+ **Solution**: Check that your API is running and the base URL is correct.
308
+
309
+ ### Invalid Token
310
+
311
+ ```bash
312
+ Authentication failed: 401 Unauthorized
313
+ ```
314
+
315
+ **Solution**: Your token may have expired. Run `timbrix logout` then `timbrix login` again.
316
+
317
+ ## License
318
+
319
+ MIT
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execute } from '@oclif/core'
4
+
5
+ await execute({development: false, dir: import.meta.url})
@@ -0,0 +1,12 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class ApiKeysCreate extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ org: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ expires: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/api-keys/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAM5C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,OAAgB,WAAW,SAAyB;IAEpD,OAAgB,QAAQ,WAGvB;IAED,OAAgB,KAAK;;;;MAepB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAmDlC"}
@@ -0,0 +1,65 @@
1
+ import { input } from "@inquirer/prompts";
2
+ import { Command, Flags } from "@oclif/core";
3
+ import chalk from "chalk";
4
+ import ora from "ora";
5
+ import { createClient } from "../../utils/client.js";
6
+ import { getErrorMessage } from "../../utils/error.js";
7
+ export default class ApiKeysCreate extends Command {
8
+ static description = "Create a new API key";
9
+ static examples = [
10
+ "<%= config.bin %> <%= command.id %> --org acme-corp-id",
11
+ "<%= config.bin %> <%= command.id %> --org acme-corp-id --name 'Production Key'",
12
+ ];
13
+ static flags = {
14
+ org: Flags.string({
15
+ char: "o",
16
+ description: "Organization ID",
17
+ required: true,
18
+ }),
19
+ name: Flags.string({
20
+ char: "n",
21
+ description: "API key name",
22
+ }),
23
+ expires: Flags.string({
24
+ char: "e",
25
+ description: "Expiration date (ISO 8601 format, e.g., 2025-12-31T23:59:59Z)",
26
+ }),
27
+ };
28
+ async run() {
29
+ const { flags } = await this.parse(ApiKeysCreate);
30
+ const client = createClient();
31
+ try {
32
+ // Get API key name
33
+ const name = flags.name ||
34
+ (await input({
35
+ message: "API key name:",
36
+ validate: (value) => {
37
+ if (value.length < 3) {
38
+ return "Name must be at least 3 characters";
39
+ }
40
+ return true;
41
+ },
42
+ }));
43
+ const spinner = ora("Creating API key...").start();
44
+ const apiKey = await client.apiKeys.create(flags.org, {
45
+ name,
46
+ expiresAt: flags.expires,
47
+ });
48
+ spinner.succeed(chalk.green("✓ API key created successfully!"));
49
+ this.log(chalk.gray("\nAPI Key Details:"));
50
+ this.log(` ${chalk.bold("ID:")} ${apiKey.apiKey.id}`);
51
+ this.log(` ${chalk.bold("Name:")} ${apiKey.apiKey.name}`);
52
+ this.log(` ${chalk.bold("Key:")} ${apiKey.plainKey}`);
53
+ if (apiKey.apiKey.expiresAt) {
54
+ this.log(` ${chalk.bold("Expires:")} ${new Date(apiKey.apiKey.expiresAt).toLocaleString()}`);
55
+ }
56
+ else {
57
+ this.log(` ${chalk.bold("Expires:")} Never`);
58
+ }
59
+ this.log(chalk.yellow("\n⚠️ Save these credentials - they won't be shown again!"));
60
+ }
61
+ catch (error) {
62
+ this.error(chalk.red(`Failed to create API key: ${getErrorMessage(error)}`));
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,14 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class ApiKeysDelete extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ org: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=delete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/api-keys/delete.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,OAAO,EAAS,MAAM,aAAa,CAAA;AAMlD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,OAAgB,WAAW,SAAkC;IAE7D,OAAgB,QAAQ,WAGvB;IAED,OAAgB,IAAI;;MAKnB;IAED,OAAgB,KAAK;;;MAWpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAgClC"}
@@ -0,0 +1,55 @@
1
+ import { confirm } from "@inquirer/prompts";
2
+ import { Args, Command, Flags } from "@oclif/core";
3
+ import chalk from "chalk";
4
+ import ora from "ora";
5
+ import { createClient } from "../../utils/client.js";
6
+ import { getErrorMessage } from "../../utils/error.js";
7
+ export default class ApiKeysDelete extends Command {
8
+ static description = "Revoke an API key (PERMANENT)";
9
+ static examples = [
10
+ "<%= config.bin %> <%= command.id %> api-key-id --org acme-corp-id",
11
+ "<%= config.bin %> <%= command.id %> api-key-id --org acme-corp-id --force",
12
+ ];
13
+ static args = {
14
+ id: Args.string({
15
+ description: "API key ID",
16
+ required: true,
17
+ }),
18
+ };
19
+ static flags = {
20
+ org: Flags.string({
21
+ char: "o",
22
+ description: "Organization ID",
23
+ required: true,
24
+ }),
25
+ force: Flags.boolean({
26
+ char: "f",
27
+ description: "Skip confirmation prompt",
28
+ default: false,
29
+ }),
30
+ };
31
+ async run() {
32
+ const { args, flags } = await this.parse(ApiKeysDelete);
33
+ const client = createClient();
34
+ try {
35
+ // Confirm deletion
36
+ if (!flags.force) {
37
+ const confirmed = await confirm({
38
+ message: chalk.yellow(`Are you sure you want to revoke this API key? This action cannot be undone.`),
39
+ default: false,
40
+ });
41
+ if (!confirmed) {
42
+ this.log(chalk.gray("Revocation cancelled"));
43
+ return;
44
+ }
45
+ }
46
+ const spinner = ora("Revoking API key...").start();
47
+ await client.apiKeys.delete(flags.org, args.id);
48
+ spinner.succeed(chalk.green("✓ API key revoked successfully!"));
49
+ this.log(chalk.gray("\nThe API key will stop working immediately."));
50
+ }
51
+ catch (error) {
52
+ this.error(chalk.red(`Failed to revoke API key: ${getErrorMessage(error)}`));
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,13 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class ApiKeysGet extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ org: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=get.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/api-keys/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,aAAa,CAAA;AAMlD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,OAAO;IAC7C,OAAgB,WAAW,SAAwB;IAEnD,OAAgB,QAAQ,WAEvB;IAED,OAAgB,IAAI;;MAKnB;IAED,OAAgB,KAAK;;MAMpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAgClC"}
@@ -0,0 +1,46 @@
1
+ import { Command, Args, Flags } from "@oclif/core";
2
+ import { createClient } from "../../utils/client.js";
3
+ import { getErrorMessage } from "../../utils/error.js";
4
+ import chalk from "chalk";
5
+ import ora from "ora";
6
+ export default class ApiKeysGet extends Command {
7
+ static description = "Get API key details";
8
+ static examples = [
9
+ "<%= config.bin %> <%= command.id %> api-key-id --org acme-corp-id",
10
+ ];
11
+ static args = {
12
+ id: Args.string({
13
+ description: "API key ID",
14
+ required: true,
15
+ }),
16
+ };
17
+ static flags = {
18
+ org: Flags.string({
19
+ char: "o",
20
+ description: "Organization ID",
21
+ required: true,
22
+ }),
23
+ };
24
+ async run() {
25
+ const { args, flags } = await this.parse(ApiKeysGet);
26
+ const client = createClient();
27
+ const spinner = ora("Fetching API key...").start();
28
+ try {
29
+ const apiKey = await client.apiKeys.get(flags.org, args.id);
30
+ spinner.stop();
31
+ this.log(chalk.cyan.bold("\nAPI Key Details:"));
32
+ this.log(` ${chalk.bold("ID:")} ${apiKey.id}`);
33
+ this.log(` ${chalk.bold("Organization ID:")} ${apiKey.organizationId}`);
34
+ this.log(` ${chalk.bold("Name:")} ${apiKey.name}`);
35
+ this.log(` ${chalk.bold("Key:")} ${apiKey.keyPreview}`);
36
+ this.log(` ${chalk.bold("Last Used:")} ${apiKey.lastUsedAt ? new Date(apiKey.lastUsedAt).toLocaleString() : chalk.gray("Never")}`);
37
+ this.log(` ${chalk.bold("Expires:")} ${apiKey.expiresAt ? new Date(apiKey.expiresAt).toLocaleString() : chalk.gray("Never")}`);
38
+ this.log(` ${chalk.bold("Created:")} ${new Date(apiKey.createdAt).toLocaleString()}`);
39
+ this.log(` ${chalk.bold("Updated:")} ${new Date(apiKey.updatedAt).toLocaleString()}`);
40
+ }
41
+ catch (error) {
42
+ spinner.fail(chalk.red("Failed to fetch API key"));
43
+ this.error(getErrorMessage(error));
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class ApiKeysList extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ org: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/api-keys/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAQ5C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,OAAO;IAC9C,OAAgB,WAAW,SAA0C;IAErE,OAAgB,QAAQ,WAEvB;IAED,OAAgB,KAAK;;MAMpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAmDlC"}
@@ -0,0 +1,61 @@
1
+ import { Command, Flags } from "@oclif/core";
2
+ import chalk from "chalk";
3
+ import ora from "ora";
4
+ import { createClient } from "../../utils/client.js";
5
+ import { getErrorMessage } from "../../utils/error.js";
6
+ import { createTable } from "../../utils/table.js";
7
+ export default class ApiKeysList extends Command {
8
+ static description = "List all API keys for an organization";
9
+ static examples = [
10
+ "<%= config.bin %> <%= command.id %> --org acme-corp-id",
11
+ ];
12
+ static flags = {
13
+ org: Flags.string({
14
+ char: "o",
15
+ description: "Organization ID",
16
+ required: true,
17
+ }),
18
+ };
19
+ async run() {
20
+ const { flags } = await this.parse(ApiKeysList);
21
+ const client = createClient();
22
+ const spinner = ora("Fetching API keys...").start();
23
+ try {
24
+ const apiKeys = await client.apiKeys.list(flags.org);
25
+ spinner.stop();
26
+ if (apiKeys.length === 0) {
27
+ this.log(chalk.yellow("No API keys found"));
28
+ this.log(chalk.gray(`\nCreate an API key with: timbrix api-keys create --org ${flags.org}`));
29
+ return;
30
+ }
31
+ const table = createTable([
32
+ "ID",
33
+ "Name",
34
+ "Key",
35
+ "Last Used",
36
+ "Expires",
37
+ "Created",
38
+ ]);
39
+ apiKeys.forEach((key) => {
40
+ table.push([
41
+ key.id.substring(0, 8) + "...",
42
+ key.name,
43
+ key.keyPreview,
44
+ key.lastUsedAt
45
+ ? new Date(key.lastUsedAt).toLocaleDateString()
46
+ : chalk.gray("Never"),
47
+ key.expiresAt
48
+ ? new Date(key.expiresAt).toLocaleDateString()
49
+ : chalk.gray("Never"),
50
+ new Date(key.createdAt).toLocaleDateString(),
51
+ ]);
52
+ });
53
+ this.log(table.toString());
54
+ this.log(chalk.gray(`\nTotal: ${apiKeys.length} API key(s)`));
55
+ }
56
+ catch (error) {
57
+ spinner.fail(chalk.red("Failed to fetch API keys"));
58
+ this.error(getErrorMessage(error));
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,11 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class Login extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ email: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ "base-url": import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
11
+ //# sourceMappingURL=login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAQ5C,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;IACxC,OAAgB,WAAW,SAAkC;IAE7D,OAAgB,QAAQ,WAGvB;IAED,OAAgB,KAAK;;;MAUpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAgDlC"}