@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.
- package/dist/commands/auth.d.ts +8 -3
- package/dist/commands/auth.js +11 -29
- package/dist/commands/billing.d.ts +8 -4
- package/dist/commands/billing.js +43 -22
- package/dist/commands/config.d.ts +8 -5
- package/dist/commands/config.js +63 -28
- package/dist/commands/domain.d.ts +12 -9
- package/dist/commands/domain.js +117 -86
- package/dist/commands/email.d.ts +4 -12
- package/dist/commands/email.js +490 -128
- package/dist/commands/funnel.d.ts +10 -7
- package/dist/commands/funnel.js +78 -55
- package/dist/commands/image.js +25 -15
- package/dist/commands/keys.d.ts +8 -3
- package/dist/commands/keys.js +67 -28
- package/dist/commands/org.d.ts +9 -5
- package/dist/commands/org.js +121 -53
- package/dist/commands/pixel.js +23 -11
- package/dist/commands/setup.d.ts +3 -2
- package/dist/commands/setup.js +44 -77
- package/dist/commands/storage.js +25 -15
- package/dist/commands/update.d.ts +2 -1
- package/dist/commands/url.js +19 -7
- package/dist/commands/webhook.d.ts +8 -5
- package/dist/commands/webhook.js +52 -36
- package/dist/commands/workflow.d.ts +13 -7
- package/dist/commands/workflow.js +158 -56
- package/dist/flags.d.ts +8 -0
- package/dist/flags.js +88 -0
- package/dist/flags.test.d.ts +1 -0
- package/dist/flags.test.js +73 -0
- package/dist/helpers.d.ts +6 -0
- package/dist/helpers.js +29 -0
- package/dist/index.js +97 -107
- package/dist/output.d.ts +10 -1
- package/dist/output.js +4 -6
- package/dist/skills/my-email-api/README.md +45 -0
- package/dist/skills/my-email-api/SKILL.md +106 -0
- package/dist/skills/my-email-api/claude/.claude-plugin/plugin.json +6 -0
- package/dist/skills/my-email-api/make/.gitkeep +0 -0
- package/dist/skills/my-email-api/n8n/.gitkeep +0 -0
- package/dist/skills/my-email-api/openapi/.gitkeep +0 -0
- package/dist/skills/my-webhook-api/README.md +40 -0
- package/dist/skills/my-webhook-api/SKILL.md +65 -0
- package/dist/skills/my-webhook-api/claude/.claude-plugin/plugin.json +6 -0
- package/dist/skills/my-webhook-api/make/.gitkeep +0 -0
- package/dist/skills/my-webhook-api/n8n/.gitkeep +0 -0
- package/dist/skills/my-webhook-api/openapi/.gitkeep +0 -0
- package/dist/skills/my-workflow-api/README.md +37 -0
- package/dist/skills/my-workflow-api/SKILL.md +98 -0
- package/dist/skills/my-workflow-api/claude/.claude-plugin/plugin.json +6 -0
- package/dist/skills/my-workflow-api/make/.gitkeep +0 -0
- package/dist/skills/my-workflow-api/n8n/.gitkeep +0 -0
- package/dist/skills/my-workflow-api/openapi/.gitkeep +0 -0
- package/dist/utils.d.ts +0 -4
- package/dist/utils.js +0 -33
- package/dist/utils.test.d.ts +1 -0
- package/dist/utils.test.js +48 -0
- package/package.json +9 -4
- package/dist/commands/account.d.ts +0 -4
- package/dist/commands/account.js +0 -80
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
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>;
|
package/dist/commands/funnel.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { funnel as sdkFunnel, hq } from '@myapihq/sdk';
|
|
2
|
-
import { requireConfig
|
|
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
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
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
|
|
43
|
-
if (!
|
|
44
|
-
error(
|
|
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
|
|
68
|
-
if (!
|
|
69
|
-
error(
|
|
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
|
|
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(
|
|
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
|
-
|
|
87
|
-
|
|
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
|
|
113
|
-
if (!
|
|
114
|
-
error(
|
|
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(
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
}
|
package/dist/commands/image.js
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
}
|
package/dist/commands/keys.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare
|
|
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>;
|
package/dist/commands/keys.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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 (
|
|
51
|
-
|
|
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.`);
|
package/dist/commands/org.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
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>;
|