@myapihq/cli 1.0.82 → 1.1.0-wip.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 (61) hide show
  1. package/dist/commands/auth.d.ts +8 -3
  2. package/dist/commands/auth.js +11 -29
  3. package/dist/commands/billing.d.ts +8 -4
  4. package/dist/commands/billing.js +43 -22
  5. package/dist/commands/config.d.ts +8 -5
  6. package/dist/commands/config.js +63 -28
  7. package/dist/commands/domain.d.ts +12 -9
  8. package/dist/commands/domain.js +117 -86
  9. package/dist/commands/email.d.ts +4 -12
  10. package/dist/commands/email.js +490 -128
  11. package/dist/commands/funnel.d.ts +10 -7
  12. package/dist/commands/funnel.js +78 -55
  13. package/dist/commands/image.js +25 -15
  14. package/dist/commands/keys.d.ts +8 -3
  15. package/dist/commands/keys.js +67 -28
  16. package/dist/commands/org.d.ts +9 -5
  17. package/dist/commands/org.js +121 -53
  18. package/dist/commands/pixel.js +23 -11
  19. package/dist/commands/setup.d.ts +3 -2
  20. package/dist/commands/setup.js +44 -77
  21. package/dist/commands/storage.js +25 -15
  22. package/dist/commands/update.d.ts +2 -1
  23. package/dist/commands/url.js +19 -7
  24. package/dist/commands/webhook.d.ts +8 -5
  25. package/dist/commands/webhook.js +52 -36
  26. package/dist/commands/workflow.d.ts +13 -7
  27. package/dist/commands/workflow.js +158 -56
  28. package/dist/flags.d.ts +8 -0
  29. package/dist/flags.js +88 -0
  30. package/dist/flags.test.d.ts +1 -0
  31. package/dist/flags.test.js +73 -0
  32. package/dist/helpers.d.ts +6 -0
  33. package/dist/helpers.js +29 -0
  34. package/dist/index.js +97 -107
  35. package/dist/output.d.ts +10 -1
  36. package/dist/output.js +4 -6
  37. package/dist/skills/my-email-api/README.md +45 -0
  38. package/dist/skills/my-email-api/SKILL.md +106 -0
  39. package/dist/skills/my-email-api/claude/.claude-plugin/plugin.json +6 -0
  40. package/dist/skills/my-email-api/make/.gitkeep +0 -0
  41. package/dist/skills/my-email-api/n8n/.gitkeep +0 -0
  42. package/dist/skills/my-email-api/openapi/.gitkeep +0 -0
  43. package/dist/skills/my-webhook-api/README.md +40 -0
  44. package/dist/skills/my-webhook-api/SKILL.md +65 -0
  45. package/dist/skills/my-webhook-api/claude/.claude-plugin/plugin.json +6 -0
  46. package/dist/skills/my-webhook-api/make/.gitkeep +0 -0
  47. package/dist/skills/my-webhook-api/n8n/.gitkeep +0 -0
  48. package/dist/skills/my-webhook-api/openapi/.gitkeep +0 -0
  49. package/dist/skills/my-workflow-api/README.md +37 -0
  50. package/dist/skills/my-workflow-api/SKILL.md +98 -0
  51. package/dist/skills/my-workflow-api/claude/.claude-plugin/plugin.json +6 -0
  52. package/dist/skills/my-workflow-api/make/.gitkeep +0 -0
  53. package/dist/skills/my-workflow-api/n8n/.gitkeep +0 -0
  54. package/dist/skills/my-workflow-api/openapi/.gitkeep +0 -0
  55. package/dist/utils.d.ts +0 -4
  56. package/dist/utils.js +0 -33
  57. package/dist/utils.test.d.ts +1 -0
  58. package/dist/utils.test.js +48 -0
  59. package/package.json +9 -4
  60. package/dist/commands/account.d.ts +0 -4
  61. package/dist/commands/account.js +0 -80
