@myapihq/cli 1.0.84 → 1.1.0-wip.1

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 (77) hide show
  1. package/dist/commands/auth.d.ts +8 -3
  2. package/dist/commands/auth.js +84 -60
  3. package/dist/commands/billing.d.ts +8 -4
  4. package/dist/commands/billing.js +46 -27
  5. package/dist/commands/config.d.ts +8 -5
  6. package/dist/commands/config.js +52 -27
  7. package/dist/commands/domain.d.ts +12 -9
  8. package/dist/commands/domain.js +124 -86
  9. package/dist/commands/email/campaign.d.ts +2 -0
  10. package/dist/commands/email/campaign.js +152 -0
  11. package/dist/commands/email/index.d.ts +4 -0
  12. package/dist/commands/email/index.js +98 -0
  13. package/dist/commands/email/mailbox.d.ts +2 -0
  14. package/dist/commands/email/mailbox.js +88 -0
  15. package/dist/commands/email/message.d.ts +2 -0
  16. package/dist/commands/email/message.js +115 -0
  17. package/dist/commands/email/template.d.ts +2 -0
  18. package/dist/commands/email/template.js +106 -0
  19. package/dist/commands/email/warmup.d.ts +2 -0
  20. package/dist/commands/email/warmup.js +43 -0
  21. package/dist/commands/email.d.ts +4 -12
  22. package/dist/commands/email.js +528 -146
  23. package/dist/commands/funnel.d.ts +10 -7
  24. package/dist/commands/funnel.js +79 -55
  25. package/dist/commands/image.js +25 -15
  26. package/dist/commands/keys.d.ts +8 -3
  27. package/dist/commands/keys.js +71 -35
  28. package/dist/commands/org.d.ts +9 -5
  29. package/dist/commands/org.js +100 -64
  30. package/dist/commands/pixel.js +23 -11
  31. package/dist/commands/setup.d.ts +3 -2
  32. package/dist/commands/setup.js +160 -165
  33. package/dist/commands/storage.js +25 -15
  34. package/dist/commands/update.d.ts +2 -1
  35. package/dist/commands/update.js +5 -0
  36. package/dist/commands/url.js +19 -7
  37. package/dist/commands/webhook.d.ts +8 -5
  38. package/dist/commands/webhook.js +70 -38
  39. package/dist/commands/workflow.d.ts +13 -7
  40. package/dist/commands/workflow.js +179 -58
  41. package/dist/config.js +10 -5
  42. package/dist/flags.d.ts +8 -0
  43. package/dist/flags.js +88 -0
  44. package/dist/flags.test.d.ts +1 -0
  45. package/dist/flags.test.js +73 -0
  46. package/dist/helpers.d.ts +6 -0
  47. package/dist/helpers.js +31 -0
  48. package/dist/index.js +98 -109
  49. package/dist/output.d.ts +12 -1
  50. package/dist/output.js +16 -6
  51. package/dist/prompt.d.ts +24 -0
  52. package/dist/prompt.js +41 -0
  53. package/dist/skills/my-email-api/README.md +45 -0
  54. package/dist/skills/my-email-api/SKILL.md +104 -0
  55. package/dist/skills/my-email-api/claude/.claude-plugin/plugin.json +6 -0
  56. package/dist/skills/my-email-api/make/.gitkeep +0 -0
  57. package/dist/skills/my-email-api/n8n/.gitkeep +0 -0
  58. package/dist/skills/my-email-api/openapi/.gitkeep +0 -0
  59. package/dist/skills/my-webhook-api/README.md +40 -0
  60. package/dist/skills/my-webhook-api/SKILL.md +138 -0
  61. package/dist/skills/my-webhook-api/claude/.claude-plugin/plugin.json +6 -0
  62. package/dist/skills/my-webhook-api/make/.gitkeep +0 -0
  63. package/dist/skills/my-webhook-api/n8n/.gitkeep +0 -0
  64. package/dist/skills/my-webhook-api/openapi/.gitkeep +0 -0
  65. package/dist/skills/my-workflow-api/README.md +36 -0
  66. package/dist/skills/my-workflow-api/SKILL.md +156 -0
  67. package/dist/skills/my-workflow-api/claude/.claude-plugin/plugin.json +6 -0
  68. package/dist/skills/my-workflow-api/make/.gitkeep +0 -0
  69. package/dist/skills/my-workflow-api/n8n/.gitkeep +0 -0
  70. package/dist/skills/my-workflow-api/openapi/.gitkeep +0 -0
  71. package/dist/utils.d.ts +26 -4
  72. package/dist/utils.js +32 -33
  73. package/dist/utils.test.d.ts +1 -0
  74. package/dist/utils.test.js +48 -0
  75. package/package.json +9 -4
  76. package/dist/commands/account.d.ts +0 -4
  77. package/dist/commands/account.js +0 -80
