@myapihq/cli 1.0.15 → 1.0.17
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/billing.js +26 -32
- package/dist/commands/config.js +20 -26
- package/dist/commands/domain.js +56 -67
- package/dist/commands/email.d.ts +2 -0
- package/dist/commands/email.js +107 -72
- package/dist/commands/funnel.d.ts +0 -3
- package/dist/commands/funnel.js +43 -91
- package/dist/commands/image.js +17 -21
- package/dist/commands/keys.js +22 -60
- package/dist/commands/org.js +37 -44
- package/dist/commands/setup.js +13 -49
- package/dist/commands/storage.js +18 -23
- package/dist/commands/url.d.ts +2 -0
- package/dist/commands/url.js +29 -0
- package/dist/commands/webhook.d.ts +2 -0
- package/dist/commands/webhook.js +64 -24
- package/dist/commands/workflow.d.ts +1 -0
- package/dist/commands/workflow.js +81 -43
- package/dist/config.js +6 -44
- package/dist/index.js +45 -55
- package/dist/output.js +5 -12
- package/dist/utils.js +2 -6
- package/package.json +5 -2
- package/src/commands/billing.ts +1 -1
- package/src/commands/email.ts +48 -8
- package/src/commands/funnel.ts +3 -33
- package/src/commands/url.ts +28 -0
- package/src/commands/webhook.ts +50 -9
- package/src/commands/workflow.ts +55 -18
- package/src/index.ts +28 -0
package/dist/commands/email.js
CHANGED
|
@@ -1,73 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.listTemplates = listTemplates;
|
|
8
|
-
exports.generateTemplate = generateTemplate;
|
|
9
|
-
exports.listCampaigns = listCampaigns;
|
|
10
|
-
exports.campaignStats = campaignStats;
|
|
11
|
-
exports.run = run;
|
|
12
|
-
const sdk_1 = require("@myapihq/sdk");
|
|
13
|
-
const config_js_1 = require("../config.js");
|
|
14
|
-
const output_js_1 = require("../output.js");
|
|
15
|
-
const utils_js_1 = require("../utils.js");
|
|
16
|
-
async function createMailbox(flags) {
|
|
17
|
-
const config = (0, config_js_1.requireConfig)();
|
|
1
|
+
import { email as sdkEmail } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, printTable, printJson, info } from '../output.js';
|
|
4
|
+
import { sleep } from '../utils.js';
|
|
5
|
+
export async function createMailbox(flags) {
|
|
6
|
+
const config = requireConfig();
|
|
18
7
|
const orgId = flags.org || config.default_org;
|
|
19
8
|
const domain = flags.domain || config.default_domain;
|
|
20
9
|
if (!orgId || !domain || !flags.username) {
|
|
21
|
-
|
|
10
|
+
error("Missing required arguments.\nUsage: myapi email create-mailbox --org <id> --domain <domain> --username <user>\n(Or set defaults via: myapi config set-org <id> / set-domain <domain>)");
|
|
22
11
|
}
|
|
23
|
-
const address = await
|
|
24
|
-
|
|
12
|
+
const address = await sdkEmail.createMailbox(config.api_key, orgId, domain, flags.username);
|
|
13
|
+
success(`Mailbox created: ${address.address}`);
|
|
25
14
|
}
|
|
26
|
-
async function listMailboxes(flags) {
|
|
27
|
-
const config =
|
|
15
|
+
export async function listMailboxes(flags) {
|
|
16
|
+
const config = requireConfig();
|
|
28
17
|
const orgId = flags.org || config.default_org;
|
|
29
18
|
if (!orgId)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
error("Missing required arguments.\nUsage: myapi email list-mailboxes --org <id> [--domain <domain> | --filter unassigned]\n(Or set a default org via: myapi config set-org <id>)");
|
|
20
|
+
if (!flags.domain && flags.filter !== 'unassigned')
|
|
21
|
+
error("Must provide either --domain <domain> or --filter unassigned");
|
|
22
|
+
const mailboxes = await sdkEmail.listMailboxes(config.api_key, orgId, {
|
|
23
|
+
domain: flags.domain,
|
|
24
|
+
filter: flags.filter === 'unassigned' ? 'unassigned' : undefined
|
|
25
|
+
});
|
|
26
|
+
printTable(mailboxes);
|
|
33
27
|
}
|
|
34
|
-
async function
|
|
35
|
-
const config =
|
|
28
|
+
export async function sent(flags) {
|
|
29
|
+
const config = requireConfig();
|
|
36
30
|
const orgId = flags.org || config.default_org;
|
|
37
|
-
if (!orgId
|
|
38
|
-
|
|
31
|
+
if (!orgId)
|
|
32
|
+
error("Missing required arguments.\nUsage: myapi email sent --org <id> [--limit <num>] [--offset <num>]\n(Or set defaults via: myapi config set-org <id>)");
|
|
33
|
+
const limit = parseInt(flags.limit) || 50;
|
|
34
|
+
const offset = parseInt(flags.offset) || 0;
|
|
35
|
+
const emails = await sdkEmail.getSentEmails(config.api_key, orgId, limit, offset);
|
|
36
|
+
printTable(emails);
|
|
37
|
+
}
|
|
38
|
+
export async function send(flags) {
|
|
39
|
+
const config = requireConfig();
|
|
40
|
+
const orgId = flags.org || config.default_org;
|
|
41
|
+
if (!orgId || !flags.from || !flags.to || !flags.subject) {
|
|
42
|
+
error("Missing required arguments.\nUsage: myapi email send --org <id> --from <email> --to <email> --subject <str> [--body <str> | --template-id <id> [--template-vars <json_str>]]");
|
|
43
|
+
}
|
|
44
|
+
if (!flags.body && !flags['template-id'])
|
|
45
|
+
error("Must provide either --body or --template-id");
|
|
46
|
+
if (flags.body && flags['template-id'])
|
|
47
|
+
error("Cannot provide both --body and --template-id");
|
|
48
|
+
let templateVars;
|
|
49
|
+
if (flags['template-vars']) {
|
|
50
|
+
try {
|
|
51
|
+
templateVars = JSON.parse(flags['template-vars']);
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
error("--template-vars must be a valid JSON string");
|
|
55
|
+
}
|
|
39
56
|
}
|
|
40
|
-
const res = await
|
|
57
|
+
const res = await sdkEmail.sendEmail(config.api_key, orgId, {
|
|
41
58
|
from: flags.from,
|
|
42
59
|
to: [flags.to],
|
|
43
60
|
subject: flags.subject,
|
|
44
|
-
text: flags.body
|
|
61
|
+
text: flags.body,
|
|
62
|
+
template_id: flags['template-id'],
|
|
63
|
+
template_vars: templateVars
|
|
45
64
|
});
|
|
46
|
-
|
|
65
|
+
success(`Email sent! Message ID: ${res.message_id}`);
|
|
66
|
+
}
|
|
67
|
+
export async function inbox(address, flags) {
|
|
68
|
+
const config = requireConfig();
|
|
69
|
+
const orgId = flags.org || config.default_org;
|
|
70
|
+
if (!orgId || !address)
|
|
71
|
+
error("Missing required arguments.\nUsage: myapi email inbox <address> --org <id>");
|
|
72
|
+
const messages = await sdkEmail.getInbox(config.api_key, orgId, address);
|
|
73
|
+
printTable(messages);
|
|
47
74
|
}
|
|
48
|
-
async function
|
|
49
|
-
const config =
|
|
75
|
+
export async function outbox(address, flags) {
|
|
76
|
+
const config = requireConfig();
|
|
50
77
|
const orgId = flags.org || config.default_org;
|
|
51
78
|
if (!orgId || !address)
|
|
52
|
-
|
|
53
|
-
const messages = await
|
|
54
|
-
|
|
79
|
+
error("Missing required arguments.\nUsage: myapi email outbox <address> --org <id>");
|
|
80
|
+
const messages = await sdkEmail.getOutbox(config.api_key, orgId, address);
|
|
81
|
+
printTable(messages);
|
|
55
82
|
}
|
|
56
|
-
async function listTemplates(flags) {
|
|
57
|
-
const config =
|
|
83
|
+
export async function listTemplates(flags) {
|
|
84
|
+
const config = requireConfig();
|
|
58
85
|
const orgId = flags.org || config.default_org;
|
|
59
86
|
if (!orgId)
|
|
60
|
-
|
|
61
|
-
const templates = await
|
|
62
|
-
|
|
87
|
+
error("Missing required arguments.\nUsage: myapi email list-templates --org <id>\n(Or set a default org via: myapi config set-org <id>)");
|
|
88
|
+
const templates = await sdkEmail.listTemplates(config.api_key, orgId);
|
|
89
|
+
printTable(templates);
|
|
63
90
|
}
|
|
64
|
-
async function generateTemplate(flags) {
|
|
65
|
-
const config =
|
|
91
|
+
export async function generateTemplate(flags) {
|
|
92
|
+
const config = requireConfig();
|
|
66
93
|
const orgId = flags.org || config.default_org;
|
|
67
94
|
if (!orgId || !flags.prompt || !flags.name) {
|
|
68
|
-
|
|
95
|
+
error("Missing required arguments.\nUsage: myapi email generate-template --org <id> --prompt <str> --name <str>");
|
|
69
96
|
}
|
|
70
|
-
const job = await
|
|
97
|
+
const job = await sdkEmail.generateTemplate(config.api_key, orgId, {
|
|
71
98
|
prompt: flags.prompt,
|
|
72
99
|
name: flags.name
|
|
73
100
|
});
|
|
@@ -76,61 +103,65 @@ async function generateTemplate(flags) {
|
|
|
76
103
|
let i = 0;
|
|
77
104
|
let elapsed = 0;
|
|
78
105
|
while (elapsed < 90000) {
|
|
79
|
-
const status = await
|
|
106
|
+
const status = await sdkEmail.getTemplateJobStatus(config.api_key, orgId, job.job_id);
|
|
80
107
|
if (status.status === 'completed') {
|
|
81
108
|
process.stdout.write('\r\x1b[K');
|
|
82
|
-
|
|
109
|
+
success(`Template generated! ID: ${status.template_id}\nPreview: ${status.result?.preview_url}`);
|
|
83
110
|
return;
|
|
84
111
|
}
|
|
85
112
|
if (status.status === 'failed') {
|
|
86
113
|
process.stdout.write('\r\x1b[K');
|
|
87
|
-
|
|
114
|
+
error("Template generation failed");
|
|
88
115
|
}
|
|
89
116
|
process.stdout.write(`\rGenerating template ${chars[i++ % chars.length]}`);
|
|
90
|
-
await
|
|
117
|
+
await sleep(3000);
|
|
91
118
|
elapsed += 3000;
|
|
92
119
|
}
|
|
93
120
|
process.stdout.write('\r\x1b[K');
|
|
94
|
-
|
|
121
|
+
error("Template generation timed out");
|
|
95
122
|
}
|
|
96
|
-
async function listCampaigns(flags) {
|
|
97
|
-
const config =
|
|
123
|
+
export async function listCampaigns(flags) {
|
|
124
|
+
const config = requireConfig();
|
|
98
125
|
const orgId = flags.org || config.default_org;
|
|
99
126
|
if (!orgId)
|
|
100
|
-
|
|
101
|
-
const campaigns = await
|
|
102
|
-
|
|
127
|
+
error("Missing required arguments.\nUsage: myapi email list-campaigns --org <id>\n(Or set a default org via: myapi config set-org <id>)");
|
|
128
|
+
const campaigns = await sdkEmail.listCampaigns(config.api_key, orgId);
|
|
129
|
+
printTable(campaigns);
|
|
103
130
|
}
|
|
104
|
-
async function campaignStats(id, flags) {
|
|
105
|
-
const config =
|
|
131
|
+
export async function campaignStats(id, flags) {
|
|
132
|
+
const config = requireConfig();
|
|
106
133
|
const orgId = flags.org || config.default_org;
|
|
107
134
|
if (!orgId || !id)
|
|
108
|
-
|
|
109
|
-
const stats = await
|
|
110
|
-
|
|
135
|
+
error("Missing required arguments.\nUsage: myapi email campaign-stats <id> --org <id>");
|
|
136
|
+
const stats = await sdkEmail.getCampaignStats(config.api_key, orgId, id);
|
|
137
|
+
printJson(stats);
|
|
111
138
|
}
|
|
112
|
-
async function run(subcommand, args, flags) {
|
|
139
|
+
export async function run(subcommand, args, flags) {
|
|
113
140
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
114
|
-
|
|
141
|
+
info('Usage: myapi email <subcommand>\n\nSubcommands:\n create-mailbox Create a new mailbox\n list-mailboxes List mailboxes\n send Send an email\n sent List sent emails\n inbox Read received emails\n outbox Read sent emails for address\n list-templates List email templates\n generate-template Generate AI template\n list-campaigns List campaigns\n campaign-stats Get campaign stats\n\nNote: All email commands require the --org <id> flag.');
|
|
115
142
|
return;
|
|
116
143
|
}
|
|
117
144
|
if (flags.help) {
|
|
118
145
|
if (subcommand === 'create-mailbox')
|
|
119
|
-
|
|
146
|
+
info('Usage: myapi email create-mailbox --org <id> --domain <domain> --username <user>');
|
|
120
147
|
else if (subcommand === 'list-mailboxes')
|
|
121
|
-
|
|
148
|
+
info('Usage: myapi email list-mailboxes --org <id> [--domain <domain> | --filter unassigned]');
|
|
122
149
|
else if (subcommand === 'send')
|
|
123
|
-
|
|
150
|
+
info('Usage: myapi email send --org <id> --from <email> --to <email> --subject <str> [--body <str> | --template-id <id> [--template-vars <json_str>]]');
|
|
151
|
+
else if (subcommand === 'sent')
|
|
152
|
+
info('Usage: myapi email sent --org <id> [--limit <num>] [--offset <num>]');
|
|
124
153
|
else if (subcommand === 'inbox')
|
|
125
|
-
|
|
154
|
+
info('Usage: myapi email inbox <address> --org <id>');
|
|
155
|
+
else if (subcommand === 'outbox')
|
|
156
|
+
info('Usage: myapi email outbox <address> --org <id>');
|
|
126
157
|
else if (subcommand === 'list-templates')
|
|
127
|
-
|
|
158
|
+
info('Usage: myapi email list-templates --org <id>');
|
|
128
159
|
else if (subcommand === 'generate-template')
|
|
129
|
-
|
|
160
|
+
info('Usage: myapi email generate-template --org <id> --prompt <str> --name <str>');
|
|
130
161
|
else if (subcommand === 'list-campaigns')
|
|
131
|
-
|
|
162
|
+
info('Usage: myapi email list-campaigns --org <id>');
|
|
132
163
|
else if (subcommand === 'campaign-stats')
|
|
133
|
-
|
|
164
|
+
info('Usage: myapi email campaign-stats <campaign_id> --org <id>');
|
|
134
165
|
return;
|
|
135
166
|
}
|
|
136
167
|
if (subcommand === 'create-mailbox')
|
|
@@ -139,8 +170,12 @@ async function run(subcommand, args, flags) {
|
|
|
139
170
|
await listMailboxes(flags);
|
|
140
171
|
else if (subcommand === 'send')
|
|
141
172
|
await send(flags);
|
|
173
|
+
else if (subcommand === 'sent')
|
|
174
|
+
await sent(flags);
|
|
142
175
|
else if (subcommand === 'inbox')
|
|
143
176
|
await inbox(args[0], flags);
|
|
177
|
+
else if (subcommand === 'outbox')
|
|
178
|
+
await outbox(args[0], flags);
|
|
144
179
|
else if (subcommand === 'list-templates')
|
|
145
180
|
await listTemplates(flags);
|
|
146
181
|
else if (subcommand === 'generate-template')
|
|
@@ -150,5 +185,5 @@ async function run(subcommand, args, flags) {
|
|
|
150
185
|
else if (subcommand === 'campaign-stats')
|
|
151
186
|
await campaignStats(args[0], flags);
|
|
152
187
|
else
|
|
153
|
-
|
|
188
|
+
error(`Unknown subcommand: ${subcommand}. Run "myapi email --help" for a list of valid subcommands.`);
|
|
154
189
|
}
|
|
@@ -2,9 +2,6 @@ export declare function list(flags: Record<string, string | boolean>): Promise<v
|
|
|
2
2
|
export declare function create(flags: Record<string, string | boolean>): Promise<void>;
|
|
3
3
|
export declare function get(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
4
4
|
export declare function del(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
5
|
-
export declare function preview(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
6
|
-
export declare function publish(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
7
|
-
export declare function status(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
8
5
|
export declare function push(id: string, slug: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
9
6
|
export declare function verify(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
10
7
|
export declare function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>): Promise<void>;
|
package/dist/commands/funnel.js
CHANGED
|
@@ -1,81 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.del = del;
|
|
7
|
-
exports.preview = preview;
|
|
8
|
-
exports.publish = publish;
|
|
9
|
-
exports.status = status;
|
|
10
|
-
exports.push = push;
|
|
11
|
-
exports.verify = verify;
|
|
12
|
-
exports.run = run;
|
|
13
|
-
const sdk_1 = require("@myapihq/sdk");
|
|
14
|
-
const config_js_1 = require("../config.js");
|
|
15
|
-
const output_js_1 = require("../output.js");
|
|
16
|
-
async function list(flags) {
|
|
17
|
-
const config = (0, config_js_1.requireConfig)();
|
|
1
|
+
import { funnel as sdkFunnel } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, printTable, info, printJson } from '../output.js';
|
|
4
|
+
export async function list(flags) {
|
|
5
|
+
const config = requireConfig();
|
|
18
6
|
const orgId = flags.org || config.default_org;
|
|
19
7
|
if (!orgId)
|
|
20
|
-
|
|
21
|
-
const funnels = await
|
|
22
|
-
|
|
8
|
+
error("Missing required arguments.\nUsage: myapi funnel list --org <id>\n(Or set defaults via: myapi config set-org <id>)");
|
|
9
|
+
const funnels = await sdkFunnel.listFunnels(config.api_key, orgId);
|
|
10
|
+
printTable(funnels);
|
|
23
11
|
}
|
|
24
|
-
async function create(flags) {
|
|
25
|
-
const config =
|
|
12
|
+
export async function create(flags) {
|
|
13
|
+
const config = requireConfig();
|
|
26
14
|
const orgId = flags.org || config.default_org;
|
|
27
15
|
const domain = flags.domain || config.default_domain;
|
|
28
16
|
if (!orgId || !domain) {
|
|
29
|
-
|
|
17
|
+
error("Missing required arguments.\nUsage: myapi funnel create --org <id> --domain <domain>\n(Or set defaults via: myapi config set-org <id> / set-domain <domain>)");
|
|
30
18
|
}
|
|
31
|
-
const funnel = await
|
|
32
|
-
|
|
19
|
+
const funnel = await sdkFunnel.createFunnel(config.api_key, orgId, domain);
|
|
20
|
+
success(`Funnel created! ID: ${funnel.id}`);
|
|
33
21
|
}
|
|
34
|
-
async function get(id, flags) {
|
|
35
|
-
const config =
|
|
22
|
+
export async function get(id, flags) {
|
|
23
|
+
const config = requireConfig();
|
|
36
24
|
const orgId = flags.org || config.default_org;
|
|
37
25
|
if (!orgId || !id)
|
|
38
|
-
|
|
39
|
-
const funnel = await
|
|
40
|
-
|
|
26
|
+
error("Missing required arguments.\nUsage: myapi funnel get <id> --org <id>\n(Or set defaults via: myapi config set-org <id>)");
|
|
27
|
+
const funnel = await sdkFunnel.getFunnel(config.api_key, orgId, id);
|
|
28
|
+
printJson(funnel);
|
|
41
29
|
}
|
|
42
|
-
async function del(id, flags) {
|
|
43
|
-
const config =
|
|
30
|
+
export async function del(id, flags) {
|
|
31
|
+
const config = requireConfig();
|
|
44
32
|
const orgId = flags.org || config.default_org;
|
|
45
33
|
if (!orgId || !id)
|
|
46
|
-
|
|
47
|
-
await
|
|
48
|
-
|
|
34
|
+
error("Missing required arguments.\nUsage: myapi funnel delete <id> --org <id>\n(Or set defaults via: myapi config set-org <id>)");
|
|
35
|
+
await sdkFunnel.deleteFunnel(config.api_key, orgId, id);
|
|
36
|
+
success(`Funnel ${id} deleted`);
|
|
49
37
|
}
|
|
50
|
-
async function
|
|
51
|
-
const config =
|
|
52
|
-
const orgId = flags.org || config.default_org;
|
|
53
|
-
if (!orgId || !id)
|
|
54
|
-
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi funnel preview <id> --org <id>\n(Or set defaults via: myapi config set-org <id>)");
|
|
55
|
-
const p = await sdk_1.funnel.previewFunnel(config.api_key, orgId, id);
|
|
56
|
-
(0, output_js_1.success)(`Preview deployed: ${p.preview_url}`);
|
|
57
|
-
}
|
|
58
|
-
async function publish(id, flags) {
|
|
59
|
-
const config = (0, config_js_1.requireConfig)();
|
|
60
|
-
const orgId = flags.org || config.default_org;
|
|
61
|
-
if (!orgId || !id)
|
|
62
|
-
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi funnel publish <id> --org <id>\n(Or set defaults via: myapi config set-org <id>)");
|
|
63
|
-
const p = await sdk_1.funnel.publishFunnel(config.api_key, orgId, id);
|
|
64
|
-
(0, output_js_1.success)(`Publish job started. Status: ${p.status}`);
|
|
65
|
-
}
|
|
66
|
-
async function status(id, flags) {
|
|
67
|
-
const config = (0, config_js_1.requireConfig)();
|
|
68
|
-
const orgId = flags.org || config.default_org;
|
|
69
|
-
if (!orgId || !id)
|
|
70
|
-
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi funnel status <id> --org <id>\n(Or set defaults via: myapi config set-org <id>)");
|
|
71
|
-
const s = await sdk_1.funnel.getPublishStatus(config.api_key, orgId, id);
|
|
72
|
-
(0, output_js_1.info)(`Publish Status: ${s.status}`);
|
|
73
|
-
}
|
|
74
|
-
async function push(id, slug, flags) {
|
|
75
|
-
const config = (0, config_js_1.requireConfig)();
|
|
38
|
+
export async function push(id, slug, flags) {
|
|
39
|
+
const config = requireConfig();
|
|
76
40
|
const orgId = flags.org || config.default_org;
|
|
77
41
|
if (!orgId || !id || !slug) {
|
|
78
|
-
|
|
42
|
+
error("Missing required arguments.\nUsage: myapi funnel push <funnel_id> <slug> --org <id> < index.html\n(Or set defaults via: myapi config set-org <id>)");
|
|
79
43
|
}
|
|
80
44
|
const html = await new Promise((resolve, reject) => {
|
|
81
45
|
let data = '';
|
|
@@ -85,45 +49,39 @@ async function push(id, slug, flags) {
|
|
|
85
49
|
process.stdin.on('error', reject);
|
|
86
50
|
});
|
|
87
51
|
if (!html)
|
|
88
|
-
|
|
89
|
-
await
|
|
90
|
-
|
|
52
|
+
error("No HTML provided via stdin");
|
|
53
|
+
await sdkFunnel.pushFunnelPage(config.api_key, orgId, id, { slug, html });
|
|
54
|
+
success(`Pushed page to ${slug}`);
|
|
91
55
|
}
|
|
92
|
-
async function verify(id, flags) {
|
|
93
|
-
const config =
|
|
56
|
+
export async function verify(id, flags) {
|
|
57
|
+
const config = requireConfig();
|
|
94
58
|
const orgId = flags.org || config.default_org;
|
|
95
59
|
if (!orgId || !id)
|
|
96
|
-
|
|
60
|
+
error("Missing required arguments.\nUsage: myapi funnel verify <id> --org <id> [--slug <slug>]\n(Or set defaults via: myapi config set-org <id>)");
|
|
97
61
|
const opts = {};
|
|
98
62
|
if (flags.slug)
|
|
99
63
|
opts.slug = flags.slug;
|
|
100
|
-
const v = await
|
|
101
|
-
|
|
64
|
+
const v = await sdkFunnel.verifyFunnel(config.api_key, orgId, id, opts);
|
|
65
|
+
printJson(v);
|
|
102
66
|
}
|
|
103
|
-
async function run(subcommand, args, flags) {
|
|
67
|
+
export async function run(subcommand, args, flags) {
|
|
104
68
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
105
|
-
|
|
69
|
+
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 verify Verify links and webhooks\n\nNote: All funnel commands require the --org <id> flag.');
|
|
106
70
|
return;
|
|
107
71
|
}
|
|
108
72
|
if (flags.help) {
|
|
109
73
|
if (subcommand === 'list')
|
|
110
|
-
|
|
74
|
+
info('Usage: myapi funnel list --org <id>');
|
|
111
75
|
else if (subcommand === 'create')
|
|
112
|
-
|
|
76
|
+
info('Usage: myapi funnel create --org <id> --domain <domain>');
|
|
113
77
|
else if (subcommand === 'get')
|
|
114
|
-
|
|
78
|
+
info('Usage: myapi funnel get <id> --org <id>');
|
|
115
79
|
else if (subcommand === 'delete')
|
|
116
|
-
|
|
117
|
-
else if (subcommand === 'preview')
|
|
118
|
-
(0, output_js_1.info)('Usage: myapi funnel preview <id> --org <id>');
|
|
119
|
-
else if (subcommand === 'publish')
|
|
120
|
-
(0, output_js_1.info)('Usage: myapi funnel publish <id> --org <id>');
|
|
121
|
-
else if (subcommand === 'status')
|
|
122
|
-
(0, output_js_1.info)('Usage: myapi funnel status <id> --org <id>');
|
|
80
|
+
info('Usage: myapi funnel delete <id> --org <id>');
|
|
123
81
|
else if (subcommand === 'push')
|
|
124
|
-
|
|
82
|
+
info('Usage: myapi funnel push <funnel_id> <slug> --org <id> < index.html\n\nPushes HTML content from stdin to the specified funnel.');
|
|
125
83
|
else if (subcommand === 'verify')
|
|
126
|
-
|
|
84
|
+
info('Usage: myapi funnel verify <id> --org <id> [--slug <slug>]\n\nVerifies syntax and structure before pushing.');
|
|
127
85
|
return;
|
|
128
86
|
}
|
|
129
87
|
if (subcommand === 'list')
|
|
@@ -134,16 +92,10 @@ async function run(subcommand, args, flags) {
|
|
|
134
92
|
await get(args[0], flags);
|
|
135
93
|
else if (subcommand === 'delete')
|
|
136
94
|
await del(args[0], flags);
|
|
137
|
-
else if (subcommand === 'preview')
|
|
138
|
-
await preview(args[0], flags);
|
|
139
|
-
else if (subcommand === 'publish')
|
|
140
|
-
await publish(args[0], flags);
|
|
141
|
-
else if (subcommand === 'status')
|
|
142
|
-
await status(args[0], flags);
|
|
143
95
|
else if (subcommand === 'push')
|
|
144
96
|
await push(args[0], args[1], flags);
|
|
145
97
|
else if (subcommand === 'verify')
|
|
146
98
|
await verify(args[0], flags);
|
|
147
99
|
else
|
|
148
|
-
|
|
100
|
+
error(`Unknown subcommand: ${subcommand}. Run "myapi funnel --help" for a list of valid subcommands.`);
|
|
149
101
|
}
|
package/dist/commands/image.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const config_js_1 = require("../config.js");
|
|
7
|
-
const output_js_1 = require("../output.js");
|
|
8
|
-
const utils_js_1 = require("../utils.js");
|
|
9
|
-
async function generate(flags) {
|
|
1
|
+
import { image as sdkImage } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, printTable } from '../output.js';
|
|
4
|
+
import { sleep } from '../utils.js';
|
|
5
|
+
export async function generate(flags) {
|
|
10
6
|
if (!flags.prompt)
|
|
11
|
-
|
|
12
|
-
const config =
|
|
7
|
+
error("Missing --prompt flag");
|
|
8
|
+
const config = requireConfig();
|
|
13
9
|
const payload = { prompt: flags.prompt };
|
|
14
10
|
if (flags.ratio)
|
|
15
11
|
payload.aspect_ratio = flags.ratio;
|
|
@@ -17,31 +13,31 @@ async function generate(flags) {
|
|
|
17
13
|
payload.style = flags.style;
|
|
18
14
|
if (flags.colors)
|
|
19
15
|
payload.colors = flags.colors;
|
|
20
|
-
const res = await
|
|
16
|
+
const res = await sdkImage.generateImage(config.api_key, payload);
|
|
21
17
|
process.stdout.write("Generating image ");
|
|
22
18
|
const chars = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
23
19
|
let i = 0;
|
|
24
20
|
let elapsed = 0;
|
|
25
21
|
while (elapsed < 60000) {
|
|
26
|
-
const job = await
|
|
22
|
+
const job = await sdkImage.getImageJob(config.api_key, res.job_id);
|
|
27
23
|
if (job.status === 'completed') {
|
|
28
24
|
process.stdout.write('\r\x1b[K');
|
|
29
|
-
|
|
25
|
+
success(`Image generated!\nURL: ${job.url}`);
|
|
30
26
|
return;
|
|
31
27
|
}
|
|
32
28
|
if (job.status === 'failed') {
|
|
33
29
|
process.stdout.write('\r\x1b[K');
|
|
34
|
-
|
|
30
|
+
error(`Image generation failed: ${job.error || 'Unknown error'}`);
|
|
35
31
|
}
|
|
36
32
|
process.stdout.write(`\rGenerating image ${chars[i++ % chars.length]}`);
|
|
37
|
-
await
|
|
33
|
+
await sleep(3000);
|
|
38
34
|
elapsed += 3000;
|
|
39
35
|
}
|
|
40
36
|
process.stdout.write('\r\x1b[K');
|
|
41
|
-
|
|
37
|
+
error("Image generation timed out");
|
|
42
38
|
}
|
|
43
|
-
async function list(flags) {
|
|
44
|
-
const config =
|
|
45
|
-
const images = await
|
|
46
|
-
|
|
39
|
+
export async function list(flags) {
|
|
40
|
+
const config = requireConfig();
|
|
41
|
+
const images = await sdkImage.listImages(config.api_key);
|
|
42
|
+
printTable(images);
|
|
47
43
|
}
|
package/dist/commands/keys.js
CHANGED
|
@@ -1,70 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.createNew = createNew;
|
|
37
|
-
exports.list = list;
|
|
38
|
-
exports.revoke = revoke;
|
|
39
|
-
const sdk_1 = require("@myapihq/sdk");
|
|
40
|
-
const config_js_1 = require("../config.js");
|
|
41
|
-
const output_js_1 = require("../output.js");
|
|
42
|
-
const readline = __importStar(require("readline"));
|
|
43
|
-
async function createNew(flags) {
|
|
1
|
+
import { hq } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, printTable, info, printJson } from '../output.js';
|
|
4
|
+
import * as readline from 'readline';
|
|
5
|
+
export async function createNew(flags) {
|
|
44
6
|
if (flags.help) {
|
|
45
|
-
|
|
7
|
+
info('Usage: myapi keys create\n\nCreates a new API key. You will be prompted to enter a name for the key.');
|
|
46
8
|
return;
|
|
47
9
|
}
|
|
48
|
-
const config =
|
|
10
|
+
const config = requireConfig();
|
|
49
11
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
50
12
|
const name = await new Promise(resolve => rl.question('Enter a name for the new key: ', resolve));
|
|
51
13
|
rl.close();
|
|
52
14
|
if (!name.trim()) {
|
|
53
|
-
|
|
15
|
+
error('Key name cannot be empty.');
|
|
54
16
|
return;
|
|
55
17
|
}
|
|
56
|
-
const keyInfo = await
|
|
57
|
-
|
|
18
|
+
const keyInfo = await hq.createApiKey(config.api_key, name.trim());
|
|
19
|
+
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!`);
|
|
58
20
|
}
|
|
59
|
-
async function list(flags) {
|
|
21
|
+
export async function list(flags) {
|
|
60
22
|
if (flags.help) {
|
|
61
|
-
|
|
23
|
+
info('Usage: myapi keys list [--json]\n\nLists all API keys associated with your account.');
|
|
62
24
|
return;
|
|
63
25
|
}
|
|
64
|
-
const config =
|
|
65
|
-
const keysList = await
|
|
26
|
+
const config = requireConfig();
|
|
27
|
+
const keysList = await hq.listApiKeys(config.api_key);
|
|
66
28
|
if (flags.json) {
|
|
67
|
-
|
|
29
|
+
printJson(keysList);
|
|
68
30
|
return;
|
|
69
31
|
}
|
|
70
32
|
const formattedKeys = keysList.map(k => {
|
|
@@ -85,18 +47,18 @@ async function list(flags) {
|
|
|
85
47
|
'Last Used': lastUsedStr
|
|
86
48
|
};
|
|
87
49
|
});
|
|
88
|
-
|
|
50
|
+
printTable(formattedKeys);
|
|
89
51
|
}
|
|
90
|
-
async function revoke(id, flags) {
|
|
52
|
+
export async function revoke(id, flags) {
|
|
91
53
|
if (flags.help) {
|
|
92
|
-
|
|
54
|
+
info('Usage: myapi keys revoke <id>\n\nRevokes an API key permanently.');
|
|
93
55
|
return;
|
|
94
56
|
}
|
|
95
57
|
if (!id) {
|
|
96
|
-
|
|
58
|
+
error("Missing key ID. Usage: myapi keys revoke <id>");
|
|
97
59
|
return;
|
|
98
60
|
}
|
|
99
|
-
const config =
|
|
100
|
-
await
|
|
101
|
-
|
|
61
|
+
const config = requireConfig();
|
|
62
|
+
await hq.revokeApiKey(config.api_key, id);
|
|
63
|
+
success(`Key ${id} revoked successfully.`);
|
|
102
64
|
}
|