@@ -1,7 +1,10 @@
1
- export declare function list(flags: Record<string, string | boolean>): Promise<void>;
2
- export declare function create(flags: Record<string, string | boolean>): Promise<void>;
3
- export declare function get(id: string, flags: Record<string, string | boolean>): Promise<void>;
4
- export declare function del(id: string, flags: Record<string, string | boolean>): Promise<void>;
5
- export declare function push(slug: string, flags: Record<string, string | boolean>): Promise<void>;
6
- export declare function verify(id: string, flags: Record<string, string | boolean>): Promise<void>;
7
- export declare function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>): Promise<void>;
1
+ import type { FlagSchema } from '../flags.js';
2
+ import { type Flags } from '../helpers.js';
3
+ export declare const SCHEMA: FlagSchema;
4
+ export declare function list(flags: Flags): Promise<void>;
5
+ export declare function create(flags: Flags): Promise<void>;
6
+ export declare function get(id: string, flags: Flags): Promise<void>;
7
+ export declare function del(id: string, flags: Flags): Promise<void>;
8
+ export declare function push(slug: string, flags: Flags): Promise<void>;
9
+ export declare function verify(id: string, flags: Flags): Promise<void>;
10
+ export declare function run(subcommand: string | undefined, args: string[], flags: Flags): Promise<void>;
@@ -1,12 +1,16 @@
1
1
  import { funnel as sdkFunnel, hq } from '@myapihq/sdk';
2
- import { requireConfig, saveConfig } from '../config.js';
2
+ import { requireConfig } from '../config.js';
3
3
  import { success, error, printTable, info, printJson } from '../output.js';
4
4
  import { formatDate } from '../utils.js';
5
+ import { requireOrg } from '../helpers.js';
6
+ export const SCHEMA = {
7
+ org: 'string',
8
+ funnel: 'string',
9
+ slug: 'string',
10
+ };
5
11
  export async function list(flags) {
6
12
  const config = requireConfig();
7
- const orgId = flags.org || config.default_org;
8
- if (!orgId)
9
- error("Missing required arguments.\nUsage: myapi funnel list --org <id>\n(Or set defaults via: myapi config set-org <id>)");
13
+ const orgId = requireOrg(flags, config, 'myapi funnel list [--org <id>]');
10
14
  const funnels = await sdkFunnel.listFunnels(config.api_key, orgId);
11
15
  if (flags.json) {
12
16
  printJson(funnels);
@@ -18,18 +22,14 @@ export async function list(flags) {
18
22
  created_at: formatDate(f.created_at),
19
23
  updated_at: formatDate(f.updated_at),
20
24
  }));
21
- if (rows.length === 0) {
22
- info('No funnels found. Create one with: myapi funnel create');
23
- return;
24
- }
25
- printTable(rows);
25
+ printTable(rows, {
26
+ flags,
27
+ empty: 'No funnels found. Create one with: myapi funnel create',
28
+ });
26
29
  }