@@ -0,0 +1,115 @@
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
+ async function send(flags) {
5
+ const config = requireConfig();
6
+ if (!flags.from || !flags.to || !flags.subject) {
7
+ error('Missing required arguments.\nUsage: myapi email message send --from <email> --to <email> --subject <str> [--body <str> | --html <str> | --template-id <id> [--template-vars <json>]]');
8
+ }
9
+ if (!flags.body && !flags.html && !flags['template-id'])
10
+ error('Must provide one of --body, --html, or --template-id');
11
+ if ((flags.body || flags.html) && flags['template-id'])
12
+ error('Cannot combine --body/--html with --template-id');
13
+ let templateVars;
14
+ if (flags['template-vars']) {
15
+ try {
16
+ templateVars = JSON.parse(flags['template-vars']);
17
+ }
18
+ catch {
19
+ error('--template-vars must be valid JSON');
20
+ }
21
+ }
22
+ const res = await sdkEmail.sendEmail(config.api_key, {
23
+ from: flags.from,
24
+ to: [flags.to],
25
+ subject: flags.subject,
26
+ text: flags.body,
27
+ html: flags.html,
28
+ template_id: flags['template-id'],
29
+ template_vars: templateVars,
30
+ });
31
+ success(`Email sent! Message ID: ${res.message_id}`);
32
+ }
33
+ async function status(messageId, _flags) {
34
+ const config = requireConfig();
35
+ if (!messageId)
36
+ error('Missing required arguments.\nUsage: myapi email message status <message_id>');
37
+ const res = await sdkEmail.getEmailStatus(config.api_key, messageId);
38
+ printJson(res);
39
+ }
40
+ async function sent(flags) {
41
+ const config = requireConfig();
42
+ const limit = flags.limit || 50;
43
+ const offset = flags.offset || 0;
44
+ const emails = await sdkEmail.getSentEmails(config.api_key, limit, offset);
45
+ printTable(emails, {
46
+ flags,
47
+ empty: 'No sent emails yet.',
48
+ });
49
+ }
50
+ async function inbox(address, flags) {
51
+ const config = requireConfig();
52
+ if (!address)
53
+ error('Missing required arguments.\nUsage: myapi email message inbox <address>');
54
+ const messages = await sdkEmail.getInbox(config.api_key, address);
55
+ printTable(messages, {
56
+ flags,
57
+ empty: `No messages in ${address}.`,
58
+ });
59
+ }
60
+ async function outbox(address, flags) {
61
+ const config = requireConfig();
62
+ if (!address)
63
+ error('Missing required arguments.\nUsage: myapi email message outbox <address>');
64
+ const messages = await sdkEmail.getOutbox(config.api_key, address);
65
+ printTable(messages, {
66
+ flags,
67
+ empty: `No outbound messages from ${address}.`,
68
+ });
69
+ }
70
+ async function get(messageId, flags) {
71
+ const config = requireConfig();
72
+ if (!messageId || !flags.address)
73
+ error('Missing required arguments.\nUsage: myapi email message get <message_id> --address <email>');
74
+ const res = await sdkEmail.getMessage(config.api_key, messageId, flags.address);
75
+ printJson(res);
76
+ }
77
+ const USAGE = {
78
+ 'send': 'myapi email message send --from <email> --to <email> --subject <str> [--body <str> | --html <str> | --template-id <id> [--template-vars <json>]]',
79
+ 'status': 'myapi email message status <message_id>',
80
+ 'sent': 'myapi email message sent [--limit <n>] [--offset <n>]',
81
+ 'inbox': 'myapi email message inbox <address>',
82
+ 'outbox': 'myapi email message outbox <address>',
83
+ 'get': 'myapi email message get <message_id> --address <email>',
84
+ };
85
+ export async function run(sub, args, flags) {
86
+ if (!sub || (flags.help && !sub)) {
87
+ info(`Usage: myapi email message <subcommand>
88
+
89
+ Subcommands:
90
+ send Send an email (transactional or templated)
91
+ status <id> Get delivery status of a sent message
92
+ sent List sent emails
93
+ inbox <addr> Read inbox for a mailbox address
94
+ outbox <addr> Read outbox for a mailbox address
95
+ get <id> Get a single message (--address <email>)`);
96
+ return;
97
+ }
98
+ if (flags.help) {
99
+ const usage = USAGE[sub];
100
+ if (usage)
101
+ info(`Usage: ${usage}`);
102
+ else
103
+ info(`Unknown subcommand: ${sub}. Run "myapi email message --help" for the list.`);
104
+ return;
105
+ }
106
+ switch (sub) {
107
+ case 'send': return send(flags);
108
+ case 'status': return status(args[0], flags);
109
+ case 'sent': return sent(flags);
110
+ case 'inbox': return inbox(args[0], flags);
111
+ case 'outbox': return outbox(args[0], flags);
112
+ case 'get': return get(args[0], flags);
113
+ default: error(`Unknown subcommand: ${sub}. Run "myapi email message --help" for the list.`);
114
+ }
115
+ }
@@ -0,0 +1,2 @@
1
+ import { type Flags } from '../../helpers.js';
2
+ export declare function run(sub: string | undefined, args: string[], flags: Flags): Promise<void>;
@@ -0,0 +1,106 @@
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 { pollJob } from '../../utils.js';
5
+ import { requireOrg } from '../../helpers.js';
6
+ async function generate(nameArg, flags) {
7
+ const config = requireConfig();
8
+ const orgId = requireOrg(flags, config, 'myapi email template generate <name> --prompt <str> [--org <id>]');
9
+ const name = nameArg || flags.name;
10
+ if (!name || !flags.prompt) {
11
+ error('Missing required arguments.\nUsage: myapi email template generate <name> --prompt <str> [--org <id>]\n or: myapi email template generate --name <name> --prompt <str> [--org <id>]');
12
+ }
13
+ const job = await sdkEmail.generateTemplate(config.api_key, orgId, {
14
+ prompt: flags.prompt,
15
+ name,
16
+ });
17
+ const status = await pollJob({
18
+ label: 'Generating template',
19
+ timeoutMs: 90_000,
20
+ intervalMs: 3000,
21
+ check: () => sdkEmail.getTemplateJobStatus(config.api_key, orgId, job.job_id),
22
+ isDone: s => s.status === 'completed',
23
+ isFailed: s => s.status === 'failed',
24
+ failedMessage: 'Template generation failed',
25
+ timeoutMessage: 'Template generation timed out',
26
+ });
27
+ success(`Template generated! ID: ${status.template_id}\nPreview: ${status.result?.preview_url}`);
28
+ }
29
+ async function list(flags) {
30
+ const config = requireConfig();
31
+ const orgId = requireOrg(flags, config, 'myapi email template list [--org <id>]');
32
+ const templates = await sdkEmail.listTemplates(config.api_key, orgId);
33
+ if (flags.json) {
34
+ printJson(templates);
35
+ return;
36
+ }
37
+ printTable(templates, {
38
+ flags,
39
+ empty: 'No templates yet. Generate one with: myapi email template generate --prompt <p> --name <n>',
40
+ });
41
+ }
42
+ async function edit(id, flags) {
43
+ const config = requireConfig();
44
+ const orgId = requireOrg(flags, config, 'myapi email template edit <id> --prompt <str> [--org <id>]');
45
+ if (!id || !flags.prompt)
46
+ error('Missing required arguments.\nUsage: myapi email template edit <id> --prompt <str> [--org <id>]');
47
+ const res = await sdkEmail.editTemplate(config.api_key, orgId, id, flags.prompt);
48
+ success(`Template ${res.template_id} edited\nPreview: ${res.preview_url}`);
49
+ }
50
+ async function sendTest(id, flags) {
51
+ const config = requireConfig();
52
+ const orgId = requireOrg(flags, config, 'myapi email template send-test <template_id> --to <email> [--org <id>]');
53
+ if (!id || !flags.to)
54
+ error('Missing required arguments.\nUsage: myapi email template send-test <template_id> --to <email> [--org <id>]');
55
+ const res = await sdkEmail.sendTestEmail(config.api_key, orgId, id, flags.to);
56
+ success(`Test sent! Message ID: ${res.message_id}`);
57
+ }
58
+ async function del(id, flags) {
59
+ const config = requireConfig();
60
+ const orgId = requireOrg(flags, config, 'myapi email template delete <id> [--org <id>]');
61
+ if (!id)
62
+ error('Missing required arguments.\nUsage: myapi email template delete <id> [--org <id>]');
63
+ await sdkEmail.deleteTemplate(config.api_key, orgId, id);
64
+ success(`Deleted template ${id}`);
65
+ }
66
+ const USAGE = {
67
+ 'generate': `myapi email template generate <name> --prompt <str> [--org <id>]
68
+ myapi email template generate --name <name> --prompt <str> [--org <id>]
69
+
70
+ Either form works; the positional name is the recommended shape.`,
71
+ 'list': 'myapi email template list [--org <id>] [--json]',
72
+ 'edit': 'myapi email template edit <id> --prompt <str> [--org <id>]',
73
+ 'send-test': 'myapi email template send-test <template_id> --to <email> [--org <id>]',
74
+ 'delete': 'myapi email template delete <id> [--org <id>]',
75
+ };
76
+ export async function run(sub, args, flags) {
77
+ if (!sub || (flags.help && !sub)) {
78
+ info(`Usage: myapi email template <subcommand>
79
+
80
+ Subcommands:
81
+ generate <name> Generate AI template (--prompt)
82
+ list List templates
83
+ edit <id> Edit a template via prompt
84
+ send-test <id> Send a test email for a template (--to)
85
+ delete <id> Delete a template
86
+
87
+ All commands accept --org <id> (or set default: myapi config set-org <id>).`);
88
+ return;
89
+ }
90
+ if (flags.help) {
91
+ const usage = USAGE[sub];
92
+ if (usage)
93
+ info(`Usage: ${usage}`);
94
+ else
95
+ info(`Unknown subcommand: ${sub}. Run "myapi email template --help" for the list.`);
96
+ return;
97
+ }
98
+ switch (sub) {
99
+ case 'generate': return generate(args[0], flags);
100
+ case 'list': return list(flags);
101
+ case 'edit': return edit(args[0], flags);
102
+ case 'send-test': return sendTest(args[0], flags);
103
+ case 'delete': return del(args[0], flags);
104
+ default: error(`Unknown subcommand: ${sub}. Run "myapi email template --help" for the list.`);
105
+ }
106
+ }
@@ -0,0 +1,2 @@
1
+ import type { Flags } from '../../helpers.js';
2
+ export declare function run(sub: string | undefined, args: string[], flags: Flags): Promise<void>;
@@ -0,0 +1,43 @@
1
+ import { email as sdkEmail } from '@myapihq/sdk';
2
+ import { requireConfig } from '../../config.js';
3
+ import { success, error, printJson, info } from '../../output.js';
4
+ export async function run(sub, args, flags) {
5
+ if (!sub || (flags.help && !sub)) {
6
+ info('Usage: myapi email warmup <start|pause|resume|stop|stats> --address <email>');
7
+ return;
8
+ }
9
+ if (flags.help) {
10
+ info(`Usage: myapi email warmup ${sub} --address <email>`);
11
+ return;
12
+ }
13
+ const config = requireConfig();
14
+ const address = flags.address || args[0];
15
+ if (!address)
16
+ error('Missing required argument: --address <email>');
17
+ switch (sub) {
18
+ case 'start': {
19
+ const res = await sdkEmail.startWarmup(config.api_key, address);
20
+ success(`Warmup started: ${address} (${res.warmup_status})`);
21
+ return;
22
+ }
23
+ case 'pause':
24
+ await sdkEmail.pauseWarmup(config.api_key, address);
25
+ success(`Warmup paused: ${address}`);
26
+ return;
27
+ case 'resume':
28
+ await sdkEmail.resumeWarmup(config.api_key, address);
29
+ success(`Warmup resumed: ${address}`);
30
+ return;
31
+ case 'stop':
32
+ await sdkEmail.stopWarmup(config.api_key, address);
33
+ success(`Warmup stopped: ${address}`);
34
+ return;
35
+ case 'stats': {
36
+ const res = await sdkEmail.getWarmupStats(config.api_key, address);
37
+ printJson(res);
38
+ return;
39
+ }
40
+ default:
41
+ error(`Unknown warmup subcommand: ${sub}. Use start|pause|resume|stop|stats`);
42
+ }
43
+ }
@@ -1,12 +1,4 @@
1
- export declare function createMailbox(flags: Record<string, string | boolean>): Promise<void>;
2
- export declare function listMailboxes(flags: Record<string, string | boolean>): Promise<void>;
3
- export declare function sent(flags: Record<string, string | boolean>): Promise<void>;
4
- export declare function send(flags: Record<string, string | boolean>): Promise<void>;
5
- export declare function inbox(address: string, flags: Record<string, string | boolean>): Promise<void>;
6
- export declare function outbox(address: string, flags: Record<string, string | boolean>): Promise<void>;
7
- export declare function listTemplates(flags: Record<string, string | boolean>): Promise<void>;
8
- export declare function deleteTemplate(id: string, flags: Record<string, string | boolean>): Promise<void>;
9
- export declare function generateTemplate(flags: Record<string, string | boolean>): Promise<void>;
10
- export declare function listCampaigns(flags: Record<string, string | boolean>): Promise<void>;
11
- export declare function campaignStats(id: string, flags: Record<string, string | boolean>): Promise<void>;
12
- 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 run(subcommand: string | undefined, args: string[], flags: Flags): Promise<void>;