27
30
  export async function create(flags) {
28
31
  const config = requireConfig();
29
- const orgId = flags.org || config.default_org;
30
- if (!orgId) {
31
- error("Missing required arguments.\nUsage: myapi funnel create --org <id>\n(Or set defaults via: myapi config set-org <id>)");
32
- }
32
+ const orgId = requireOrg(flags, config, 'myapi funnel create [--org <id>]');
33
33
  const result = await sdkFunnel.createFunnel(config.api_key, orgId);
34
34
  success(`Funnel created! ID: ${result.funnel.id}`);
35
35
  if (result.domain_url)
@@ -39,9 +39,9 @@ export async function create(flags) {
39
39
  }
40
40
  export async function get(id, flags) {
41
41
  const config = requireConfig();
42
- const orgId = flags.org || config.default_org;
43
- if (!orgId || !id)
44
- error("Missing required arguments.\nUsage: myapi funnel get <id> --org <id>\n(Or set defaults via: myapi config set-org <id>)");
42
+ const orgId = requireOrg(flags, config, 'myapi funnel get <id> [--org <id>]');
43
+ if (!id)
44
+ error('Missing required arguments.\nUsage: myapi funnel get <id> [--org <id>]');
45
45
  const raw = await sdkFunnel.getFunnel(config.api_key, orgId, id);
46
46
  const funnel = raw.funnel ?? raw;
47
47
  const subdomain_url = raw.subdomain_url ?? funnel.subdomain_url;
@@ -64,27 +64,31 @@ export async function get(id, flags) {
64
64
  }
65
65
  export async function del(id, flags) {
66
66
  const config = requireConfig();
67
- const orgId = flags.org || config.default_org;
68
- if (!orgId || !id)
69
- error("Missing required arguments.\nUsage: myapi funnel delete <id> --org <id>\n(Or set defaults via: myapi config set-org <id>)");
67
+ const orgId = requireOrg(flags, config, 'myapi funnel delete <id> [--org <id>]');
68
+ if (!id)
69
+ error('Missing required arguments.\nUsage: myapi funnel delete <id> [--org <id>]');
70
70
  await sdkFunnel.deleteFunnel(config.api_key, orgId, id);
71
71
  success(`Funnel ${id} deleted`);
72
72
  }
73
73
  export async function push(slug, flags) {
74
74
  const config = requireConfig();
75
- const orgId = flags.org || config.default_org;
76
- if (!orgId)
77
- error("Missing org. Set a default with: myapi config set-org <id>");
75
+ const orgId = requireOrg(flags, config, 'myapi funnel push [slug] [--funnel <id>] [--org <id>]');
78
76
  const rawSlug = slug || flags.slug || '/';
79
77
  const finalSlug = rawSlug.startsWith('/') ? rawSlug : `/${rawSlug}`;
80
78
  let funnelId = flags.funnel || config.default_funnel;
79
+ let resolvedFromOrg = false;
81
80
  if (!funnelId) {
82
81
  const existing = await sdkFunnel.listFunnels(config.api_key, orgId);
83
82
  if (existing.length === 0)
84
- error("No funnel found for this org. Try: myapi auth config set-org <id>");
83
+ error('No funnel found for this org. Create one with: myapi funnel create');
84
+ if (existing.length > 1) {
85
+ error(`Multiple funnels exist for this org and no default is set.\nPick one with --funnel <id>, or set a default:\n myapi config set-funnel <id>\n\nFunnels:\n${existing.map(f => ` ${f.id}`).join('\n')}`);
86
+ }
85
87
  funnelId = existing[0].id;
86
- config.default_funnel = funnelId;
87
- saveConfig(config);
88
+ resolvedFromOrg = true;
89
+ }
90
+ if (process.stdin.isTTY) {
91
+ error("No content provided via stdin. Use a pipe or file:\n echo '<h1>Hello</h1>' | myapi funnel push /\n cat page.html | myapi funnel push /about");
88
92
  }
89
93
  const html = await new Promise((resolve, reject) => {
90
94
  let data = '';
@@ -97,6 +101,9 @@ export async function push(slug, flags) {
97
101
  error("No content provided via stdin. Usage: echo '<h1>Hello</h1>' | myapi funnel push [slug]");
98
102
  const result = await sdkFunnel.pushFunnelPage(config.api_key, orgId, funnelId, { slug: finalSlug, html });
99
103
  success(`Pushed page to ${finalSlug}`);
104
+ if (resolvedFromOrg) {
105
+ info(`(Used the org's only funnel: ${funnelId}. Set a default with: myapi config set-funnel ${funnelId})`);
106
+ }
100
107
  if (result?.url) {
101
108
  info(`Preview: ${result.url}`);
102
109
  }
@@ -109,47 +116,63 @@ export async function push(slug, flags) {
109
116
  }
110
117
  export async function verify(id, flags) {
111
118
  const config = requireConfig();
112
- const orgId = flags.org || config.default_org;
113
- if (!orgId || !id)
114
- error("Missing required arguments.\nUsage: myapi funnel verify <id> --org <id> [--slug <slug>]\n(Or set defaults via: myapi config set-org <id>)");
119
+ const orgId = requireOrg(flags, config, 'myapi funnel verify <id> [--slug <slug>] [--org <id>]');
120
+ if (!id)
121
+ error('Missing required arguments.\nUsage: myapi funnel verify <id> [--slug <slug>] [--org <id>]');
115
122
  const opts = {};
116
123
  if (flags.slug)
117
124
  opts.slug = flags.slug;
118
125
  const v = await sdkFunnel.verifyFunnel(config.api_key, orgId, id, opts);
119
126
  printJson(v);
120
127
  }
128
+ // ── Dispatcher ───────────────────────────────────────────────────────────────
129
+ const SUBCOMMAND_USAGE = {
130
+ 'list': 'myapi funnel list [--org <id>] [--json]',
131
+ 'create': 'myapi funnel create [--org <id>]',
132
+ 'get': 'myapi funnel get <id> [--org <id>] [--json]',
133
+ 'delete': 'myapi funnel delete <id> [--org <id>]',
134
+ 'push': `myapi funnel push [slug] [--funnel <id>] [--slug <path>] [--org <id>] < page.html
135
+
136
+ Reads HTML from stdin and publishes to <slug> on your funnel. Funnel is resolved
137
+ from --funnel, the default funnel, or (only if the org has exactly one) auto-picked.
138
+
139
+ Examples:
140
+ echo '<h1>Hello</h1>' | myapi funnel push /
141
+ cat about.html | myapi funnel push /about
142
+ myapi funnel push < index.html
143
+ cat p.html | myapi funnel push /pricing --funnel <uuid>`,
144
+ 'verify': 'myapi funnel verify <id> [--slug <slug>] [--org <id>]',
145
+ };
121
146
  export async function run(subcommand, args, flags) {
122
147
  if (!subcommand || (flags.help && !subcommand)) {
123
- info('Usage: myapi funnel <subcommand>\n\nSubcommands:\n list List funnels\n create Create a funnel\n get Get funnel details\n delete Delete a funnel\n push Push a raw HTML page to a slug\n\nNote: Most funnel commands require the --org <id> flag (or set a default via myapi auth config set-org <id>).');
148
+ info(`Usage: myapi funnel <subcommand>
149
+
150
+ Subcommands:
151
+ list List funnels
152
+ create Create a funnel
153
+ get <id> Get funnel details
154
+ delete Delete a funnel
155
+ push Push a raw HTML page from stdin to a slug
156
+ verify Verify a published page is reachable
157
+
158
+ All commands accept --org <id> (or set default: myapi config set-org <id>).`);
124
159
  return;
125
160
  }
126
161
  if (flags.help) {
127
- if (subcommand === 'list')
128
- info('Usage: myapi funnel list --org <id> [--json]\n\nLists all funnels (websites) in the organization.\n\nFlags:\n --org <id> Organization ID (or set default via myapi auth config set-org)\n --json Output raw JSON');
129
- else if (subcommand === 'create')
130
- info('Usage: myapi funnel create --org <id>\n\nCreates a new funnel in the organization.\n\nFlags:\n --org <id> Organization ID (or set default via myapi auth config set-org)');
131
- else if (subcommand === 'get')
132
- info('Usage: myapi funnel get <id> --org <id>\n\nFetches details of a specific funnel including its pages and settings.\n\nFlags:\n --org <id> Organization ID (or set default via myapi auth config set-org)');
133
- else if (subcommand === 'delete')
134
- info('Usage: myapi funnel delete <id> --org <id>\n\nDeletes a funnel permanently.\n\nFlags:\n --org <id> Organization ID (or set default via myapi auth config set-org)');
135
- else if (subcommand === 'push')
136
- info('Usage: myapi funnel push [slug] < page.html\n\nPublishes an HTML page from stdin to a path within your funnel (website).\nThe funnel is always resolved from your default or --funnel flag.\n\nFlags:\n --org <id> Organization ID (or set default via myapi config set-org)\n --funnel <id> Funnel ID (or set default via myapi config set-funnel)\n --slug <path> Alternative way to specify the slug\n\nExamples:\n echo \'<h1>Hello</h1>\' | myapi funnel push / # push to /\n cat about.html | myapi funnel push /about # push to /about\n myapi funnel push < index.html # push to / on default funnel\n cat p.html | myapi funnel push /pricing --funnel <uuid>');
137
- else if (subcommand === 'pull')
138
- info('Usage: myapi funnel pull [funnel_id] [slug]\n\nFetches the HTML content of a funnel page.');
162
+ const usage = SUBCOMMAND_USAGE[subcommand];
163
+ if (usage)
164
+ info(`Usage: ${usage}`);
165
+ else
166
+ info(`Unknown subcommand: ${subcommand}. Run "myapi funnel --help" for the list.`);
139
167
  return;
140
168
  }
141
- if (subcommand === 'list')
142
- await list(flags);
143
- else if (subcommand === 'create')
144
- await create(flags);
145
- else if (subcommand === 'get')
146
- await get(args[0], flags);
147
- else if (subcommand === 'delete')
148
- await del(args[0], flags);
149
- else if (subcommand === 'push')
150
- await push(args[0], flags);
151
- else if (subcommand === 'verify')
152
- await verify(args[0], flags);
153
- else
154
- error(`Unknown subcommand: ${subcommand}. Run "myapi funnel --help" for a list of valid subcommands.`);
169
+ switch (subcommand) {
170
+ case 'list': return list(flags);
171
+ case 'create': return create(flags);
172
+ case 'get': return get(args[0], flags);
173
+ case 'delete': return del(args[0], flags);
174
+ case 'push': return push(args[0], flags);
175
+ case 'verify': return verify(args[0], flags);
176
+ default: error(`Unknown subcommand: ${subcommand}. Run "myapi funnel --help" for a list of valid subcommands.`);
177
+ }
155
178
  }
@@ -61,26 +61,36 @@ export async function del(id, flags) {
61
61
  await sdkImage.deleteImage(config.api_key, orgId, id);
62
62
  success(`Image deleted! (Job ${id} history retained, URL nullified)`);
63
63
  }
64
+ // ── Dispatcher ───────────────────────────────────────────────────────────────
65
+ const SUBCOMMAND_USAGE = {
66
+ 'list': 'myapi image list [--org <id>] [--json]',
67
+ 'generate': 'myapi image generate --prompt "<text>" [--ratio <1:1|16:9>] [--style <style>] [--colors <hex_list>] [--org <id>]',
68
+ 'delete': 'myapi image delete <job_id> [--org <id>]',
69
+ };
64
70
  export async function run(subcommand, args, flags) {
65
71
  if (!subcommand || (flags.help && !subcommand)) {
66
- info('Usage: myapi image <subcommand>\n\nSubcommands:\n list List all your generated images\n generate Generate a new AI image from a prompt\n delete Delete the physical image file for a job\n\nNote: All image commands require the --org <id> flag.');
72
+ info(`Usage: myapi image <subcommand>
73
+
74
+ Subcommands:
75
+ list List all your generated images
76
+ generate Generate a new AI image from a prompt ($0.05 per generation)
77
+ delete Delete the physical image file for a job (history retained, URL nullified)
78
+
79
+ All commands accept --org <id> (or set default: myapi config set-org <id>).`);
67
80
  return;
68
81
  }
69
82
  if (flags.help) {
70
- if (subcommand === 'list')
71
- info('Usage: myapi image list --org <id> [--json]');
72
- else if (subcommand === 'generate')
73
- info('Usage: myapi image generate --prompt "<text>" [--ratio <1:1|16:9>] [--style <style>] [--colors <hex_list>] --org <id>\n\nGenerates an AI image and polls until the public URL is ready. Costs $0.05 per generation.');
74
- else if (subcommand === 'delete')
75
- info('Usage: myapi image delete <job_id> --org <id>\n\nDeletes the physical image file from storage. The generation job history is kept, but its URL will become null.');
83
+ const usage = SUBCOMMAND_USAGE[subcommand];
84
+ if (usage)
85
+ info(`Usage: ${usage}`);
86
+ else
87
+ info(`Unknown subcommand: ${subcommand}. Run "myapi image --help" for the list.`);
76
88
  return;
77
89
  }
78
- if (subcommand === 'list')
79
- await list(flags);
80
- else if (subcommand === 'generate')
81
- await generate(flags);
82
- else if (subcommand === 'delete')
83
- await del(args[0], flags);
84
- else
85
- error(`Unknown subcommand: ${subcommand}. Run "myapi image --help" for a list of valid subcommands.`);
90
+ switch (subcommand) {
91
+ case 'list': return list(flags);
92
+ case 'generate': return generate(flags);
93
+ case 'delete': return del(args[0], flags);
94
+ default: error(`Unknown subcommand: ${subcommand}. Run "myapi image --help" for a list of valid subcommands.`);
95
+ }
86
96
  }
@@ -1,3 +1,8 @@
1
- export declare function createNew(flags: Record<string, string | boolean>): Promise<void>;
2
- export declare function list(flags: Record<string, string | boolean>): Promise<void>;
3
- export declare function revoke(id: string, flags: Record<string, string | boolean>): Promise<void>;
1
+ import type { FlagSchema } from '../flags.js';
2
+ import type { Flags } from '../helpers.js';
3
+ export declare const SCHEMA: FlagSchema;
4
+ export declare function run(subcommand: string | undefined, args: string[], flags: Flags): Promise<void>;
5
+ export declare function runApiKeys(subcommand: string | undefined, args: string[], flags: Flags): Promise<void>;
6
+ export declare function createNew(flags: Flags): Promise<void>;
7
+ export declare function list(flags: Flags): Promise<void>;
8
+ export declare function revoke(id: string, flags: Flags): Promise<void>;
@@ -3,11 +3,63 @@ import { requireConfig } from '../config.js';
3
3
  import { success, error, printTable, info, printJson } from '../output.js';
4
4
  import { formatDate } from '../utils.js';
5
5
  import * as readline from 'readline';
6
- export async function createNew(flags) {
6
+ export const SCHEMA = {
7
+ name: 'string',
8
+ };
9
+ const KEYS_HEADER = `Usage: myapi keys <subcommand>
10
+
11
+ Manage programmatic API keys for your account.
12
+
13
+ Subcommands:
14
+ list List all API keys with IDs and creation dates
15
+ create Create a new API key (the key value is shown once)
16
+ revoke <id> Permanently revoke an API key by ID
17
+
18
+ Alias for: myapi auth api-keys`;
19
+ const API_KEYS_HEADER = `Usage: myapi auth api-keys <subcommand>
20
+
21
+ Manage programmatic API keys for your account.
22
+
23
+ Subcommands:
24
+ list List all API keys with IDs and creation dates
25
+ create Create a new API key (the key value is shown once)
26
+ revoke <id> Permanently revoke an API key by ID
27
+
28
+ Alias: myapi keys <subcommand>`;
29
+ function subcommandUsage(prefix) {
30
+ return {
31
+ 'list': `myapi ${prefix} list [--json]`,
32
+ 'create': `myapi ${prefix} create [--name <name>]\n\nCreates a new API key. If --name is omitted you will be prompted.`,
33
+ 'revoke': `myapi ${prefix} revoke <id>\n\nPermanently revokes an API key by ID. The key stops working immediately and the action cannot be undone.`,
34
+ };
35
+ }
36
+ async function dispatch(prefix, subcommand, args, flags) {
37
+ if (!subcommand || (flags.help && !subcommand)) {
38
+ info(prefix === 'keys' ? KEYS_HEADER : API_KEYS_HEADER);
39
+ return;
40
+ }
7
41
  if (flags.help) {
8
- info('Usage: myapi auth api-keys create [--name <name>]\n\nCreates a new API key.\n\nFlags:\n --name <name> Key name (skips prompt)');
42
+ const usage = subcommandUsage(prefix)[subcommand];
43
+ if (usage)
44
+ info(`Usage: ${usage}`);
45
+ else
46
+ info(`Unknown subcommand: ${subcommand}. Run "myapi ${prefix} --help" for the list.`);
9
47
  return;
10
48
  }
49
+ switch (subcommand) {
50
+ case 'create': return createNew(flags);
51
+ case 'list': return list(flags);
52
+ case 'revoke': return revoke(args[0], flags);
53
+ default: error(`Unknown subcommand: ${subcommand}. Run "myapi ${prefix} --help" for available subcommands.`);
54
+ }
55
+ }
56
+ export async function run(subcommand, args, flags) {
57
+ return dispatch('keys', subcommand, args, flags);
58
+ }
59
+ export async function runApiKeys(subcommand, args, flags) {
60
+ return dispatch('auth api-keys', subcommand, args, flags);
61
+ }
62
+ export async function createNew(flags) {
11
63
  const config = requireConfig();
12
64
  let name = flags.name || '';
13
65
  if (!name) {
@@ -15,46 +67,33 @@ export async function createNew(flags) {
15
67
  name = await new Promise(resolve => rl.question('Enter a name for the new key: ', resolve));
16
68
  rl.close();
17
69
  }
18
- if (!name.trim()) {
70
+ if (!name.trim())
19
71
  error('Key name cannot be empty. Use --name <name>');
20
- return;
21
- }
22
72
  const keyInfo = await hq.createApiKey(config.api_key, name.trim());
23
73
  success(`New API key created!\n\nName: ${keyInfo.prefix}...\nKey: ${keyInfo.api_key}\n\nMake sure to copy your new API key now. You won't be able to see it again!`);
24
74
  }
25
75
  export async function list(flags) {
26
- if (flags.help) {
27
- info('Usage: myapi auth api-keys list [--json]\n\nLists all API keys associated with your account.\n\nAlias: myapi keys list\n\nFlags:\n --json Output raw JSON');
28
- return;
29
- }
30
76
  const config = requireConfig();
31
77
  const keysList = await hq.listApiKeys(config.api_key);
32
78
  if (flags.json) {
33
79
  printJson(keysList);
34
80
  return;
35
81
  }
36
- const formattedKeys = keysList.map(k => {
37
- const createdStr = formatDate(k.created_at);
38
- const lastUsedStr = k.last_used_at ? formatDate(k.last_used_at) : 'Never';
39
- return {
40
- Name: k.name || 'Unnamed',
41
- Prefix: k.prefix,
42
- ID: k.id,
43
- 'Created At': createdStr,
44
- 'Last Used': lastUsedStr
45
- };
82
+ const formattedKeys = keysList.map(k => ({
83
+ Name: k.name || 'Unnamed',
84
+ Prefix: k.prefix,
85
+ ID: k.id,
86
+ 'Created At': formatDate(k.created_at),
87
+ 'Last Used': k.last_used_at ? formatDate(k.last_used_at) : 'Never',
88
+ }));
89
+ printTable(formattedKeys, {
90
+ flags,
91
+ empty: 'No API keys yet. Create one with: myapi keys create',
46
92
  });
47
- printTable(formattedKeys);
48
93
  }
49
94
  export async function revoke(id, flags) {
50
- if (flags.help) {
51
- info('Usage: myapi auth api-keys revoke <id>\n\nPermanently revokes an API key by ID. This action cannot be undone.\nThe key stops working immediately.\n\nAlias: myapi keys revoke <id>');
52
- return;
53
- }
54
- if (!id) {
55
- error("Missing key ID. Usage: myapi keys revoke <id>");
56
- return;
57
- }
95
+ if (!id)
96
+ error('Missing key ID. Usage: myapi keys revoke <id>');
58
97
  const config = requireConfig();
59
98
  await hq.revokeApiKey(config.api_key, id);
60
99
  success(`Key ${id} revoked successfully.`);
@@ -1,5 +1,9 @@
1
- export declare function create(flags: Record<string, string | boolean>): Promise<void>;
2
- export declare function list(flags: Record<string, string | boolean>): Promise<void>;
3
- export declare function get(id: string, flags: Record<string, string | boolean>): Promise<void>;
4
- export declare function del(id: string, flags: Record<string, string | boolean>): Promise<void>;
5
- export declare function importOrg(args: string[], flags: Record<string, string | boolean>): Promise<void>;
1
+ import type { FlagSchema } from '../flags.js';
2
+ import { type Flags } from '../helpers.js';
3
+ export declare const SCHEMA: FlagSchema;
4
+ export declare function create(restArgs: string[], flags: Flags): Promise<void>;
5
+ export declare function list(flags: Flags): Promise<void>;
6
+ export declare function get(id: string, flags: Flags): Promise<void>;
7
+ export declare function del(id: string, _flags: Flags): Promise<void>;
8
+ export declare function importOrg(args: string[], flags: Flags): Promise<void>;
9
+ export declare function run(subcommand: string | undefined, args: string[], flags: Flags): Promise<void>;